1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
2):监听键盘按下 3):监听键盘抬起 */ public class Tank { private static final int SPEED = 5; // 坦克的速度 private int x, y; //坦克的初始位置 private Direction direction; // 坦克的方向
public Tank(int x, int y, Direction direction){ this.x = x; this.y = y; this.direction = direction; }
// 1):得到窗口传递的画笔,绘制自己 public void paint (Graphics g) { g.drawImage(ImagesResource.goodTankD, x, y, null); }
// 2):监听键盘按下 public void keyPressed(KeyEvent e) {
} // 3):监听键盘抬起 public void keyReleased(KeyEvent e) {
} }
|