This program implements a simple two-element chase game where the player maneuvers a cursor character toward a randomly moving target on a black screen. The player character is rendered using a block-graphic character (▘.) and is moved with the Q/A/O/P keys, while the target drifts pseudo-randomly in one of four cardinal directions by two character positions per cycle. The main loop uses a short FOR/NEXT delay (lines 80–90) to pace the animation instead of PAUSE, and both sprites are erased each frame by overprinting with INK 0 (invisible ink) rather than clearing the whole screen. When the player catches the target, a victory sequence at line 900 flashes the player character using alternating INK colors and FLASH 1, looping 50 times before halting.
Program Analysis
Program Structure
The program is organized into two logical sections: an initialization block (lines 5–50), a main game loop (lines 60–240), and a win sequence (lines 900–960). Initialization sets the screen to all-black with BORDER 0: PAPER 0: CLS, places the target at the screen center (X=15, Y=11), and sets the player origin at A=0, B=0 (row, column respectively).
Sprite Rendering and Erasure
Both the player and target are single two-character block-graphic sprites. Erasure is achieved by overprinting with INK 0 on a black PAPER 0 background (lines 100–110), making the characters invisible rather than actually clearing them. This avoids screen flicker from a full CLS and is a common Sinclair BASIC sprite technique. The player character is ▘. (a block-graphic followed by a dot) and the target is a space printed with a colored INK, effectively a colored block.
Movement and Controls
The target moves by selecting a random integer 1–4 (line 120) and applying a step of ±2 in X or Y, with boundary checks to keep it within the 32×22 character grid (lines 130–160). The player is moved one character at a time via INKEY$ polling (lines 170–200) using the standard Q/A/O/P layout. Boundary limits allow the player to reach row 20 downward and column 30 rightward.
| Key | Action | Boundary Check |
|---|---|---|
| Q | Move up (A−1) | A≥1 |
| A | Move down (A+1) | A≤20 |
| O | Move left (B−1) | B≥1 |
| P | Move right (B+1) | B≤30 |
Timing and Loop Control
The main loop begins at line 80 with a FOR N=1 TO 17: NEXT N busy-wait delay. This is a deliberate pacing mechanism — a pure BASIC spin loop — substituting for PAUSE, which would block all input. This keeps the game loop responsive to INKEY$ while still introducing a small delay per frame.
Collision Detection
Collision is checked at line 210 by comparing the player coordinates (A, B) directly with the target coordinates (Y, X). Because the target moves in steps of 2 and the player moves in steps of 1, it is theoretically possible for the target to always remain on even coordinates while the player can occupy odd ones, potentially making the game unwinnable under certain conditions. However, since both start at reachable coordinates and movement is asymmetric, in practice the game is completable.
Win Sequence
Lines 900–950 implement a 50-iteration celebration loop. Each iteration prints "YOU WON!" at the top-left in green on white paper, then redraws the player character at the catch position using BRIGHT 1, FLASH 1, and a random INK color. Interleaving two PRINT AT A,B statements with different random INK values inside the same loop creates a simple color-cycling flash effect without any additional timing logic. The program ends with PAUSE 1000: STOP.
Notable Anomalies
- The player boundary check for moving right is
B<=30, allowing column 31 — valid but asymmetric with the target’sX<=29limit. - The target uses
INK INT(RND*7)+1(colors 1–7) in the erase-then-redraw phase, but line 220 usesINK INT(RND*6)+2(colors 2–7), so the target is never rendered in blue (INK 1) during the main loop redraw. - The
FOR N=1 TO 50loop at line 900 spans all the way toNEXT Nat line 950, enclosing the entire win animation — an unusual multi-statement loop body spread across several line numbers.
Content
Source Code
5 REM PROGRAM TAG
10 BORDER 0: PAPER 0: CLS
20 LET X=15
30 LET Y=11
40 LET A=0
50 LET B=0
60 PRINT AT A,B;"\'."
70 PRINT AT Y,X; INK INT (RND*7)+1;"\ "
80 FOR N=1 TO 17
90 NEXT N
100 PRINT AT Y,X; INK 0;""
110 PRINT AT A,B; INK 0;""
120 LET C=INT (RND*4)+1
130 IF C=1 AND X<=29 THEN LET X=X+2
140 IF C=2 AND X>=2 THEN LET X=X-2
150 IF C=3 AND Y<=19 THEN LET Y=Y+2
160 IF C=4 AND Y>=2 THEN LET Y=Y-2
170 IF INKEY$="O" AND B>=1 THEN LET B=B-1
180 IF INKEY$="A" AND A<=20 THEN LET A=A+1
190 IF INKEY$="Q" AND A>=1 THEN LET A=A-1
200 IF INKEY$="P" AND B<=30 THEN LET B=B+1
210 IF A=Y AND B=X THEN GO TO 900
220 PRINT AT Y,X; BRIGHT 1; INK INT (RND*6)+2;"\ "
230 PRINT AT A,B; INK 7;"\'."
240 GO TO 80
900 FOR N=1 TO 50: PRINT AT 0,0; PAPER 7; INK 2;"YOU WON!"
910 BORDER 0
920 PRINT AT A,B; BRIGHT 1; INK INT (RND*6)+2; FLASH 1;"\'."
930 PRINT AT A,B; INK 7; FLASH 1;"\'."
940 BORDER 2
950 NEXT N
960 PAUSE 1000: STOP
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.
