Class PlayerActions
java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.components.player.PlayerActions
Action component for interacting with the player. Player events should be initialised in create()
and when triggered should call methods within this class.
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcreate()Called when the entity is created and registered.voidcrouch()Makes the player crouchbooleanbooleanbooleanbooleanbooleanintcom.badlogic.gdx.math.Vector2Returns the player's current walking direction as a 2D vector.floatfloatbooleanbooleanbooleanbooleanisMoving()voidjump()Makes the player jump This method applies an upward impules to the players physics body to initiate a jump.voidonLand()Called when a player lands on a surface This method resets the players jump state, allowing them to jump againvoidsetMoving(boolean moving) voidsetWalkSpeed(int x, int y) voidupdate()Called once per frame of the game, and should be used for most component logic.Methods 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()Description copied from class:ComponentCalled when the entity is created and registered. Initial logic such as calls to GetComponent should be made here, not in the constructor which is called before an entity is finished. -
update
public void update()Description copied from class:ComponentCalled once per frame of the game, and should be used for most component logic. Not called if component is disabled. -
getWalkDirection
public com.badlogic.gdx.math.Vector2 getWalkDirection()Returns the player's current walking direction as a 2D vector. x: +right, -left; y: +up, -down -
jump
public void jump()Makes the player jump This method applies an upward impules to the players physics body to initiate a jump. It handles both single and double jumps - if the player has already used their single and double jump the method returns immediately Before applying the impuse, the players vertical velocity is set to 0 to keep consistent jump heights -
onLand
public void onLand()Called when a player lands on a surface This method resets the players jump state, allowing them to jump again -
crouch
public void crouch()Makes the player crouch -
setMoving
public void setMoving(boolean moving) - Parameters:
moving- weather the entity position will be updated or not
-
isMoving
public boolean isMoving()- Returns:
- returns weather the entity is allowed to move
-
getXDirection
public float getXDirection() -
getYDirection
public float getYDirection() -
getIsJumping
public boolean getIsJumping() -
getIsDoubleJumping
public boolean getIsDoubleJumping() -
getIsCrouching
public boolean getIsCrouching() -
hasSoundPlayed
public boolean hasSoundPlayed() -
hasAdrenaline
public boolean hasAdrenaline() -
hasDashed
public boolean hasDashed() -
getJetpackFuel
public int getJetpackFuel() -
getIsJetpackOn
public boolean getIsJetpackOn() -
getIsGliding
public boolean getIsGliding() -
setWalkSpeed
public void setWalkSpeed(int x, int y)
-