Ejemplo n.º 1
0
  @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;
      }
    }
  }
Ejemplo n.º 2
0
 @Override
 public void setPosition(Vector2 value) {
   super.setPosition(value);
   bounds.setCenter(value);
 }