|
|
|
@ -25,18 +25,16 @@ public class Tank extends GameObject {
|
|
|
|
|
//public TankFrame tankFrame = null;
|
|
|
|
|
private Random random = new Random();
|
|
|
|
|
public Group group = Group.BAD;
|
|
|
|
|
public GameModel gm;
|
|
|
|
|
public Rectangle rectangle = new Rectangle();
|
|
|
|
|
int oldX, oldY;
|
|
|
|
|
public String uuid;
|
|
|
|
|
|
|
|
|
|
public Tank(int x, int y, Dir dir, Group group, GameModel gm) {
|
|
|
|
|
public Tank(int x, int y, Dir dir, Group group) {
|
|
|
|
|
super();
|
|
|
|
|
this.x = x;
|
|
|
|
|
this.y = y;
|
|
|
|
|
this.dir = dir;
|
|
|
|
|
this.group = group;
|
|
|
|
|
this.gm = gm;
|
|
|
|
|
this.oldY = y;
|
|
|
|
|
this.oldX = x;
|
|
|
|
|
this.uuid = UUID.randomUUID().toString();
|
|
|
|
@ -45,6 +43,7 @@ public class Tank extends GameObject {
|
|
|
|
|
rectangle.y = y;
|
|
|
|
|
rectangle.width = Tank.tankWidth;
|
|
|
|
|
rectangle.height = Tank.tankHeight;
|
|
|
|
|
GameModel.INSTANCE.add(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -81,7 +80,7 @@ public class Tank extends GameObject {
|
|
|
|
|
System.out.println("tank paint:" + this.toString());
|
|
|
|
|
if (!living) {
|
|
|
|
|
System.out.println("tank remove:" + this.toString());
|
|
|
|
|
gm.remove(this);
|
|
|
|
|
GameModel.INSTANCE.remove(this);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
switch (this.dir) {
|
|
|
|
@ -161,20 +160,20 @@ public class Tank extends GameObject {
|
|
|
|
|
int by = y + Tank.tankHeight / 2 - ImageManger.bulletD.getHeight() / 2;
|
|
|
|
|
switch (dir) {
|
|
|
|
|
case DOWN:
|
|
|
|
|
new Bullet(bx, by + 6, this.dir, this.getGroup(), this.gm);
|
|
|
|
|
new Bullet(bx, by - 6, this.dir, this.getGroup(), this.gm);
|
|
|
|
|
new Bullet(bx, by + 6, this.dir, this.getGroup());
|
|
|
|
|
new Bullet(bx, by - 6, this.dir, this.getGroup());
|
|
|
|
|
break;
|
|
|
|
|
case UP:
|
|
|
|
|
new Bullet(bx + 1, by + 6, this.dir, this.getGroup(), this.gm);
|
|
|
|
|
new Bullet(bx + 1, by - 6, this.dir, this.getGroup(), this.gm);
|
|
|
|
|
new Bullet(bx + 1, by + 6, this.dir, this.getGroup());
|
|
|
|
|
new Bullet(bx + 1, by - 6, this.dir, this.getGroup());
|
|
|
|
|
break;
|
|
|
|
|
case LEFT:
|
|
|
|
|
new Bullet(bx + 6, by, this.dir, this.getGroup(), this.gm);
|
|
|
|
|
new Bullet(bx - 6, by, this.dir, this.getGroup(), this.gm);
|
|
|
|
|
new Bullet(bx + 6, by, this.dir, this.getGroup());
|
|
|
|
|
new Bullet(bx - 6, by, this.dir, this.getGroup());
|
|
|
|
|
break;
|
|
|
|
|
case RIGHT:
|
|
|
|
|
new Bullet(bx + 6, by + 1, this.dir, this.getGroup(), this.gm);
|
|
|
|
|
new Bullet(bx - 6, by + 1, this.dir, this.getGroup(), this.gm);
|
|
|
|
|
new Bullet(bx + 6, by + 1, this.dir, this.getGroup());
|
|
|
|
|
new Bullet(bx - 6, by + 1, this.dir, this.getGroup());
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|