Class SpecialBubbleModel

java.lang.Object
model.entities.EntityModel
model.bubbles.BubbleModel
model.bubbles.specialBubbles.SpecialBubbleModel
Direct Known Subclasses:
LightningBubbleModel, WaterBubbleModel

public abstract class SpecialBubbleModel extends BubbleModel
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.

  • Constructor Details

    • SpecialBubbleModel

      public SpecialBubbleModel(float x, float y, Constants.Direction direction)
      Constructs a new SpecialBubbleModel.
      Parameters:
      x - the starting x coordinate
      y - the starting y coordinate
      direction - the starting direction
  • Method Details

    • update

      public abstract void update()
      Updates the state and position of the special bubble.
      Specified by:
      update in class BubbleModel
    • playerPop

      public abstract void playerPop(PlayerModel playerModel)
      Handles the player popping the special bubble.
      Parameters:
      playerModel - the player model
    • checkCollisionWithPlayer

      public void checkCollisionWithPlayer(PlayerModel playerModel)
      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:
      checkCollisionWithPlayer in class BubbleModel
      Parameters:
      playerModel - the player model