Package model.entities
Class EntityModel
java.lang.Object
model.entities.EntityModel
- Direct Known Subclasses:
BubbleModel,EnemyModel,MenuTwinkleBubble,PlayerModel,ProjectileModel,WaterFlowModel
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
FieldsModifier and TypeFieldDescriptionprotected booleanprotected intprotected Rectangle2D.Floatprotected booleanprotected LevelManagerModelprotected final PlayingTimerprotected intprotected floatprotected float -
Constructor Summary
ConstructorsConstructorDescriptionEntityModel(float x, float y, int width, int height) Constructs a new EntityModel with the specified position and dimensions. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidconpenetrationSafeUpdateXPos(float xMovement) Safely updates the x-coordinate position of the entity by the specified movement amount, ensuring no penetration through walls.voidDeactivates the entity.Returns the hitbox of the entity.intgetTileX()Returns the x-coordinate tile position of the entity.intgetTileY()Returns the y-coordinate tile position of the entity.protected voidinitHitbox(float width, float height) Initializes the hitbox for the entity with the specified dimensions.protected voidInitializes the level manager, if null.booleanisActive()Returns the active status of the entity.booleanisImmune()Returns the immune status of the entity.voidsetActive(boolean active) Sets the active status of the entity.protected voidupdateXPos(float xMovement) Updates the x-coordinate position of the entity by the specified movement amount.
-
Field Details
-
timer
-
levelManagerModel
-
x
protected float x -
y
protected float y -
width
protected int width -
height
protected int height -
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 entityy- the y-coordinate of the entitywidth- the width of the entityheight- 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 hitboxheight- 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
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.
-