A variable lives starts at 3. Change it by -1 for a press on a cross, and for a press that is too slow.
Another hint
At the end of A: if lives = 0, show Game over and the level, then reset level and lives. When level reaches the length of targets, show Champion.
Three lives, game over at zero, and a win after the last level.
This ticks by itself when your blocks do what is asked.
ModifyChange the code on purpose and check the result.
Make it yours
Change the rules to make it your game. Ideas: more levels, a different chance of a fake-out, a shorter wait at higher levels, or a sound for each level.
Try it yourselfYour edits are saved in this browser.
It takes a few seconds to load. Your work in this step is kept.
Lesson done. You've finished every step you need.
Now you can
Use two true/false variables to tell different moments apart.
Use a variable as the place in a list, so a rule gets harder.
An optional, harder extension of the Reaction timer. Students add decoy signals, levels with target times kept in a list, and lives, managing several pieces of state at once. About 60 minutes.
I can use two true/false variables to tell different moments apart.
I can use a variable as the place in a list, so a rule gets harder.
I can manage lives, levels and an end to the game.
Before class
This lesson is optional: it is for students who finished the Reaction timer and Radio duel and want a harder challenge. It needs nothing new, only more of the same ideas at once. A decoy (a cross instead of the heart) appears about one round in three (pick random 0 to 2 = 0); a second true/false variable, decoy, remembers that moment. Levels use a list of target times, targets: the current level is the place in the list, so reaction < targets[level] gets harder as the level rises. When the level reaches the length of the list, the player has won. Lives count mistakes.
Running the lesson
Predict: about one in three. Ask why 0 to 2 gives a third.
Investigate: the list holds the rules of the game. The last question previews Milestone 3's win condition.
Milestone 1: else if decoy. Read A aloud: 'if waiting, time it; else if a cross is showing, caught out; else too early'.
Milestone 2: targets[level] is the key idea: a variable chooses the place in the list.
Milestone 3: goals only. Encourage students to plan on paper first: when do lives go down, when does the game end?
Make it yours: let students swap games and play each other's.
The hard part (on purpose)
Which check comes first in the A button, and a list of targets by level. Ask them to say the order of the questions before testing.
When students get stuck
Pressing on a cross shows the too-early cross, not the skull. Ask: Which is checked first in A: waiting, decoy, or else? Fix: Order: if waiting … else if decoy … else.
The level goes up even when slow. Ask: Which way round is the comparison? Fix: Use reaction < targets[level]: faster than the target.
Something goes wrong after the last level. Ask: Which places exist in targets? Fix: When level equals the length of targets, the player has won: show Champion and start again.
Stretch and support
Stretch: Make the decoy chance grow with the level: pick random 0 to (4 − level), so higher levels trick you more often.
Support: Students who find this heavy can stop after Milestone 2; the levels alone make a good game.
Where it leads
The other optional lesson, Tournament, takes the Radio duel further with a scoreboard list. Class ideas: a class high-level board; students design a sixth level and argue what its target should be.
What each step is for
Investigate: A list can hold the rules of a game: one target per level, found by using the level number as the place.
Milestone 1: fake-outs: A second true/false variable remembers a second kind of moment, and else if tells the moments apart.
Milestone 2: levels: Comparing with a list item, chosen by a variable, lets the same rule get harder as the variable grows.
Milestone 3: lives: Writing the end of the game from goals alone shows whether a student can manage several pieces of state at once.