Esempio n. 1
0
 public void phase2() {
   System.out.println("Phase 2");
   lblStatus1.setText("SR Phase");
   lblStatus2.setText("Resolving slow actions...");
   lblStatus3.setText("");
   ListIterator iList = listAT.listIterator();
   while (iList.hasNext()) {
     GameAction oAction = (GameAction) iList.next();
     if (oAction.isReady()) {
       oAction.fire();
       iList.remove();
     }
   }
   phase3();
 }
 // Checks which input occurs
 public void checkSystemInput() {
   if (exit.isPressed()) {
     System.exit(0);
   }
 }
Esempio n. 3
0
  public void updateWorld(long elapsedTime) {

    float angleVelocity;

    Player player = (Player) gameObjectManager.getPlayer();
    MovingTransform3D playerTransform = player.getTransform();
    Vector3D velocity = playerTransform.getVelocity();

    // playerTransform.stop();
    velocity.x = 0;
    velocity.z = 0;
    float x = -playerTransform.getSinAngleY();
    float z = -playerTransform.getCosAngleY();
    if (goForward.isPressed()) {
      velocity.add(x * PLAYER_SPEED, 0, z * PLAYER_SPEED);
    }
    if (goBackward.isPressed()) {
      velocity.add(-x * PLAYER_SPEED, 0, -z * PLAYER_SPEED);
    }
    if (goLeft.isPressed()) {
      velocity.add(z * PLAYER_SPEED, 0, -x * PLAYER_SPEED);
    }
    if (goRight.isPressed()) {
      velocity.add(-z * PLAYER_SPEED, 0, x * PLAYER_SPEED);
    }
    if (jump.isPressed()) {
      player.setJumping(true);
    }
    if (fire.isPressed()) {
      player.fireProjectile();
    }

    playerTransform.setVelocity(velocity);

    // look up/down (rotate around x)
    angleVelocity = Math.min(tiltUp.getAmount(), 200);
    angleVelocity += Math.max(-tiltDown.getAmount(), -200);
    playerTransform.setAngleVelocityX(angleVelocity * PLAYER_TURN_SPEED / 200);

    // turn (rotate around y)
    angleVelocity = Math.min(turnLeft.getAmount(), 200);
    angleVelocity += Math.max(-turnRight.getAmount(), -200);
    playerTransform.setAngleVelocityY(angleVelocity * PLAYER_TURN_SPEED / 200);

    // update objects
    gameObjectManager.update(elapsedTime);

    // limit look up/down
    float angleX = playerTransform.getAngleX();
    float limit = (float) Math.PI / 2;
    if (angleX < -limit) {
      playerTransform.setAngleX(-limit);
    } else if (angleX > limit) {
      playerTransform.setAngleX(limit);
    }

    // set the camera to be 100 units above the player
    Transform3D camera = polygonRenderer.getCamera();
    camera.setTo(playerTransform);
    camera.getLocation().add(0, CAMERA_HEIGHT, 0);
  }