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