We build the blocks

The timer: every 0.05 seconds
As long as the hearts are more than 0: the apple goes down by speed, and the basket moves with the tilt. If the apple reaches the bottom of the canvas the hearts go down one, the lose sound plays, and the apple goes back to the top. When the hearts become 0 “Game over! Your score …” appears.
Touching
The points go up one, a note plays, and the apple goes back to the top in a random place. The remainder score mod 3 = 0 means “every 3 apples”: we add 2 to the speed and show “New level! 🚀”.
The “Again” button
It puts the three variables back to their first values, takes the apple back to the top, and writes “🍎 0 ❤️ 3”.
📌 Another example: a sound for every event
Catching: a high note. Falling: a lose sound.



✍️ Practise here in the lesson✖ Close the labor open the lab in a new page ↗
🎯 Challenge yourself
Every apple you catch adds a point and writes it.
👀 Show the solution🙈 Hide the solution



Result: the points go up.
An apple that falls takes away a heart.
👀 Show the solution🙈 Hide the solution



Result: the hearts go down.
When the hearts run out a “Game over” message appears with the score.
👀 Show the solution🙈 Hide the solution



Result: Game over!

