Exemple #1
0
 @Override
 public void keyPressed(KeyEvent event) {
   char key = event.getKeyChar();
   if (key == 'k') {
     player.move(0, playerspeed);
   } else if (key == 'i') {
     player.move(0, -playerspeed);
   }
 }
 public void keyPressed(KeyEvent e) {
   int key = e.getKeyCode();
   if (key == KeyEvent.VK_UP) {
     yMove = -MV_AMT;
     xMove = 0;
   } else if (key == KeyEvent.VK_RIGHT) {
     xMove = MV_AMT;
     yMove = 0;
   } else if (key == KeyEvent.VK_DOWN) {
     yMove = MV_AMT;
     xMove = 0;
   } else if (key == KeyEvent.VK_LEFT) {
     xMove = -MV_AMT;
     yMove = 0;
   } else if (key == KeyEvent.VK_SPACE) {
     xMove = 0;
     yMove = 0;
   }
 }