Class PlayerActions
java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.components.player.PlayerActions
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.
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
create()
Initializes the component by setting required components and registering event listeners for all player actions.void
equipWeapon
(Entity weapon) com.badlogic.gdx.math.Vector2
com.badlogic.gdx.math.Vector2
com.badlogic.gdx.math.Vector2
void
infDash()
Cheat: infinite dashes.void
infJumps()
Cheat: infinite jumps.void
Cheat: infinite stamina.void
setCamera
(com.badlogic.gdx.graphics.Camera camera) Sets the camera, used for testingvoid
setTimeSinceLastAttack
(float timeSinceLastAttack) Sets time since last attack, used for testingvoid
ensures that no weapon is equipped and weapon’s texture (sprite) is no longer visible in the game.void
update()
Updates player movement, speed, and grounded status.void
this function sets the coordinates for the weapon in player's handvoid
Upgrades the speed of the playerMethods inherited from class com.csse3200.game.components.Component
dispose, earlyUpdate, getEntity, getPrio, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate
-
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. -
update
public void update()Updates player movement, speed, and grounded status. Called once per frame. -
infDash
public void infDash()Cheat: infinite dashes. -
infJumps
public void infJumps()Cheat: infinite jumps. -
infStamina
public void infStamina()Cheat: infinite stamina. -
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
-
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
-