坦克大战(一期)-设计模式-添加4块墙

DesignPatterns
bingor 2 years ago
parent ef41cce8ed
commit 761d0c5c75

@ -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) {

@ -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() {

Loading…
Cancel
Save