Catch the Alien

This file is part of and Timex Sinclair Public Domain Library Tape 1003. Download the collection to get this file.
Date: 198x
Type: Program
Platform(s): TS 1000
Tags: Arcade, Game

This is a simple arcade-style game in which the player manoeuvres a cursor character around the screen to catch a randomly placed alien before a countdown timer expires. The alien (%A, displayed in inverse video as an “A”) is placed at a random row and column using INT(22*RND) and INT(27*RND), while the player’s marker (%+, an inverse “+”) is moved with the keys J, I, M, and K — a common four-direction layout. The score is derived from the remaining loop counter X, counting down from 100, so catching the alien quickly yields a higher score; a high-score variable H is maintained across rounds. The game loop uses CLS on every iteration to redraw the screen, and collision detection is a simple two-step coordinate comparison at lines 170–180.


Program Analysis

Program Structure

The program is organised into a small number of logical phases:

  1. Title / init (lines 1–5): Displays the title, pauses briefly, and initialises the high-score variable H to zero.
  2. Round setup (lines 10–30): Resets the player’s row (L=10) and column (C=15) to the centre of the screen, then places the alien at a random position (M, N).
  3. Main game loop (lines 50–200): Counts X down from 100 to 1. Each iteration reads a keypress, moves the player cursor, redraws the screen, and checks for a catch.
  4. Failure path (lines 219–230): Prints “LOST” and loops back to a new round.
  5. Success path (lines 300–310): Updates the high score if appropriate, displays both scores, then falls through to the pause/restart shared at line 220.

Variables

VariableRole
HHigh score (persists across rounds)
LPlayer row (0–21)
CPlayer column (0–31)
MAlien row (random each round)
NAlien column (random each round)
XFOR loop counter / score (100→1)
L$Current keypress

Key BASIC Idioms

  • Inverse-video characters as sprites: %A (inverse “A”) represents the alien and %+ (inverse “+”) represents the player. This is a typical ZX81/TS1000 technique for making characters stand out without any separate graphics data.
  • Countdown loop as timer and score: The FOR X=100 TO 1 STEP -1 loop simultaneously limits round duration and provides the score — the sooner the catch, the larger the remaining value of X.
  • INKEY$ polling inside FOR loop: Line 100 reads INKEY$ on every iteration without waiting, giving a near-real-time movement feel, though the loop speed is bounded by the redraw cost of CLS and two PRINT AT calls each cycle.
  • Two-condition collision detection (lines 170–180): Row and column matches are checked in sequence. Line 170 uses IF L<>M THEN GOTO 200 to skip the column check entirely when the row does not match, avoiding a compound condition.

Movement and Controls

Four keys provide cardinal movement using a layout common on rubber-key machines:

KeyEffect
IUp (decrement row L)
MDown (increment row L)
JLeft (decrement column C)
KRight (increment column C)

Bugs and Anomalies

  • No boundary clamping: L and C are never checked against screen edges. Moving the player off the 22×32 display area will cause an “Out of screen” error and crash the program.
  • Alien not erased on miss: Because the alien is drawn once at line 60 (inside the loop) and CLS is called at line 150, the alien is actually redrawn every iteration — this works correctly, but it means the alien always appears at the fixed position drawn before the loop, and any flickering is inherent to the CLS-then-redraw cycle.
  • Line 60 is inside the FOR loop but the alien position is fixed: M and N are not updated inside the loop, so the alien does not move; it is simply redrawn at the same spot each frame, which is the intended behaviour.
  • High-score condition uses IF H<X: This correctly updates H only when the current score exceeds it.
  • Lines 320–330: These are utility/maintenance lines (SAVE and RUN) that are unreachable during normal program execution and do not affect gameplay.

Content

Appears On

Assembled by Tim Ward from many sources. Contains programs 10122 – 10175.

Related Products

Related Articles

Related Content

Image Gallery

Catch the Alien

Source Code

   1 PRINT AT 0,12;"CATCH THE ALIEN"
   2 PAUSE 300
   4 REM % %C%A%T%C%H% %T%H%E% %A%L%I%E%N% 
   5 LET H=0
  10 LET L=10
  20 LET C=15
  25 LET M=INT (22*RND)
  30 LET N=INT (27*RND)
  50 FOR X=100 TO 1 STEP -1
  60 PRINT AT M,N;"%A"
 100 LET L$=INKEY$
 110 IF L$="J" THEN LET C=C-1
 120 IF L$="M" THEN LET L=L+1
 130 IF L$="I" THEN LET L=L-1
 140 IF L$="K" THEN LET C=C+1
 150 CLS 
 160 PRINT AT L,C;"%+"
 170 IF L<>M THEN GOTO 200
 180 IF C=N THEN GOTO 300
 200 NEXT X
 219 PRINT "LOST"
 220 PAUSE 500
 230 GOTO 25
 300 IF H<X THEN LET H=X
 305 PRINT AT 1,1;"YOU SCORED ";X;" HI SCORE ";H
 310 GOTO 220
 320 SAVE "1015%6"
 330 RUN 

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.

People

No people associated with this content.

Scroll to Top