|
|
@ -4,6 +4,23 @@ import java.awt.Graphics;
|
|
|
|
|
|
|
|
|
|
|
|
public class Tank {
|
|
|
|
public class Tank {
|
|
|
|
private int x,y;
|
|
|
|
private int x,y;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public int getX() {
|
|
|
|
|
|
|
|
return x;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setX(int x) {
|
|
|
|
|
|
|
|
this.x = x;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public int getY() {
|
|
|
|
|
|
|
|
return y;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setY(int y) {
|
|
|
|
|
|
|
|
this.y = y;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private Dir dir = Dir.DOWN;
|
|
|
|
private Dir dir = Dir.DOWN;
|
|
|
|
private static final int SPEED = 5;
|
|
|
|
private static final int SPEED = 5;
|
|
|
|
|
|
|
|
|
|
|
@ -14,6 +31,8 @@ public class Tank {
|
|
|
|
|
|
|
|
|
|
|
|
private TankFrame tf = null;
|
|
|
|
private TankFrame tf = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private boolean living = true;
|
|
|
|
|
|
|
|
|
|
|
|
public boolean isMoving() {
|
|
|
|
public boolean isMoving() {
|
|
|
|
return moving;
|
|
|
|
return moving;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -41,6 +60,7 @@ public class Tank {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void paint(Graphics g) {
|
|
|
|
public void paint(Graphics g) {
|
|
|
|
|
|
|
|
if (!living) tf.tanks.remove(this);
|
|
|
|
switch (dir) {
|
|
|
|
switch (dir) {
|
|
|
|
case LEFT:
|
|
|
|
case LEFT:
|
|
|
|
g.drawImage(ResourceMgr.tankL, x, y, null);
|
|
|
|
g.drawImage(ResourceMgr.tankL, x, y, null);
|
|
|
@ -85,4 +105,8 @@ public class Tank {
|
|
|
|
int bY = this.y + Tank.HEIGHT / 2 - Bullet.HEIGHT / 2;
|
|
|
|
int bY = this.y + Tank.HEIGHT / 2 - Bullet.HEIGHT / 2;
|
|
|
|
tf.bullets.add(new Bullet(bX, bY, this.dir, this.tf));
|
|
|
|
tf.bullets.add(new Bullet(bX, bY, this.dir, this.tf));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void die() {
|
|
|
|
|
|
|
|
this.living = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|