Package model.bubbles.specialBubbles
Class SpecialBubbleModel
java.lang.Object
model.entities.EntityModel
model.bubbles.BubbleModel
model.bubbles.specialBubbles.SpecialBubbleModel
- Direct Known Subclasses:
LightningBubbleModel,WaterBubbleModel
Represents a special bubble that is not generated by the player, but are automatically generate by a
BubbleGenerator.
This abstract class extends the BubbleModel and provides the basic structure and behavior for special bubbles. Special bubbles have unique interactions and behaviors when collided with the player.
-
Field Summary
Fields inherited from class model.bubbles.BubbleModel
active, blinkingTimer, bubbleType, direction, externalCollisionBox, internalCollisionBox, levelManagerModel, normalTimer, popped, popTimer, previousDirection, previousState, redTimer, shake, shakeTimer, state, timer, xSpeed, ySpeed -
Constructor Summary
ConstructorsConstructorDescriptionSpecialBubbleModel(float x, float y, Constants.Direction direction) Constructs a new SpecialBubbleModel. -
Method Summary
Modifier and TypeMethodDescriptionvoidcheckCollisionWithPlayer(PlayerModel playerModel) Checks for collisions with the player and handles the interaction.abstract voidplayerPop(PlayerModel playerModel) Handles the player popping the special bubble.abstract voidupdate()Updates the state and position of the special bubble.Methods inherited from class model.bubbles.BubbleModel
bounceDown, bubbleShaking, changeDirection, getBubbleType, getCenter, getDirection, getState, handlePlayerPush, initCollisionBoxes, isActive, isPlayerJumpingOnBubble, isPlayerPoppingBubble, isPlayerTouchingBubble, isPopped, pacManEffect, setActive, updateCollisionBoxes, updateDirection, updatePosition, updateTimersMethods inherited from class model.entities.EntityModel
conpenetrationSafeUpdateXPos, deactivate, getHitbox, getTileX, getTileY, initHitbox, initLevelManager, isImmune, updateXPos
-
Constructor Details
-
SpecialBubbleModel
Constructs a new SpecialBubbleModel.- Parameters:
x- the starting x coordinatey- the starting y coordinatedirection- the starting direction
-
-
Method Details
-
update
public abstract void update()Updates the state and position of the special bubble.- Specified by:
updatein classBubbleModel
-
playerPop
Handles the player popping the special bubble.- Parameters:
playerModel- the player model
-
checkCollisionWithPlayer
Checks for collisions with the player and handles the interaction.If the player is popping the bubble, it calls the
playerPop(PlayerModel)method.If the player is touching the bubble, it handles the interaction based on the player's position and state:
- If the player is jumping on the bubble, the bubble bounces down and the player jumps on the bubble.
- If the player is pushing the bubble, the bubble's position is adjusted based on the player's push direction.
- Specified by:
checkCollisionWithPlayerin classBubbleModel- Parameters:
playerModel- the player model
-