Skip to content
Game 2 Unit 7 of 8 1 hr learning time

Five Bombs

Wrap the game in a FOR loop — five rounds, random wires, shrinking timers, and a running score.

88% of Bomb Defusal

One bomb is a puzzle. Five bombs is a game. Each bomb picks a new random wire. Each bomb ticks faster than the last. A score tracks how many you defuse. The game gets harder as you play — bomb 1 gives you 9 seconds, bomb 5 gives you 3. The structure that makes this work is a FOR loop wrapped around everything you’ve built so far.

The Round Loop

The key lines that turn one bomb into five:

  36 LET sc=0
  38 FOR b=1 TO 5
  42 LET w=INT (RND*4)+1
  44 LET t=11-b*2
  46 IF t<3 THEN LET t=3

Bomb 3 of 5 — the header shows the round number and current score

Line 36 sets the score to 0 before the loop begins. Line 38 starts the loop: FOR b=1 TO 5. Everything between this line and the matching NEXT b runs five times — once for each bomb.

Line 42 picks a random correct wire: LET w=INT(RND*4)+1. A new wire every round. The player can’t memorise the answer from a previous attempt.

Lines 44-46 set the timer. The formula 11-b*2 gives: bomb 1 = 9, bomb 2 = 7, bomb 3 = 5, bomb 4 = 3, bomb 5 = 1. But 1 second is impossibly fast — the clamp on line 46 sets a minimum of 3. So bombs 4 and 5 both give 3 seconds. Tight, but playable.

Difficulty Scaling

The timer formula is the simplest way to make a game harder: reduce a number each round. Bomb 1 at 9 seconds is relaxed — plenty of time to read the wires and choose. Bomb 3 at 5 seconds is tense. Bomb 5 at 3 seconds is frantic — three ticks to decide, with the beep rising and the fuse burning fast.

The clamp (IF t<3 THEN LET t=3) is important. Without it, bomb 5 would get 11-10=1 — a single tick. The fuse would vanish immediately and the countdown would flash from 1 to 0. The game would feel unfair. Clamping at 3 keeps the last bombs tight but honest.

Score and Header

Inside the loop, each bomb redraws the screen. The header updates to show the current bomb number and score:

  56 PRINT AT 0,1; PAPER 2; INK 7;"Bomb ";b;" of 5"
  58 PRINT AT 0,22; PAPER 2; INK 6;"Score: ";sc

The score increments on a successful defusal: LET sc=sc+1. The player sees their running total in the header bar, updated every round.

The Game Flow

With the FOR loop in place, one round of Bomb Defusal works like this:

  1. Pick a random wire and set the timer
  2. Draw the game screen — header, wires, fuse
  3. Run the countdown — digit, fuse, border, tick sound, INKEY$ check
  4. If the player cuts the right wire: green border, “DEFUSED!”, score +1
  5. If the player cuts the wrong wire or time runs out: explosion strobe, “BOOM!”
  6. NEXT b — on to the next bomb

After 5 bombs, the program falls through to whatever comes next. Right now that’s the end. In the next unit, it’ll be a results screen.

Try This

  • Change FOR b=1 TO 5 to FOR b=1 TO 10. Ten bombs, but the timer formula still bottoms out at 3 — bombs 4 through 10 are all 3-second rounds. The difficulty plateaus.
  • Change the timer formula to LET t=12-b. Now the progression is gentler: 11, 10, 9, 8, 7. Every bomb gets slightly faster but none are frantic. Which feels better?
  • Remove the clamp on line 46. Run the program and play through to bomb 5. What happens with a 1-second timer? Is it playable?

What You’ve Learnt

  • FOR/NEXT for rounds — wrapping game logic in a loop creates multiple rounds from the same code
  • RND per round — each bomb picks a fresh random wire, so every round is different
  • Difficulty scaling — reducing the timer with a formula makes each round harder
  • ClampingIF t<3 THEN LET t=3 prevents the timer from becoming unplayable
  • Running score — a variable that increments on success and displays in the header