示例#1
0
  public void keyPressed(KeyEvent e) {

    System.out.println("Pressed: " + e.getKeyCode());
    direction.setKeyPressed(e.getKeyCode(), true);

    if (isMoving == false) {
      characterAssocié.setMoving(true);
      isMoving = true;
    }
    if (direction.isHeJumping()) {
      characterAssocié.setFalling(true);
      characterAssocié.jump(400);
    }
    if (direction.isToTheLeft()) characterAssocié.setVitesseHorizontal(300);
    else if (direction.isToTheRight()) characterAssocié.setVitesseHorizontal(-300);
    if (direction.isClimbing()) {
      characterAssocié.setFalling(true);
      characterAssocié.setVitesseVertical(-200);
    }

    if (direction.isPressedDown()) characterAssocié.setVitesseVertical(200);

    if (e.getKeyCode() == KeyEvent.VK_ENTER) {
      characterAssocié.setPositionX(300);
      characterAssocié.setPositionY(300);
      characterAssocié.setFalling(false);
      characterAssocié.setMoving(false);
    }
  }
示例#2
0
 public void keyReleased(KeyEvent e) {
   System.out.println("Released" + e.getKeyCode());
   direction.setKeyPressed(e.getKeyCode(), false);
   if (direction.isAllArrowReleased()) {
     characterAssocié.setMoving(false);
     isMoving = false;
   }
 }