Example #1
0
  public void keyPressed(KeyEvent e) {
    // System.out.println("keyPressed");
    if (focussed) {
      switch (e.getKeyCode()) {
        case KeyEvent.VK_W: // case KeyEvent.VK_W uo:
          pacman.moveUp();
          break;

        case KeyEvent.VK_Z: // case KeyEvent.VK_Z down:
          pacman.moveDown();
          break;

        case KeyEvent.VK_S: // case KeyEvent.VK_S right:
          pacman.moveUp();
          break;

        case KeyEvent.VK_A: // case KeyEvent.VK_A  left:
          pacman.moveUp();
          break;

        case KeyEvent.VK_UP: // case KeyEvent.VK_KP_UP:
          pacman.moveUp();
          break;
        case KeyEvent.VK_DOWN: // case KeyEvent.VK_KP_DOWN:
          pacman.moveDown();
          break;
        case KeyEvent.VK_RIGHT: // case KeyEvent.VK_KP_RIGHT:
          pacman.moveRight();
          break;
        case KeyEvent.VK_LEFT: // case KeyEvent.VK_KP_LEFT:
          pacman.moveLeft();
          break;
      }
    } // end if focussed
  }
Example #2
0
  public void paint(Graphics g) {

    board.drawMaze();
    pacman.drawMazeMan(true);
    pacman.start();
  }