From 32b0fa6c521002219f158a42bfeee4a90e8cf4be Mon Sep 17 00:00:00 2001 From: bingor Date: Thu, 13 Oct 2022 18:01:17 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9D=A6=E5=85=8B=E5=A4=A7=E6=88=98=EF=BC=88?= =?UTF-8?q?=E4=B8=80=E6=9C=9F=EF=BC=89-=E8=AE=BE=E8=AE=A1=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F-=E8=A3=85=E9=A5=B0=E8=80=85=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E5=BA=94=E7=94=A8=E5=88=B0=E5=AD=90=E5=BC=B9=E4=B8=8A-?= =?UTF-8?q?=E6=9C=89bug=E7=89=881.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/msb/TankDemo.java | 2 +- src/main/java/com/msb/decorator/RectDecorator.java | 7 +++++-- src/main/java/com/msb/decorator/TailDecorator.java | 7 +++++-- src/main/java/com/msb/inter/impl/FourFireStrategy.java | 2 ++ 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/msb/TankDemo.java b/src/main/java/com/msb/TankDemo.java index 725b1a8..bbe5b64 100644 --- a/src/main/java/com/msb/TankDemo.java +++ b/src/main/java/com/msb/TankDemo.java @@ -13,7 +13,7 @@ public class TankDemo { //现实当中,虽然可以过按键来改变方块的坐标并且重新刷新画板来实现移动,但是敌方的坦克应该是自动在跑 while (true) { // Thread.sleep(50); - Thread.sleep(1000); + Thread.sleep(500); tankFrame.repaint(); } } diff --git a/src/main/java/com/msb/decorator/RectDecorator.java b/src/main/java/com/msb/decorator/RectDecorator.java index 1a02426..113eb7f 100644 --- a/src/main/java/com/msb/decorator/RectDecorator.java +++ b/src/main/java/com/msb/decorator/RectDecorator.java @@ -24,8 +24,10 @@ public class RectDecorator extends GODecoratory { @Override public void paint(Graphics g) { - this.x = gameObject.x; - this.y = gameObject.y; + /*this.x = gameObject.x; + this.y = gameObject.y;*/ + this.x = super.gameObject.x; + this.y = super.gameObject.y; gameObject.paint(g); //原来的样式 //需要装饰的样式 @@ -45,4 +47,5 @@ public class RectDecorator extends GODecoratory { public int getHeight() { return super.gameObject.getHeight(); } + } diff --git a/src/main/java/com/msb/decorator/TailDecorator.java b/src/main/java/com/msb/decorator/TailDecorator.java index c7d3cd2..38f595d 100644 --- a/src/main/java/com/msb/decorator/TailDecorator.java +++ b/src/main/java/com/msb/decorator/TailDecorator.java @@ -24,8 +24,10 @@ public class TailDecorator extends GODecoratory { @Override public void paint(Graphics g) { - this.x = gameObject.x; - this.y = gameObject.y; + /*this.x = gameObject.x; + this.y = gameObject.y;*/ + this.x = super.gameObject.x; + this.y = super.gameObject.y; gameObject.paint(g); //原来的样式 //需要装饰的样式 @@ -46,4 +48,5 @@ public class TailDecorator extends GODecoratory { public int getHeight() { return super.gameObject.getHeight(); } + } diff --git a/src/main/java/com/msb/inter/impl/FourFireStrategy.java b/src/main/java/com/msb/inter/impl/FourFireStrategy.java index 5134847..7a555d3 100644 --- a/src/main/java/com/msb/inter/impl/FourFireStrategy.java +++ b/src/main/java/com/msb/inter/impl/FourFireStrategy.java @@ -6,6 +6,7 @@ package com.msb.inter.impl;/** */ import com.msb.model.Bullet; +import com.msb.model.GameModel; import com.msb.model.Tank; import com.msb.enums.DirEnum; import com.msb.inter.FireStrategy; @@ -25,6 +26,7 @@ public class FourFireStrategy implements FireStrategy { for (DirEnum value : DirEnum.values()) { // new Bullet(bX, bY, value, tank.getGroup(), tank.getGameModel()); new Bullet(bX, bY, value, tank.getGroup()); +// GameModel.INSTANCE.add(new Bullet(bX, bY, value, tank.getGroup())); } } }