Home / Commodore 64 / Phase 0 / Lesson 8
Lesson 8 of 64

Mini-Game: Typing Turmoil

What you'll learn:

  • Combine loops, input, randomness, and sound into a playable mini-game.
  • Track score and lives to create tension and clear win/lose states.
  • Measure reaction time with `TI` and reward quick responses.
13% Complete

Lesson 8 – Mini-Game: Typing Turmoil

Time to put Week 1’s skills to work. You’ll build a reflex game that flashes random letters, waits for a quick key press, and keeps score with sound effects. It’s simple, frantic, and proves how far PRINT, loops, IF, GET, RND, and the SID can take you.

[📷 suggested: screenshot of the Typing Turmoil scoreboard mid-game]


The One-Minute Tour

  • Clear and redraw the HUD each round to keep information current.
  • Use RND to pick the target letter; GET captures the player’s response.
  • Compare reaction time with TI to award bonuses.
  • SID bleeps celebrate hits and groan at misses.

Game Listing

NEW
5  REM === TYPING TURMOIL ===
10 POKE 54295,0 : POKE 54296,0 : REM silence before starting
20 RND(-TI) : SCORE=0 : LIVES=3 : ROUND=0
30 PRINT CHR$(147)
40 PRINT "TYPING TURMOIL" : PRINT "---------------"
50 PRINT "PRESS THE LETTER SHOWN BEFORE TIME RUNS OUT" : PRINT
60 IF LIVES=0 THEN GOTO 200
70 ROUND=ROUND+1
80 TARGET=INT(RND(1)*26)+65 : TARGET$=CHR$(TARGET)
90 TIME_LIMIT=120 : REM about 2 seconds (PAL)
100 PRINT CHR$(147)
110 PRINT "ROUND "; ROUND
120 PRINT "SCORE: "; SCORE; TAB(20); "LIVES: "; LIVES
130 PRINT : PRINT "TYPE: "; TARGET$
140 TI$="000000"
150 GET K$ : IF K$="" THEN IF TI<TIME_LIMIT THEN 150
160 IF K$=TARGET$ THEN GOSUB 400 : GOTO 170
161 IF K$="" THEN GOSUB 500 : GOTO 180
162 GOSUB 500 : GOTO 180
170 ELAPSE=TI : BONUS=0
171 IF ELAPSE<60 THEN BONUS=5
172 SCORE=SCORE+10+BONUS
173 PRINT : PRINT "GOOD!";
174 IF BONUS>0 THEN PRINT " BONUS!"
175 IF BONUS=0 THEN PRINT
176 PRINT "REACTION: "; INT(ELAPSE*10/60)/10; " SEC"
177 IF BONUS>0 THEN PRINT "+";10+BONUS;" POINTS"
178 IF BONUS=0 THEN PRINT "+10 POINTS"
179 FOR T=1 TO 300: NEXT T
180 GOTO 60
182 LIVES=LIVES-1
183 PRINT : PRINT "MISS!";
184 IF K$="" THEN PRINT " TOO SLOW"
185 IF K$<>"" THEN PRINT " WRONG KEY"
186 PRINT "THE LETTER WAS "; TARGET$
187 FOR T=1 TO 400: NEXT T
188 GOTO 60
200 PRINT CHR$(147)
210 PRINT "GAME OVER" : PRINT "----------"
220 PRINT "ROUNDS PLAYED: "; ROUND
230 PRINT "FINAL SCORE : "; SCORE
240 PRINT
250 PRINT "PRESS Y TO PLAY AGAIN OR ANY OTHER KEY TO QUIT"
260 GET K$ : IF K$="" THEN 260
270 IF K$="Y" THEN RUN
280 PRINT : PRINT "THANKS FOR PLAYING!"
290 END

400 REM --- SUCCESS SOUND ---
410 POKE 54273,0 : POKE 54272,80
420 POKE 54275,18 : POKE 54276,240
430 POKE 54277,17
440 FOR D=1 TO 50: NEXT D
450 POKE 54277,16
460 RETURN

500 REM --- FAILURE SOUND ---
510 POKE 54273,200 : POKE 54272,20
520 POKE 54275,66 : POKE 54276,32
530 POKE 54277,129
540 FOR D=1 TO 80: NEXT D
550 POKE 54277,128
560 RETURN

[🎥 suggested: gameplay clip showing a successful round, a miss, and the game-over screen]


Code Tour

  • Lines 10–20: reset the SID volume, seed the RNG, and initialise score/lives.
  • Lines 30–130: draw the HUD each round with PRINT and TAB.
  • Lines 150–162: loop on GET until the timer expires or the player presses a key.
  • Lines 170–176: award points, add a speed bonus, and play the success sound.
  • Lines 180–184: deduct a life, announce the correct letter, and play the failure sound.
  • Lines 200–290: graceful game-over screen with replay option.
  • Subroutines 400–560: two simple SID tones for feedback.

Experiment Section

  • Tighten or relax the timer by changing TIME_LIMIT.
  • Swap to numbers: TARGET=INT(RND(1)*10)+48.
  • Add a second difficulty level—after every five rounds, reduce TIME_LIMIT or increase the bonus threshold.
  • Display the high score by storing the best SCORE in another variable.
  • Replace the sounds with different waveforms or multi-note jingles.

[📷 suggested: screenshot of a tweaked HUD with different targets]


Concept Expansion

You now have the loop structure common to many real-time BASIC games: draw → wait → evaluate → score → repeat. Future weeks will introduce arrays for word banks, sprite animation, and smarter timers using raster interrupts, but the heartbeat will feel familiar.


Game Integration

  • Use the same loop skeleton for shooter “waves,” whack-a-mole, or rhythm trainers.
  • Attach the timer logic to power-ups: fast responses extend a combo meter.
  • Reuse the success/failure sounds as global feedback cues across mini-games.

From the Vault


Quick Reference

RND(-TI)               : REM seed randomness once per run
TARGET$ = CHR$(INT(RND(1)*26)+65)
TI$ = "000000"         : REM reset system clock
GET K$: IF K$="" THEN ...
IF K$=TARGET$ THEN SCORE = SCORE + 10 : GOSUB 400 : GOTO 60
LIVES = LIVES - 1
GOSUB 500
  • Keep the game responsive by redrawing only the necessary HUD elements.
  • Reset TI$ before each round to measure reaction time cleanly.
  • Remember to gate off the SID voice (POKE 54277,16/128) after each tone.

What You’ve Learnt

  • How to stitch together all Week 1 techniques into a playable loop.
  • Managing score, lives, and timers for real tension.
  • Using sound for immediate feedback.
  • Designing restart logic so players can keep chasing high scores.

Next up: Week 2 kicks off with Gridlocked — building 2D layouts that turn typing practice into map adventures.