Ball Misses Paddle
When the player misses the ball, it will hit the red wall as set in the tile map -- using the on sprite of kind
Projectile hits wall (red) allows us to take action.
First, we'll shake the camera a bit, then destroy ball with ashes effect for 20 ms.
We'll reduce the player life count by one, play a four tone sound effect, and then flip the ballInPlay
variable to zero.
Paddle Misses Ball
When the player misses the ball, it will hit the red wall as set in
the tile map -- using the on sprite of kind Projectile hits wall
(red) allows us to take action.
First, we'll shake the camera a bit, then destroy ball with
ashes effect for 20 ms.
We'll reduce the player life count by one, play a four tone
sound effect, and then flip the ballInPlay variable to zero.
Ball Hits Bricks
Similarly to the ball hitting the paddle, we use the overlap test to see when the ball ( sprite of kind
Projectile) overlaps a brick (otherSprite of kind Food).
If the ball is traveling upward (vy > 0) we invert the velocity on y and send it back down. The opposite is
true if the ball is traveling downward when it hits a brick, which happens on rebounds off the top of the
board or higher rows of bricks.
Next, we'll destroy otherSprite to get rid of the brick.
The score goes up by 200 points. Yay!
The brickCount variable is reduced by one, so we'll know when the last brick is hit.
A satisfying tone is played for a 1/4 beat.
If the final brick is hit (brickCount < or = 0) then we destroy the ball and paddle, pause a brief moment, and
then reset everything for the next level.
This includes calling the brick setup functions for the rows you want, setting the associated brickCount
value, setting ballInPlay to 0 and finally, playing the BGM music!