3 of 1 ·Timers and state

Lesson 3 · Creative Coding
Mini project: Catch the Falling Objects.
Variables & Score
A variable remembers a value. A score starts at zero; one catch adds one. Trace three catches on paper before adding lives or a timer.
Click to zoomEverything from this month comes together now: sprites, events, loops, conditions and variables, in one working game.
You're building Catch the Falling Objects — a basket at the bottom, things falling from the top, points for catches, lives for misses.
It's a small game. It's also a complete one, with a beginning, a way to win and a way to lose. That's more than most first projects ever get.
Click to zoomAdding a countdown sounds advanced. It's a variable and a loop:
set [timer] to 30
repeat until <timer = 0>
wait 1 seconds
change [timer] by -1
That's a 30-second countdown. repeat until is a third kind of loop — it keeps going until a condition becomes true, which is exactly the shape you need here.
A timer changes the whole feel of a game. The same catching game with 30 seconds on the clock is far more exciting than the same one without.
7 more parts in this lesson
Walkthroughs, code labs, mini-games and the checkpoint quiz unlock when you buy the course.