public class Player extends Entity
Player entity.
  • Constructor Details

    • Player

      public Player(GamePanel gamePanel, String theme)
      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.
      Overrides:
      update in class Entity
    • draw

      public void draw(Graphics2D graphics2D)
      Draws the player sprite based on the current action.
      Overrides:
      draw in class Entity
      Parameters:
      graphics2D - the rendering environment.
    • 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