Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
// bullet.js
// Handling enemys' bullets.
var BULLET_TYPE_AIM = 0;
var BULLET_TYPE_SHOTGUN = 1;
var BULLET_TYPE_3WAY = 2;
var BULLET_TYPE_5WAY = 3;
var bicons = new Array;
var bicon = new GIcon;
bicon.image = "images/bullet.png";
bicon.shadow = "images/dummy_shadow.png";
bicon.iconSize = new GSize(16, 16);
bicon.shadowSize = new GSize(1, 1);
bicon.iconAnchor = new GPoint(8, 8);
var bsicon;
bsicon = new GIcon(bicon);
bsicon.iconSize = new GSize(4, 4);
bsicon.iconAnchor = new GPoint(2, 2);
bicons.push(bsicon);
bsicon = new GIcon(bicon);
bsicon.iconSize = new GSize(8, 8);
bsicon.iconAnchor = new GPoint(4, 4);
bicons.push(bsicon);
bsicon = new GIcon(bicon);
bsicon.iconSize = new GSize(12, 12);
bsicon.iconAnchor = new GPoint(6, 6);
bicons.push(bsicon);
bicons.push(bicon);
function Bullet() {
this.type;
this.deg;
this.speed;
this.cnt;
this.climbRatio;
this.iconIdx;
this.exists = false;
this.marker = new GMarker(
new GPoint(mapManager.centerX, mapManager.centerY), bicon);
this.set = function(type, x, y, d, sp) {
this.type = type;
this.marker.point.x = x;
this.marker.point.y = y;
this.deg = d;
this.speed = sp;
this.cnt = 0;
this.climbRatio = 1;
this.iconIdx = 0;
this.exists = true;
map.addOverlay(this.marker);
this.marker.remove();
this.marker.icon = bicons[this.iconIdx];
this.marker.initialize(map);
}
this.setClimbed = function(type, x, y, d, sp) {
this.set(type, x, y, d, sp);
this.climbRatio = 0;
this.marker.remove();
this.marker.icon = bicons[3];
this.marker.initialize(map);
}
this.update = function() {
if (!this.exists)
return;
if (this.climbRatio > 0) {
this.marker.point.x += Math.sin(this.deg) * this.speed * this.climbRatio;
this.marker.point.y += Math.cos(this.deg) * this.speed * this.climbRatio;
this.marker.point.y += this.climbRatio * 0.00004;
this.climbRatio -= 0.05;
var ii = Math.floor((1 - this.climbRatio) / 0.33);
if (ii > this.iconIdx) {
this.iconIdx = ii;
this.marker.remove();
this.marker.icon = bicons[this.iconIdx];
this.marker.initialize(map);
}
if (this.climbRatio <= 0) {
var d = Math.atan2(ship.marker.point.x - this.marker.point.x,
ship.marker.point.y - this.marker.point.y);
switch (this.type) {
case BULLET_TYPE_AIM:
this.deg = d;
break;
case BULLET_TYPE_SHOTGUN:
for (var i = 0; i < 5; i++) {
var b;
b = getBulletInstance();
if (b == null)
break;
b.setClimbed(0, this.marker.point.x, this.marker.point.y,
d + Math.random() * 0.3 - 0.15,
this.speed * (1 + Math.random() * 0.6 - 0.3));
}
this.deg = d;
break;
case BULLET_TYPE_3WAY:
var ds = d - 0.4;
for (var i = 0; i < 2; i++) {
var b;
b = getBulletInstance();
if (b == null)
break;
b.setClimbed(0, this.marker.point.x, this.marker.point.y,
ds, this.speed);
ds += 0.8;
}
this.deg = d;
break;
case BULLET_TYPE_5WAY:
var ds = d - 0.6 - 0.3;
for (var i = 0; i < 5; i++) {
ds += 0.3;
if (i == 2)
continue;
var b;
b = getBulletInstance();
if (b == null)
break;
b.setClimbed(0, this.marker.point.x, this.marker.point.y,
ds, this.speed);
}
this.deg = d;
break;
}
}
} else {
this.marker.point.x += Math.sin(this.deg) * this.speed;
this.marker.point.y += Math.cos(this.deg) * this.speed;
ship.checkHit(this.marker.point);
}
this.marker.point.x += mapManager.velX;
this.marker.point.y += mapManager.velY;
if (this.marker.point.x < mapManager.bounds.minX ||
this.marker.point.x > mapManager.bounds.maxX ||
this.marker.point.y < mapManager.bounds.minY ||
this.marker.point.y > mapManager.bounds.maxY) {
this.exists = false;
map.removeOverlay(this.marker);
return;
}
this.cnt++;
this.marker.redraw(true);
}
}