|
|
@ -29,6 +29,7 @@ public class TankFrame extends Frame {
|
|
|
|
setSize(GAME_WIDTH, GAME_HEIGHT);
|
|
|
|
setSize(GAME_WIDTH, GAME_HEIGHT);
|
|
|
|
setResizable(true);
|
|
|
|
setResizable(true);
|
|
|
|
setVisible(true);
|
|
|
|
setVisible(true);
|
|
|
|
|
|
|
|
setBackground(Color.BLACK);
|
|
|
|
|
|
|
|
|
|
|
|
addWindowListener(new WindowAdapter() {
|
|
|
|
addWindowListener(new WindowAdapter() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
@ -46,7 +47,7 @@ public class TankFrame extends Frame {
|
|
|
|
public void paint(Graphics g) {
|
|
|
|
public void paint(Graphics g) {
|
|
|
|
// super.paint(g);
|
|
|
|
// super.paint(g);
|
|
|
|
Color color = g.getColor();
|
|
|
|
Color color = g.getColor();
|
|
|
|
g.setColor(Color.BLACK);
|
|
|
|
g.setColor(Color.WHITE);
|
|
|
|
g.drawString("子弹的数量:" + bullets.size(), 10, 60);
|
|
|
|
g.drawString("子弹的数量:" + bullets.size(), 10, 60);
|
|
|
|
g.setColor(color);
|
|
|
|
g.setColor(color);
|
|
|
|
tank.paint(g);
|
|
|
|
tank.paint(g);
|
|
|
@ -65,7 +66,7 @@ public class TankFrame extends Frame {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Graphics gOffScreen = offScreenImage.getGraphics();
|
|
|
|
Graphics gOffScreen = offScreenImage.getGraphics();
|
|
|
|
Color color = gOffScreen.getColor();
|
|
|
|
Color color = gOffScreen.getColor();
|
|
|
|
gOffScreen.setColor(Color.WHITE);
|
|
|
|
gOffScreen.setColor(Color.BLACK);
|
|
|
|
gOffScreen.fillRect(0, 0, GAME_WIDTH, GAME_HEIGHT);
|
|
|
|
gOffScreen.fillRect(0, 0, GAME_WIDTH, GAME_HEIGHT);
|
|
|
|
gOffScreen.setColor(color);
|
|
|
|
gOffScreen.setColor(color);
|
|
|
|
paint(gOffScreen);
|
|
|
|
paint(gOffScreen);
|
|
|
|