Lesson 2 · Creative Coding
Counting up and down.
A sprite that moves is a toy. Add a score and a way to lose, and it becomes a game.
Score gives the player something to chase. Lives give them something to protect. Together they create the tension that makes people want another go.
Both are just variables — score counting up, lives counting down — but they change how the whole thing feels to play.
Counting up is easy: change score by 1 and let it climb forever.
Counting down needs more care, because something must happen when it hits zero:
change [lives] by -1
if <lives = 0> then
say "Game Over"
stop all
Forget that check and lives sail past zero into -1, -2, -3 while the game carries on. That's the unfinished-branch bug from Chapter 4, showing up in a real program.
5 more parts in this lesson
Walkthroughs, code labs, mini-games and the checkpoint quiz unlock when you buy the course.