Create onready variables for access
to the AudioStreamPlayer and
Preload three pop sound files into an array.
preload loads them into memory immediately, which is faster during gameplay.
This variable keeps track of how many pops are left to play.
_ready() is called when the scene is loaded.
randomize() initializes the random number generator so that results aren’t always the same each time the game runs.
Create the fire function to fire the cannon
The fire() function activates the particles from 6 different emitters (Blue, Orange, etc.) by setting their emitting property to true.
Chooses a random number of pops (between 3 to 5) to play and stores it in pops_remaining.
Manually calls the function that plays the first pop immediately, instead of waiting for the timer.
If there are no pops left to play, the function exits early.
Picks a random sound from the pop_sounds list.
Sets that sound as the stream for the pop_player.
Decreases the number of remaining pops by 1.
If there are still pops to play, it starts the timer to call _on_pop_timer_timeout() again after a random short delay (between 0.05 and 0.2 seconds).
Now add the Confetti_Cannon scene as a child of the CheckPoint scene
In the check_point script
Check if the level is complete
and if it is, fire the Confetti_Cannon