|
|
|
@ -62,55 +62,64 @@ public class Tank {
|
|
|
|
|
return moving;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setMoving(boolean moving) {
|
|
|
|
|
this.moving = moving;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setDir(Dir dir) {
|
|
|
|
|
this.dir = dir;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void paint(Graphics g) {
|
|
|
|
|
if (!living) tf.tanks.remove(this);
|
|
|
|
|
private void move() {
|
|
|
|
|
if (!moving) return;
|
|
|
|
|
switch (dir) {
|
|
|
|
|
case LEFT:
|
|
|
|
|
g.drawImage(ResourceMgr.tankL, x, y, null);
|
|
|
|
|
x -= SPEED;
|
|
|
|
|
break;
|
|
|
|
|
case UP:
|
|
|
|
|
g.drawImage(ResourceMgr.tankU, x, y, null);
|
|
|
|
|
y -= SPEED;
|
|
|
|
|
break;
|
|
|
|
|
case RIGHT:
|
|
|
|
|
g.drawImage(ResourceMgr.tankR, x, y, null);
|
|
|
|
|
x += SPEED;
|
|
|
|
|
break;
|
|
|
|
|
case DOWN:
|
|
|
|
|
g.drawImage(ResourceMgr.tankD, x, y, null);
|
|
|
|
|
y += SPEED;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
move();
|
|
|
|
|
|
|
|
|
|
if (random.nextInt(10) > 5) this.fire();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void move() {
|
|
|
|
|
if (!moving) return;
|
|
|
|
|
public void paint(Graphics g) {
|
|
|
|
|
if (!living) tf.tanks.remove(this);
|
|
|
|
|
switch (dir) {
|
|
|
|
|
case LEFT:
|
|
|
|
|
x -= SPEED;
|
|
|
|
|
g.drawImage(ResourceMgr.tankL, x, y, null);
|
|
|
|
|
break;
|
|
|
|
|
case UP:
|
|
|
|
|
y -= SPEED;
|
|
|
|
|
g.drawImage(ResourceMgr.tankU, x, y, null);
|
|
|
|
|
break;
|
|
|
|
|
case RIGHT:
|
|
|
|
|
x += SPEED;
|
|
|
|
|
g.drawImage(ResourceMgr.tankR, x, y, null);
|
|
|
|
|
break;
|
|
|
|
|
case DOWN:
|
|
|
|
|
y += SPEED;
|
|
|
|
|
g.drawImage(ResourceMgr.tankD, x, y, null);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
move();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (random.nextInt(10) > 5) this.fire();
|
|
|
|
|
|
|
|
|
|
public void setMoving(boolean moving) {
|
|
|
|
|
this.moving = moving;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setDir(Dir dir) {
|
|
|
|
|
this.dir = dir;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setX(int x) {
|
|
|
|
|
this.x = x;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setY(int y) {
|
|
|
|
|
this.y = y;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void die() {
|
|
|
|
|