Package model.bubbles.specialBubbles
Class BubbleGenerator
java.lang.Object
model.bubbles.specialBubbles.BubbleGenerator
Generates special bubbles at specified intervals.
This class is responsible for generating special bubbles (e.g., water bubbles, lightning bubbles) at regular intervals. It uses a timer to control the spawn rate and determines the position and direction of the bubbles based on the generator type and position.
-
Constructor Summary
ConstructorsConstructorDescriptionBubbleGenerator(Constants.BubbleGenerator.GeneratorType generatorType, Constants.BubbleGenerator.GeneratorPosition generatorPosition) Constructs a new BubbleGenerator. -
Method Summary
Modifier and TypeMethodDescriptionvoidChecks if a new bubble should be spawned.voidSpawns a new bubble.voidupdate()Updates the state of the bubble generator.voidUpdates the spawn timer.
-
Constructor Details
-
BubbleGenerator
public BubbleGenerator(Constants.BubbleGenerator.GeneratorType generatorType, Constants.BubbleGenerator.GeneratorPosition generatorPosition) Constructs a new BubbleGenerator.- Parameters:
generatorType- the type of bubbles to generategeneratorPosition- the position of the generator (top or bottom)
-
-
Method Details
-
update
public void update()Updates the state of the bubble generator.This method updates the timers and checks if a new bubble should be spawned.
-
updateTimers
public void updateTimers()Updates the spawn timer.This method decreases the spawn timer based on the elapsed time.
-
checkBubbleSpawn
public void checkBubbleSpawn()Checks if a new bubble should be spawned.If the spawn timer has elapsed and the number of active special bubbles is below the maximum limit, a new bubble is spawned.
-
spawnBubble
public void spawnBubble()Spawns a new bubble.This method calculates the position and direction of the new bubble and adds it to the special bubble manager.
-