コード例 #1
0
  @Override
  public void keyReleased(KeyEvent e) {
    int key = e.getKeyCode();

    if (key == keySet.UP) player.getTank().up = false;
    if (key == keySet.DOWN) player.getTank().down = false;
    if (key == keySet.LEFT) player.getTank().left = false;
    if (key == keySet.RIGHT) player.getTank().right = false;
  }
コード例 #2
0
  @Override
  public void keyPressed(KeyEvent e) {
    int key = e.getKeyCode();

    if (key == keySet.SHOT) player.getTank().shot();
    if (key == keySet.UP) player.getTank().setOneDirection(true, false, false, false);
    if (key == keySet.DOWN) player.getTank().setOneDirection(false, true, false, false);
    if (key == keySet.LEFT) player.getTank().setOneDirection(false, false, true, false);
    if (key == keySet.RIGHT) player.getTank().setOneDirection(false, false, false, true);
  }