19 — Game: how fast are you?
The stopwatch from 15 — Time is enough for a game. Start the clock the moment the signal appears, and read it when the key comes down.
Steps
Starting the clock and reading it is the whole idea:
run it →start the timer ask answer Press enter show elapsedelapsedis the seconds since the clock was started.Give the signal late. Asking straight away lets someone press early, so pause first:
run it →show Get ready wait 3 seconds show Press enter nowKeeping the reading in a name lets you use it more than once:
run it →start the timer ask answer Enter set taken to elapsed show takenSay how fast that was:
run it →set taken to 0.4 if taken is less than 1 show very fast else if taken is less than 2 show not bad else show a little slow endAll of it together:
run it →show A reaction test show Get ready wait 3 seconds show Press enter now start the timer ask answer Enter set taken to elapsed show taken if taken is less than 1 show very fast else if taken is less than 2 show not bad else show a little slow endThe clock gives the time up to the moment
elapsedis read, so where you start it is exactly where the measuring begins.
Try it yourself
Measure three times and show the best of them. Put each reading in a list and
ask for the smallest of times — the list is from 05 — Set and
the smallest is from 17 — Word guess.
What you learned
start the timerstarts the clock andelapsedgives the seconds since.set taken to elapsedkeeps a reading so it can be used again.- A
waitbefore the signal is what stops an early press. - The reading is an ordinary number, so a condition takes it as it is.