Space-Boy is an arcade-style game where the player controls a horizontally moving platform to keep a bouncing character in flight, with the goal of erasing floating objects arranged in an oval pattern at the top of the screen. The oval is drawn procedurally using trigonometric functions (SIN and COS) to position inverse-video characters along an elliptical path before the game loop begins. The platform drifts randomly each cycle via `LET B=B-RND*5+RND*5`, simulating zero-gravity wobble while the player uses X and M to counteract it. A lives counter (K, starting at 5) decrements each time the bouncing space-boy reaches row 18 without the platform being close enough. On game over, the score is displayed and the program restarts from line 240 using `RUN 240`.
Program Analysis
Program Structure
The program divides into three clear phases:
- Introduction (lines 100–264): Scrolling text instructions, waits for ENTER via
INPUT A$. - Setup (lines 5010–5459): Draws an elliptical field of inverse-video objects, initialises game variables.
- Game loop (lines 5510–6060): Main play loop, collision detection, scoring, and game-over handling.
Ellipse Drawing Routine
Lines 5010–5050 use a parametric trigonometric loop to paint an oval of inverse space characters:
PRINT AT 9*COS(B)+12, 14*SIN(B)+17;" " where B = PI*A/50 for A from 1 to 100.
This produces 100 evenly spaced points on an ellipse with semi-axes of 9 rows and 14 columns, centred at row 12, column 17. Because PRINT AT simply plots a character, overlapping positions are silently ignored, and the inverse-video space character effectively “marks” each cell. The CLEAR at line 5060 clears variables but leaves the screen, so the oval persists while game variables are reset.
Screen Layout (Block Graphics)
Lines 5062–5075 construct a decorative capsule/border graphic using ZX block characters printed at rows 5–8. The pattern uses \..\.., \'', and % (inverse space) combinations to create a multi-row rectangular frame representing the top of the capsule.
Game Variables
| Variable | Purpose |
|---|---|
A | Platform row (fixed at 19) |
B | Platform column (drifts randomly each cycle) |
C | Space-boy row (bounces between rows 5 and 18) |
D | Space-boy column (controlled by player) |
E | Vertical direction: +1 (down) or −1 (up) |
K | Lives remaining (starts at 5) |
SCORE | Increments by 1 each game loop iteration |
Game Loop Logic
Each pass through lines 5510–6000 performs the following steps:
- Randomly nudge the platform column:
LET B=B-RND*5+RND*5. The net drift averages to zero but produces noisy movement, simulating weightlessness. - Read
INKEY$for X (move space-boy left) or M (right), clamped to columns 8–23. - Clamp platform column B to the range 9–21.
- Advance the space-boy vertically by
E. - Draw the platform at row
A(19), the space-boy at rowCwith the lives counterKdisplayed beside it. - Erase previous positions by printing spaces.
- Check bounce: if
C+1 = 19, reverse direction (E = -1); ifC = 5, reverse direction (E = 1). - Check miss: if
C = 18andABS(D-B) > 2, decrementK.
Notable Techniques
- Score as time:
SCOREis simply a loop counter — it measures survival time rather than objects erased, despite the instructions implying erasure. - No actual erasure mechanic: The oval objects drawn in the setup phase are never removed during play. The stated goal of “erasing all objects” is not mechanically implemented; the game ends only when
K = 0. - Restart via
RUN 240: Line 6030 usesRUN 240to restart from the “Press ENTER” prompt without rerunning the intro text, a common ZX BASIC idiom. - CLEAR after ellipse:
CLEARat line 5060 resets all variables but preserves the display, allowing the oval to remain on screen while variables are cleanly initialised below. - Platform graphic: The platform is drawn as
\:.\..\.:— a three-character block graphic forming a small shelf shape. - Lives display inline: The value of
Kis printed directly in the space-boy’s sprite row (PRINT AT C,D+1;" ";K), doubling as both a visual element and a HUD.
Bugs and Anomalies
- The game description says the player should erase objects, but no collision detection between the space-boy and the oval objects is implemented.
SCOREsimply counts loop iterations. - The two
INKEY$reads at lines 5520 and 5530 are sequential and independent. Only one key can register per frame, and if both keys happen to be polled in the same pass, only the first pressed is acted upon — a minor but expected limitation of polling without a keypress buffer. - Lines 6040–6060 (
CLEAR,SAVE "1027%4",RUN) appear after the unconditionalRUN 240at line 6030 and are therefore unreachable in normal execution. TheSAVEcommand uses an inverse-video digit in its filename, indicating an auto-run flag. - The miss-detection condition at line 5770 checks
C=18, one row above the platform at row 19. Combined with the bounce reversal atC+1=19(line 5775), a life is lost whenever the space-boy is near the platform row but more than 2 columns away — correct in intent but the row value is slightly inconsistent with the drawn platform position.
Content
Source Code
100 PRINT
110 PRINT TAB (8);"% %S%P%A%C%E%-%B%O%Y% "
120 PRINT
130 PRINT
140 PRINT "IN THIS GAME, YOU HAVE TO"
150 PRINT "MANIPULATE THE FLOATING"
160 PRINT "SPACE-BOY TO ERASE ALL THE"
170 PRINT "OBJECTS FLOATING AT THE TOP"
180 PRINT TAB (8);"OF THE CAPSULE"
190 PRINT
200 PRINT
210 PRINT "KEY X MOVES YOU TO THE LEFT,"
220 PRINT "KEY M TO THE RIGHT"
230 PRINT
235 PRINT "YOU KEEP THE SPACE-BOY IN"
237 PRINT "FLIGHT BY BOUNCING HIM OFF"
238 PRINT TAB (4);"THE MOVING PLATFORM"
240 PRINT
250 PRINT "PRESS ENTER WHEN YOU ARE"
260 PRINT TAB (4);"READY TO PLAY"
264 INPUT A$
270 CLS
\n5010 FOR A=1 TO 100
\n5020 LET B=PI*A/50
\n5030 PRINT AT 9*COS (B)+12,14*SIN (B)+17;"% "
\n5050 NEXT A
\n5060 CLEAR
\n5062 PRINT AT 5,11;"\..\..\''% \''% \''% \''% \''\..\.."
\n5065 PRINT AT 6,11;"% \''% \''% \''% \''% \''% \''% "
\n5070 PRINT AT 7,10;"% \''% \''% \''% \''% \''% \''% \''% "
\n5075 PRINT AT 8,11;"% \''% \''% \''% \''% \''% \''% "
\n5451 LET C=10
\n5452 LET D=10
\n5453 LET SCORE=0
\n5455 LET A=19
\n5456 LET B=21
\n5457 LET E=1
\n5459 LET K=5
\n5510 LET B=B-RND*5+RND*5
\n5520 IF INKEY$="X" THEN LET D=D-1
\n5525 IF D<8 THEN LET D=8
\n5530 IF INKEY$="M" THEN LET D=D+1
\n5535 IF D>23 THEN LET D=23
\n5540 IF B>21 THEN LET B=21
\n5550 IF B<9 THEN LET B=9
\n5555 LET C=C+E
\n5600 PRINT AT A,B;"\:.\..\.:"
\n5710 PRINT AT C,D+1;" ";K
\n5720 PRINT AT C+1,D+1;"\:'\''\':"
\n5721 IF K=0 THEN GOTO 6010
\n5740 PRINT AT A,B;" "
\n5750 PRINT AT C,D+2;" "
\n5760 PRINT AT C+1,D+1;" "
\n5770 IF C=18 AND ABS (D-B)>2 THEN LET K=K-1
\n5775 IF C+1=19 THEN LET E=-1
\n5785 IF C=5 THEN LET E=1
\n5800 LET SCORE=SCORE+1
\n6000 GOTO 5510
\n6010 PRINT AT 10,8;"% % YOU SCORED ";SCORE;"% % "
\n6015 PAUSE 400
\n6020 CLS
\n6030 RUN 240
\n6040 CLEAR
\n6050 SAVE "1027%4"
\n6060 RUN
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.
