Class Player
java.lang.Object
fr.paris.saclay.sidescroller.drawables.Drawable
fr.paris.saclay.sidescroller.drawables.entities.Entity
fr.paris.saclay.sidescroller.drawables.entities.Player
Player entity.
-
Field Summary
Fields inherited from class fr.paris.saclay.sidescroller.drawables.entities.Entity
animationMap, attackHitBox, attackHitboxSize, blockHitBox, blockHitboxSize, hitBox, hitboxSize, image, invincibilityTimer, isAttacking, isBlocking, isDead, isInvincible, isJumping, lifePoints, maximumInvincibility, maximumLifePoints, spriteCounter, spriteNumber
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
attack()
Handles attack action.
Player cannot attack during jumping, attacking, when recovering and recovered stamina is equal to 25 or when is not recovering and stamina is not 0.void
block()
Handles block action.
Player cannot block during jumping, attacking, if it's already blocking or when currentStamina reaches 0.void
Handles the block release by setting isBlocking to false and changing to walking animation.void
draw
(Graphics2D graphics2D) Draws the player sprite based on the current action.int
Gets current stamina.void
setCurrentStamina
(int currentStamina) Sets current stamina.void
update()
Defines actions for each frame and handles sprite changes.Methods inherited from class fr.paris.saclay.sidescroller.drawables.entities.Entity
chasePlayer, drawHpBar, getAttackHitBox, getBlockHitBox, getHitBox, getLifePoints, getMaximumInvincibility, getMaximumLifePoints, isAttacking, isBlocking, isDead, isInvincible, isJumping, setAttacking, setAttackSprites, setBlockSprites, setDead, setEntityInvincible, setJumpSprites, setSprites, tookDamage, uniqueMovement, updateHitboxPosition, updateSprites
Methods inherited from class fr.paris.saclay.sidescroller.drawables.Drawable
getXPosition, updatePositionToCamera
-
Constructor Details
-
Player
Creates a Player instance, saves the GamePanel reference and sets the theme (avatar related to the selection of the initial menu).- Parameters:
gamePanel
- GamePanel reference.theme
- theme types: pink, blue, yellow, green (each one related to a different avatar).
-
-
Method Details
-
update
public void update()Defines actions for each frame and handles sprite changes. -
draw
Draws the player sprite based on the current action. -
attack
public void attack()Handles attack action.
Player cannot attack during jumping, attacking, when recovering and recovered stamina is equal to 25 or when is not recovering and stamina is not 0. -
block
public void block()Handles block action.
Player cannot block during jumping, attacking, if it's already blocking or when currentStamina reaches 0. -
blockRelease
public void blockRelease()Handles the block release by setting isBlocking to false and changing to walking animation. -
getCurrentStamina
public int getCurrentStamina()Gets current stamina.- Returns:
- the current stamina
-
setCurrentStamina
public void setCurrentStamina(int currentStamina) Sets current stamina.- Parameters:
currentStamina
- the current stamina
-