Ejemplo n.º 1
0
  @Override
  public void keyPressed(KeyEvent e) {

    switch (e.getKeyCode()) {
      case KeyEvent.VK_UP:
        System.out.println("Move up");
        break;

      case KeyEvent.VK_DOWN:
        currentSprite = characterDown;
        if (robot.isJumped() == false) {
          robot.setDucked(true);
          robot.setSpeedX(0);
        }
        break;

      case KeyEvent.VK_LEFT:
        robot.moveLeft();
        robot.setMovingLeft(true);
        break;

      case KeyEvent.VK_RIGHT:
        robot.moveRight();
        robot.setMovingRight(true);
        break;

      case KeyEvent.VK_SPACE:
        robot.jump();
        break;

      case KeyEvent.VK_CONTROL:
        if (robot.isDucked() == false && robot.isJumped() == false) {
          robot.shoot();
          robot.setReadyToFire(false);
        }
        break;
    }
  }
Ejemplo n.º 2
0
  @Override
  public void keyPressed(KeyEvent e) {

    switch (e.getKeyCode()) {
      case KeyEvent.VK_UP:
        robot.moveUp();
        // robot.setMovingUp(true);
        break;

      case KeyEvent.VK_DOWN:
        robot.moveDown();
        // robot.setMovingDown(true);
        break;

      case KeyEvent.VK_LEFT:
        myBasket.moveLeft();

        break;

      case KeyEvent.VK_RIGHT:
        myBasket.moveRight();

        break;

        /* case KeyEvent.VK_SPACE:
        robot.jump();
        break;*/

      case KeyEvent.VK_CONTROL:
        if (robot.isReadyToFire()) {
          robot.shoot();
          robot.setReadyToFire(false);
        }
        break;
    }
  }