Class WaterFlowModel
This class extends the EntityModel and provides specific behavior for water flows.
Water flows move in a random horizontal direction and interact with players, enemies, bubbles, and items.
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintflipW()Calculates the width flip value for rendering the water flow.intflipX()Calculates the x-coordinate flip value for rendering the water flow.booleanbooleanbooleanvoidUpdates the timers for the water flow.voidupdate()Updates the state and position of the water flow.voidupdateCollisions(PlayerModel playerModel) Updates the collisions for the water flow.Methods inherited from class model.entities.EntityModel
conpenetrationSafeUpdateXPos, deactivate, getHitbox, getTileX, getTileY, initHitbox, initLevelManager, isActive, isImmune, setActive, updateXPos
-
Constructor Details
-
WaterFlowModel
public WaterFlowModel(float x, float y) Constructs a new WaterFlowModel.- Parameters:
x- the starting x coordinatey- the starting y coordinate
-
-
Method Details
-
update
public void update()Updates the state and position of the water flow.This method handles the first update, updates timers, moves the water flow, updates water drop positions, and checks if the water flow is out of the screen.
-
timersUpdate
public void timersUpdate()Updates the timers for the water flow.This method decreases the water drop timer based on the elapsed time. It also updates the transparency timer to toggle the transparency state of the water flow at specified intervals.
-
updateCollisions
Updates the collisions for the water flow.This method checks for collisions with the player, enemies. If the water flow captures the player, it also checks for collisions with bubbles and items.
- Parameters:
playerModel- the player model to check for collisions with the player
-
flipX
public int flipX()Calculates the x-coordinate flip value for rendering the water flow.This method determines the direction in which the water flow should be flipped based on its current direction. If the direction is UP or DOWN, it uses the previous direction. If the direction is RIGHT, it returns 0; otherwise, it returns the width of the water flow.
- Returns:
- the x-coordinate flip value for rendering
-
flipW
public int flipW()Calculates the width flip value for rendering the water flow.This method determines the direction in which the water flow should be flipped based on its current direction. If the direction is UP or DOWN, it uses the previous direction. If the direction is RIGHT, it returns 1; otherwise, it returns -1.
- Returns:
- the width flip value for rendering
-
getIsTransparent
public boolean getIsTransparent() -
getLastPositions
-
isPlayerCaptured
public boolean isPlayerCaptured() -
isPlaySoundActive
public boolean isPlaySoundActive()
-