Ejemplo n.º 1
0
 @Override
 public void keyPressed(KeyEvent e) {
   switch (e.getKeyCode()) {
     case KeyEvent.VK_ESCAPE:
       timer.stop();
       game.showMenu();
     case THRUSTER_P1:
       facade.setThrusterActive(player1, true);
       break;
     case LEFT_P1:
       player1_angle = Math.PI / 20;
       break;
     case RIGHT_P1:
       player1_angle = -Math.PI / 20;
       break;
     case FIRE_P1:
       player1_fire = true;
       break;
     case THRUSTER_P2:
       if (player2 != null) facade.setThrusterActive(player2, true);
       break;
     case LEFT_P2:
       if (player2 != null) player2_angle = Math.PI / 20;
       break;
     case RIGHT_P2:
       if (player2 != null) player2_angle = -Math.PI / 20;
       break;
     case FIRE_P2:
       if (player2 != null) player2_fire = true;
       break;
   }
 }
Ejemplo n.º 2
0
 @Override
 public void keyReleased(KeyEvent e) {
   switch (e.getKeyCode()) {
     case THRUSTER_P1:
       facade.setThrusterActive(player1, false);
       break;
     case LEFT_P1:
       player1_angle = 0;
       break;
     case RIGHT_P1:
       player1_angle = 0;
       break;
     case THRUSTER_P2:
       if (player2 != null) facade.setThrusterActive(player2, false);
       break;
     case LEFT_P2:
       if (player2 != null) player2_angle = 0;
       break;
     case RIGHT_P2:
       if (player2 != null) player2_angle = 0;
       break;
   }
 }