|
|
|
@ -4,7 +4,7 @@ import java.awt.Graphics;
|
|
|
|
|
import java.util.Random;
|
|
|
|
|
|
|
|
|
|
public class Tank {
|
|
|
|
|
private static final int SPEED = 5;
|
|
|
|
|
private static final int SPEED = 1;
|
|
|
|
|
|
|
|
|
|
public static int WIDTH = ResourceMgr.tankD.getWidth();
|
|
|
|
|
public static int HEIGHT = ResourceMgr.tankD.getHeight();
|
|
|
|
@ -15,7 +15,7 @@ public class Tank {
|
|
|
|
|
|
|
|
|
|
private Dir dir = Dir.DOWN;
|
|
|
|
|
|
|
|
|
|
private boolean moving = false;
|
|
|
|
|
private boolean moving = true;
|
|
|
|
|
|
|
|
|
|
private TankFrame tf = null;
|
|
|
|
|
|
|
|
|
@ -23,6 +23,25 @@ public class Tank {
|
|
|
|
|
|
|
|
|
|
private Group group = Group.BAD;
|
|
|
|
|
|
|
|
|
|
public Tank(int x, int y, Dir dir, Group group, TankFrame tf) {
|
|
|
|
|
super();
|
|
|
|
|
this.x = x;
|
|
|
|
|
this.y = y;
|
|
|
|
|
this.dir = dir;
|
|
|
|
|
this.tf = tf;
|
|
|
|
|
this.group = group;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void fire(){
|
|
|
|
|
int bX = this.x + Tank.WIDTH / 2 - Bullet.WIDTH / 2;
|
|
|
|
|
int bY = this.y + Tank.HEIGHT / 2 - Bullet.HEIGHT / 2;
|
|
|
|
|
tf.bullets.add(new Bullet(bX, bY, this.dir, this.group, this.tf));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Dir getDir() {
|
|
|
|
|
return dir;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getX() {
|
|
|
|
|
return x;
|
|
|
|
|
}
|
|
|
|
@ -55,24 +74,10 @@ public class Tank {
|
|
|
|
|
this.moving = moving;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Dir getDir() {
|
|
|
|
|
return dir;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setDir(Dir dir) {
|
|
|
|
|
this.dir = dir;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Tank(int x, int y, Dir dir, Group group, TankFrame tf) {
|
|
|
|
|
super();
|
|
|
|
|
this.x = x;
|
|
|
|
|
this.y = y;
|
|
|
|
|
this.dir = dir;
|
|
|
|
|
this.tf = tf;
|
|
|
|
|
this.group = group;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void paint(Graphics g) {
|
|
|
|
|
if (!living) tf.tanks.remove(this);
|
|
|
|
|
switch (dir) {
|
|
|
|
@ -116,12 +121,6 @@ public class Tank {
|
|
|
|
|
if (random.nextInt(10) > 5) this.fire();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void fire(){
|
|
|
|
|
int bX = this.x + Tank.WIDTH / 2 - Bullet.WIDTH / 2;
|
|
|
|
|
int bY = this.y + Tank.HEIGHT / 2 - Bullet.HEIGHT / 2;
|
|
|
|
|
tf.bullets.add(new Bullet(bX, bY, this.dir, this.group, this.tf));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void die() {
|
|
|
|
|
this.living = false;
|
|
|
|
|
}
|
|
|
|
|