From 761d0c5c75475ea6811bfa7700fd8d2325eb2240 Mon Sep 17 00:00:00 2001 From: bingor Date: Wed, 12 Oct 2022 15:39:00 +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-=E6=B7=BB=E5=8A=A04=E5=9D=97=E5=A2=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/msb/model/GameModel.java | 8 ++++++++ src/main/java/com/msb/model/Wall.java | 5 ++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/msb/model/GameModel.java b/src/main/java/com/msb/model/GameModel.java index 53dc60b..c03bb49 100644 --- a/src/main/java/com/msb/model/GameModel.java +++ b/src/main/java/com/msb/model/GameModel.java @@ -5,6 +5,7 @@ package com.msb.model;/** * @Version: 1.0 */ +import com.msb.TankFrame; import com.msb.base.PropertyMgr; import com.msb.chain.ColliderChain; import com.msb.enums.DirEnum; @@ -59,6 +60,13 @@ public class GameModel { // tankFrame.tanks.add(new Tank(100 + i*80, 100, DirEnum.valueOf(random.nextInt(30)%4), GroupEnum.BAD, tankFrame)); gameObjects.add(new Tank(100 + i*120, 100, DirEnum.DOWN, GroupEnum.BAD)); } + + //上面两块 + add(new Wall(TankFrame.GAME_WIDTH/4*1-200/2, TankFrame.GAME_HEIGHT/4*1-50/2, 200, 50)); + add(new Wall(TankFrame.GAME_WIDTH/4*3-200/2, TankFrame.GAME_HEIGHT/4*1-50/2, 200, 50)); + //下面两块 + add(new Wall(TankFrame.GAME_WIDTH/4*1-50/2, TankFrame.GAME_HEIGHT/4*3-200/2, 50, 200)); + add(new Wall(TankFrame.GAME_WIDTH/4*3-50/2, TankFrame.GAME_HEIGHT/4*3-200/2, 50, 200)); } public void paint(Graphics g) { diff --git a/src/main/java/com/msb/model/Wall.java b/src/main/java/com/msb/model/Wall.java index b72bb8c..e08eb3c 100644 --- a/src/main/java/com/msb/model/Wall.java +++ b/src/main/java/com/msb/model/Wall.java @@ -31,7 +31,10 @@ public class Wall extends GameObject { @Override public void paint(Graphics g) { - GameModel.getInstance().paint(g); + Color color = g.getColor(); + g.setColor(Color.LIGHT_GRAY); + g.fillRect(x, y, width, height); + g.setColor(color); } public int getWidth() {