예제 #1
0
파일: Player.java 프로젝트: marshauf/uni
  @Override
  public void update(float deltaTime) {
    // Compute player input direction
    if (cmds.isEmpty() == false) {
      dir.x = 0;
      dir.y = 0;
      if (cmds.contains(Command.MoveUp)) {
        dir.y += 1;
      }
      if (cmds.contains(Command.MoveDown)) {
        dir.y -= 1;
      }
      if (cmds.contains(Command.MoveLeft)) {
        dir.x -= 1;
      }
      if (cmds.contains(Command.MoveRight)) {
        dir.x += 1;
      }
      dir.nor();
      // Set the velocity of the player object to the direction * speed
      // This enables immediate turns
      super.setVelocity(dir.scl(speed));

      super.position.x += velocity.x * deltaTime;
      super.position.y += velocity.y * deltaTime;
      bounds.setCenter(super.position);

      System.out.println(position.toString());
    }

    if (timeLeftOnEmpowered > 0.0f) {
      timeLeftOnEmpowered -= deltaTime;
      if (timeLeftOnEmpowered < 0.0f) {
        timeLeftOnEmpowered = 0.0f;
      }
    }
  }
예제 #2
0
파일: Player.java 프로젝트: marshauf/uni
 @Override
 public void setPosition(Vector2 value) {
   super.setPosition(value);
   bounds.setCenter(value);
 }