This program implements a simple catching game where the player moves a basket left and right to catch falling treasure bags. Each round, a bag drops from a random column across 15 attempts, and the player scores a randomly generated pound value (a multiple of 10 up to £40) for each successful catch. The program tracks a running session score (“SWAG”) and a persistent high score (“HI-SWAG”) across rounds, looping back to restart after each 15-bag session. Block graphics are used for the bag sprite and basket, with inverse-video pound signs representing the falling item.
Program Analysis
Program Structure
The program is organised into a tight main loop with minimal subroutines. Initialisation and the game loop are all inline:
- Lines 10–30: Initialise basket position (
X), high score (H), and round score (S). - Lines 40–210: Outer
FOR Mloop iterates 15 bag-drop attempts per session. - Lines 80–140: Inner
FOR Yloop animates the falling bag down 9 rows. - Lines 150–210: Catch detection, scoring, and display after the bag lands.
- Lines 220–250: End-of-session: high score update and restart via
GOTO 30.
Gameplay Mechanics
At the start of each attempt, a bag column A is chosen randomly via INT(RND*12)+2, placing it in columns 2–13. A score value B is set to a random multiple of 10 from 0 to 40 using (INT(RND*5))*10. The player moves the basket left (5) or right (8) during the fall. Catch detection at line 160 checks whether A=X+2, meaning the centre of the basket (offset by 2 from its left edge) aligns with the bag column.
Display and Graphics
The game uses a combination of block graphics and inverse-video characters for its visuals. The ceiling/border on row 1 is drawn once per attempt at line 70 using ▌ and ▐ characters flanking a row of inverse pound signs (%£). The falling bag is rendered as a single inverse pound sign (%£), erased each step by printing a space at line 130. The basket drawn at line 120 uses a composite string mixing block graphics and spaces to suggest a container shape:
\:— left edge block graphic (▌)%— inverse space (filled cell)\ :— right edge block graphic (▐)
Key BASIC Idioms
Player input is polled inside the inner fall loop (lines 100–110) using bare INKEY$ comparisons, which means the basket only moves if a key is held during the brief window each row provides — effectively coupling movement speed to the fall rate. Boundary checks (X<>0 and X<>11) prevent the basket from scrolling off screen.
Scoring and High Score
The current session score S accumulates catch values in B and is displayed live at line 180. After all 15 attempts, H is updated only if S>H (line 230), providing persistent high-score tracking for the duration of the program’s execution. Since S is reset at line 30 but H is only reset at line 10 (on cold start), the high score survives across sessions.
Potential Bugs and Anomalies
- The ceiling line (line 70) is redrawn at the start of every attempt, even though it doesn’t change — a minor inefficiency that could be moved to a one-time initialisation block.
- A bag value of
B=0is possible (whenINT(RND*5)=0), meaning the player can “catch” a bag worth nothing, displayingSWAG=£with an unchanged total — this may confuse players. - The basket is 7 characters wide (line 120:
" \: % \ : ") but the catch check uses a single-column test (A=X+2), so only a narrow central hit registers, despite the visual suggesting a wider catch area. - The ceiling is drawn at row 1 (line 70) rather than row 0, leaving row 0 reserved for the score display at line 180 — a deliberate layout choice that works correctly.
Content
Source Code
5 REM "SWAG"
10 LET H=0
20 LET X=0
30 LET S=0
40 FOR M=1 TO 15
50 LET A=INT (RND*12)+2
60 LET B=(INT (RND*5))*10
70 PRINT AT 1,1;"\ :%£%£%£%£%£%£%£%£%£%£%£%£\: "
80 FOR Y=1 TO 9
90 PRINT AT Y,A;"%£"
100 IF INKEY$="5" AND X<>0 THEN LET X=X-1
110 IF INKEY$="8" AND X<>11 THEN LET X=X+1
120 PRINT AT 10,X;" \: % \ : "
130 PRINT AT Y,A;" "
140 NEXT Y
150 PRINT AT 10,A;"%£"
160 IF A<>X+2 THEN GOTO 200
170 LET S=S+B
180 PRINT AT 0,2;"SWAG=£";S
190 GOTO 210
200 PRINT AT 10,A;" "
210 NEXT M
220 CLS
230 IF H<S THEN LET H=S
240 PRINT AT 0,12;"HI-SWAG=£";H
250 GOTO 30
260 SAVE "1016%5"
270 LIST
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.
