|
|
@ -9,6 +9,9 @@ import java.awt.*;
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public class Tank {
|
|
|
|
public class Tank {
|
|
|
|
private static final int SPEED = 5;
|
|
|
|
private static final int SPEED = 5;
|
|
|
|
|
|
|
|
public static int WIDTH = ResourceImageRead.TANK_DOWN.getWidth();
|
|
|
|
|
|
|
|
public static int HEIGHT = ResourceImageRead.TANK_DOWN.getHeight();
|
|
|
|
|
|
|
|
|
|
|
|
private int x;
|
|
|
|
private int x;
|
|
|
|
private int y;
|
|
|
|
private int y;
|
|
|
|
private Direction direction;
|
|
|
|
private Direction direction;
|
|
|
@ -79,8 +82,11 @@ public class Tank {
|
|
|
|
* 解决:坦克对象要持有FrameTank对象的引用
|
|
|
|
* 解决:坦克对象要持有FrameTank对象的引用
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public void fire() {
|
|
|
|
public void fire() {
|
|
|
|
|
|
|
|
int bulletX = this.x + Tank.WIDTH / 2 - Bullet.WIDTH / 2;
|
|
|
|
|
|
|
|
int bulletY = this.y + Tank.HEIGHT / 2 - Bullet.HEIGHT / 2;
|
|
|
|
|
|
|
|
|
|
|
|
// 将子弹加入子弹集合
|
|
|
|
// 将子弹加入子弹集合
|
|
|
|
frameTank.bulletList.add(new Bullet(this.x, this.y, this.direction, this.frameTank));
|
|
|
|
frameTank.bulletList.add(new Bullet(bulletX, bulletY, this.direction, this.frameTank));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Direction getDirection() {
|
|
|
|
public Direction getDirection() {
|
|
|
|