Class EntityModel

java.lang.Object
model.entities.EntityModel
Direct Known Subclasses:
BubbleModel, EnemyModel, MenuTwinkleBubble, PlayerModel, ProjectileModel, WaterFlowModel

public abstract class EntityModel extends Object
Represents a generic entity in the game.

This abstract class provides common properties and methods for all game entities, such as position, dimensions, hitbox, and movement logic.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected boolean
     
    protected int
     
     
    protected boolean
     
     
    protected final PlayingTimer
     
    protected int
     
    protected float
     
    protected float
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    EntityModel(float x, float y, int width, int height)
    Constructs a new EntityModel with the specified position and dimensions.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    Safely updates the x-coordinate position of the entity by the specified movement amount, ensuring no penetration through walls.
    void
    Deactivates the entity.
    Returns the hitbox of the entity.
    int
    Returns the x-coordinate tile position of the entity.
    int
    Returns the y-coordinate tile position of the entity.
    protected void
    initHitbox(float width, float height)
    Initializes the hitbox for the entity with the specified dimensions.
    protected void
    Initializes the level manager, if null.
    boolean
    Returns the active status of the entity.
    boolean
    Returns the immune status of the entity.
    void
    setActive(boolean active)
    Sets the active status of the entity.
    protected void
    updateXPos(float xMovement)
    Updates the x-coordinate position of the entity by the specified movement amount.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • timer

      protected final PlayingTimer timer
    • levelManagerModel

      protected LevelManagerModel levelManagerModel
    • x

      protected float x
    • y

      protected float y
    • width

      protected int width
    • height

      protected int height
    • hitbox

      protected Rectangle2D.Float hitbox
    • immune

      protected boolean immune
    • active

      protected boolean active
  • Constructor Details

    • EntityModel

      public EntityModel(float x, float y, int width, int height)
      Constructs a new EntityModel with the specified position and dimensions.
      Parameters:
      x - the x-coordinate of the entity
      y - the y-coordinate of the entity
      width - the width of the entity
      height - the height of the entity
  • Method Details

    • initLevelManager

      protected void initLevelManager()
      Initializes the level manager, if null.
    • initHitbox

      protected void initHitbox(float width, float height)
      Initializes the hitbox for the entity with the specified dimensions.
      Parameters:
      width - the width of the hitbox
      height - the height of the hitbox
    • updateXPos

      protected void updateXPos(float xMovement)
      Updates the x-coordinate position of the entity by the specified movement amount.
      Parameters:
      xMovement - the amount to move the entity along the x-axis
    • conpenetrationSafeUpdateXPos

      protected void conpenetrationSafeUpdateXPos(float xMovement)
      Safely updates the x-coordinate position of the entity by the specified movement amount, ensuring no penetration through walls.
      Parameters:
      xMovement - the amount to move the entity along the x-axis
    • getTileX

      public int getTileX()
      Returns the x-coordinate tile position of the entity.
      Returns:
      the x-coordinate tile position
    • getTileY

      public int getTileY()
      Returns the y-coordinate tile position of the entity.
      Returns:
      the y-coordinate tile position
    • getHitbox

      public Rectangle2D.Float getHitbox()
      Returns the hitbox of the entity.
      Returns:
      the hitbox of the entity
    • isImmune

      public boolean isImmune()
      Returns the immune status of the entity.
      Returns:
      true if the entity is immune, false otherwise
    • isActive

      public boolean isActive()
      Returns the active status of the entity.
      Returns:
      true if the entity is active, false otherwise
    • setActive

      public void setActive(boolean active)
      Sets the active status of the entity.
      Parameters:
      active - the new active status to set
    • deactivate

      public void deactivate()
      Deactivates the entity.