Exemplo n.º 1
0
 public void toggle(int key, boolean pressed) {
   if (key == KeyEvent.VK_UP) up.toggle(pressed);
   if (key == KeyEvent.VK_DOWN) down.toggle(pressed);
   if (key == KeyEvent.VK_RIGHT) right.toggle(pressed);
   if (key == KeyEvent.VK_LEFT) left.toggle(pressed);
   if (key == KeyEvent.VK_SPACE) space.toggle(pressed);
 }
Exemplo n.º 2
0
 public void toggle(KeyEvent e, boolean pressed) {
   // Movement
   if (e.getKeyCode() == KeyEvent.VK_A || e.getKeyCode() == KeyEvent.VK_LEFT) left.toggle(pressed);
   if (e.getKeyCode() == KeyEvent.VK_D || e.getKeyCode() == KeyEvent.VK_RIGHT)
     right.toggle(pressed);
   if (e.getKeyCode() == KeyEvent.VK_W || e.getKeyCode() == KeyEvent.VK_UP) up.toggle(pressed);
   if (e.getKeyCode() == KeyEvent.VK_S || e.getKeyCode() == KeyEvent.VK_DOWN) down.toggle(pressed);
 }
Exemplo n.º 3
0
 private void toggle(KeyEvent ke, boolean pressed) {
   if (ke.getKeyCode() == KeyEvent.VK_F3) F3.toggle(pressed);
   if (ke.getKeyCode() == KeyEvent.VK_ESCAPE) escape.toggle(pressed);
   if (ke.getKeyCode() == KeyEvent.VK_W) up.toggle(pressed);
   if (ke.getKeyCode() == KeyEvent.VK_S) down.toggle(pressed);
   if (ke.getKeyCode() == KeyEvent.VK_A) left.toggle(pressed);
   if (ke.getKeyCode() == KeyEvent.VK_D) right.toggle(pressed);
   if (ke.getKeyCode() == KeyEvent.VK_UP) up.toggle(pressed);
   if (ke.getKeyCode() == KeyEvent.VK_DOWN) down.toggle(pressed);
   if (ke.getKeyCode() == KeyEvent.VK_LEFT) left.toggle(pressed);
   if (ke.getKeyCode() == KeyEvent.VK_RIGHT) right.toggle(pressed);
 }
Exemplo n.º 4
0
 public void toggleKey(int keyPressed, boolean isPressed) {
   if (keyPressed == KeyEvent.VK_W || keyPressed == KeyEvent.VK_UP) {
     up.toggle(isPressed);
   }
   if (keyPressed == KeyEvent.VK_S || keyPressed == KeyEvent.VK_DOWN) {
     down.toggle(isPressed);
   }
   if (keyPressed == KeyEvent.VK_A || keyPressed == KeyEvent.VK_LEFT) {
     left.toggle(isPressed);
   }
   if (keyPressed == KeyEvent.VK_D || keyPressed == KeyEvent.VK_RIGHT) {
     right.toggle(isPressed);
   }
 }