Class PlayerActions

java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.components.player.PlayerActions

public class PlayerActions extends Component
Component that handles all player actions including movement, jumping, sprinting, dashing, crouching, attacking, and shooting.

Events related to the player should be initialized in create(), and corresponding actions are triggered when these events occur.

  • Constructor Details

    • PlayerActions

      public PlayerActions()
  • Method Details

    • create

      public void create()
      Initializes the component by setting required components and registering event listeners for all player actions.
      Overrides:
      create in class Component
    • update

      public void update()
      Updates player movement, speed, and grounded status. Called once per frame.
      Overrides:
      update in class Component
    • infDash

      public void infDash()
      Cheat: infinite dashes.
    • infJumps

      public void infJumps()
      Cheat: infinite jumps.
    • infStamina

      public void infStamina()
      Cheat: infinite stamina.
    • getCurrentWeaponStats

      public WeaponsStatsComponent getCurrentWeaponStats()
    • upgradeSpeed

      public void upgradeSpeed()
      Upgrades the speed of the player
    • getMaxSpeed

      public com.badlogic.gdx.math.Vector2 getMaxSpeed()
      Returns:
      the max speed vector
    • getCrouchSpeed

      public com.badlogic.gdx.math.Vector2 getCrouchSpeed()
      Returns:
      the crouch speed
    • getSprintSpeed

      public com.badlogic.gdx.math.Vector2 getSprintSpeed()
      Returns:
      the sprint speed
    • equipWeapon

      public void equipWeapon(Entity weapon)
    • unequipWeapon

      public void unequipWeapon()
      ensures that no weapon is equipped and weapon’s texture (sprite) is no longer visible in the game.
    • updateWeaponPosition

      public void updateWeaponPosition()
      this function sets the coordinates for the weapon in player's hand
    • setTimeSinceLastAttack

      public void setTimeSinceLastAttack(float timeSinceLastAttack)
      Sets time since last attack, used for testing
      Parameters:
      timeSinceLastAttack - time since last attack
    • setCamera

      public void setCamera(com.badlogic.gdx.graphics.Camera camera)
      Sets the camera, used for testing
      Parameters:
      camera - camera