Detection Drama
Add visual drama to detection — exclamation mark, double border flash, and alarm sounds.
Detection should feel dramatic, not just a quiet life deduction. An exclamation mark appears above the guard, the border flashes red twice, and a two-stage alarm sounds. The player always knows why they were caught.
The Program
10 BORDER 0: PAPER 0: INK 7: CLS
20 DIM m$(8, 16)
30 LET v = 3: LET e = 0: LET l = 1
40 RESTORE 900
50 REM load floor
60 FOR i = 1 TO 8
70 READ m$(i)
80 NEXT i
90 READ r, c, g, h, d$, o, p, w, x
100 LET q = 1: LET t = 0: LET s = 20 - l * 3: LET f$ = d$(1 TO 1)
110 LET j = 0
120 CLS
130 GO SUB 800
135 PRINT AT o + 2, p + 2; INK 6; "*"
136 PRINT AT w + 2, x + 2; INK 1; "X"
140 GO SUB 870
150 REM game loop
155 GO SUB 700
160 PRINT AT r + 2, c + 2; INK 7; BRIGHT 1; "@"
170 PRINT AT g + 2, h + 2; INK 2; "G"
180 LET t = t + 1
190 LET k$ = INKEY$
200 IF k$ = "" THEN GO TO 240
210 LET u = r: LET i = c
212 IF k$ = "q" THEN LET u = r - 1
214 IF k$ = "a" THEN LET u = r + 1
216 IF k$ = "o" THEN LET i = c - 1
218 IF k$ = "p" THEN LET i = c + 1
220 IF u < 1 OR u > 8 OR i < 1 OR i > 16 THEN GO TO 240
222 IF m$(u)(i TO i) = "#" THEN GO TO 240
224 PRINT AT r + 2, c + 2; " "
226 LET r = u: LET c = i
228 IF r = o AND c = p AND j = 0 THEN LET j = 1: BEEP 0.1, 20: PRINT AT w + 2, x + 2; INK 4; "X": GO SUB 870
230 IF r = w AND c = x AND j = 1 THEN GO TO 550
240 IF t < s THEN GO TO 320
250 LET t = 0
255 GO SUB 760
260 PRINT AT g + 2, h + 2; " "
270 LET f$ = d$(q TO q)
280 IF f$ = "N" THEN LET g = g - 1
290 IF f$ = "S" THEN LET g = g + 1
300 IF f$ = "W" THEN LET h = h - 1
310 IF f$ = "E" THEN LET h = h + 1
315 LET q = q + 1: IF q > LEN d$ THEN LET q = 1
320 IF r = g AND c = h THEN GO TO 400
330 GO TO 150
400 REM detected
405 GO SUB 760
410 LET v = v - 1
415 PRINT AT g + 1, h + 2; INK 2; BRIGHT 1; "!"
420 BEEP 0.05, 30: BEEP 0.05, 25
425 BORDER 2: PAUSE 5: BORDER 0: PAUSE 3
430 BORDER 2: PAUSE 5: BORDER 0
435 BEEP 0.1, 20: BEEP 0.15, 15
440 PRINT AT g + 1, h + 2; " "
445 IF v = 0 THEN GO TO 500
460 PRINT AT g + 2, h + 2; " "
470 PRINT AT r + 2, c + 2; " "
480 RESTORE: FOR i = 1 TO (l - 1) * 9 + 8: READ a$: NEXT i: READ r, c, g, h, d$, o, p, w, x
490 LET q = 1: LET f$ = d$(1 TO 1): LET t = 0
495 GO SUB 870: GO TO 150
500 CLS
510 PRINT AT 8, 9; INK 2; "GAME OVER"
520 PRINT AT 10, 8; "Score: "; e
525 PRINT AT 11, 8; "Floor: "; l
530 BEEP 0.15, 0: BEEP 0.15, -3: BEEP 0.2, -7
540 STOP
550 REM floor complete
560 LET e = e + 10 * l
565 GO SUB 760
570 BEEP 0.15, 12: BEEP 0.15, 16: BEEP 0.3, 19
580 PRINT AT 12, 5; INK 4; "FLOOR "; l; " COMPLETE!"
590 PAUSE 50
600 LET l = l + 1
610 IF l > 3 THEN GO TO 650
620 GO TO 60
650 REM victory
660 CLS
670 PRINT AT 8, 8; INK 4; "YOU ESCAPED!"
680 PRINT AT 10, 8; "Score: "; e
690 BEEP 0.15, 12: BEEP 0.15, 16: BEEP 0.15, 19: BEEP 0.3, 24
695 STOP
700 REM === draw sightline ===
710 LET a = g: LET b = h
720 IF f$ = "N" THEN LET a = a - 1
722 IF f$ = "S" THEN LET a = a + 1
724 IF f$ = "W" THEN LET b = b - 1
726 IF f$ = "E" THEN LET b = b + 1
728 IF a < 1 OR a > 8 OR b < 1 OR b > 16 THEN RETURN
730 IF m$(a)(b TO b) = "#" THEN RETURN
732 IF a = r AND b = c THEN GO TO 400
734 PRINT AT a + 2, b + 2; INK 6; "."
736 GO TO 720
760 REM === clear sightline ===
770 LET a = g: LET b = h
772 IF f$ = "N" THEN LET a = a - 1
774 IF f$ = "S" THEN LET a = a + 1
776 IF f$ = "W" THEN LET b = b - 1
778 IF f$ = "E" THEN LET b = b + 1
780 IF a < 1 OR a > 8 OR b < 1 OR b > 16 THEN RETURN
782 IF m$(a)(b TO b) = "#" THEN RETURN
784 IF a = o AND b = p AND j = 0 THEN PRINT AT a + 2, b + 2; INK 6; "*": GO TO 772
786 IF a = w AND b = x THEN PRINT AT a + 2, b + 2; INK 4; "X": GO TO 772
788 PRINT AT a + 2, b + 2; " "
790 GO TO 772
800 REM === draw map ===
810 FOR y = 1 TO 8
820 FOR x = 1 TO 16
830 IF m$(y)(x TO x) = "#" THEN PRINT AT y + 2, x + 2; INK 1; CHR$ 143
840 NEXT x
850 NEXT y
860 RETURN
870 REM === draw HUD ===
880 PRINT AT 0, 0; INK 7; "Lives:"; v; " Score:"; e; " Floor:"; l; " "
885 IF j = 0 THEN PRINT AT 1, 0; INK 6; "Find * then reach X "
886 IF j = 1 THEN PRINT AT 1, 0; INK 4; "Go to X exit! "
890 RETURN
900 REM floor 1
910 DATA "################"
920 DATA "# #"
930 DATA "# ## #### # #"
940 DATA "# # # #"
950 DATA "# #### # #"
960 DATA "# # # #"
970 DATA "# ## # #"
980 DATA "################"
990 DATA 6,2,3,10,"WWWWWWEEEEEE",2,14,6,15
1000 REM floor 2
1010 DATA "################"
1020 DATA "# # # #"
1030 DATA "# # ## # # #"
1040 DATA "# # # #"
1050 DATA "### ##### # #"
1060 DATA "# # #"
1070 DATA "# # # # #"
1080 DATA "################"
1090 DATA 6,2,3,5,"SSSSNNNN",2,14,6,15
1100 REM floor 3
1110 DATA "################"
1120 DATA "# # #"
1130 DATA "# #### # ### #"
1140 DATA "# # #"
1150 DATA "# ##### # ### #"
1160 DATA "# #"
1170 DATA "# # # # # #"
1180 DATA "################"
1190 DATA 6,2,2,3,"EEEEEEEWWWWWWW",2,14,6,15
How It Works
Line 405 clears the sightline first. The visual drama needs a clean stage.
Line 415 prints a bright red ! above the guard. g + 1 places it one row above the guard’s position (remember, lower row numbers are higher on screen — but with the + 2 offset, g + 1 is one row above g + 2). The exclamation mark tells the player: “the guard spotted you here.”
Lines 420-430 create a double border flash. BORDER 2 turns the border red, PAUSE 5 holds it briefly, BORDER 0 resets, PAUSE 3 creates a gap, then the flash repeats. The double flash is more alarming than a single one.
Lines 435 plays the alarm. BEEP 0.1, 20 then BEEP 0.15, 15 — a high tone followed by a lower tone, like a real alarm winding down.
Line 440 cleans up the exclamation mark. PRINT AT g + 1, h + 2; " " removes it before the position reset.
Feedback Pacing
The detection sequence is deliberately paced:
- Sightline clears (instant)
- Exclamation mark appears (instant)
- High-pitched beep (0.05s)
- First border flash (0.1s hold)
- Brief gap (0.06s)
- Second border flash (0.1s hold)
- Alarm tones (0.25s total)
- Exclamation mark removed
Total: about half a second. Long enough to register what happened, short enough not to frustrate. The player sees the !, hears the alarm, sees the red flash — all reinforcing “you were spotted.”
Why Drama Matters
Without the drama, detection is confusing. The player blinks and their position has changed. What happened? With the drama, the cause is clear: the guard saw you, the alarm sounded, you lost a life. Good feedback teaches the player what to avoid.
Try This
Longer drama. Add a third border flash or increase the PAUSE values. At what point does it stop feeling dramatic and start feeling slow?
Sound pitch. Try different BEEP values. Higher pitches (25, 30) feel urgent. Lower pitches (5, 10) feel ominous.