--- title: "Catch the Alien" id: 57268 type: "computer_media" slug: "catch-the-alien" url: "http://localhost/computer_media/catch-the-alien/" markdown_url: "http://localhost/computer_media/catch-the-alien.md" published_at: "2024-10-04T07:51:26+00:00" modified_at: "2026-03-30T21:18:49+00:00" author: "David Anderson" featured_image: url: "http://localhost/wp-content/uploads/2024/10/156_CtA.png" excerpt: "Race against a countdown to catch a randomly placed alien by steering your cursor with four keys — score higher by catching it faster." category: - name: "Archived Media" slug: "archived-media" taxonomy: "category" url: "http://localhost/category/archived-media/" post_tag: - name: "Downloadable" slug: "downloadable" taxonomy: "post_tag" url: "http://localhost/tag/downloadable/" - name: "TS 1000" slug: "ts1000" taxonomy: "post_tag" url: "http://localhost/tag/ts1000/" model: - name: "Timex/Sinclair 1000" slug: "ts-1000" taxonomy: "model" url: "http://localhost/model/ts-1000/" genre: - name: "Arcade" slug: "arcade" taxonomy: "genre" url: "http://localhost/type/arcade/" - name: "Game" slug: "game" taxonomy: "genre" url: "http://localhost/type/game/" media_contents: - id: 56734 title: "Timex Sinclair Public Domain Library Tape 1003" type: "computer_media" url: "http://localhost/computer_media/timex-sinclair-public-domain-library-tape-1003/" media_type: "Program" mediadate: "198x" images: - url: "http://localhost/wp-content/uploads/2024/10/156_CtA.png" media_type_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 | Variable | Role | | --- | --- | | `H` | High score (persists across rounds) | | `L` | Player row (0–21) | | `C` | Player column (0–31) | | `M` | Alien row (random each round) | | `N` | Alien column (random each round) | | `X` | FOR 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: | Key | Effect | | --- | --- | | `I` | Up (decrement row `L`) | | `M` | Down (increment row `L`) | | `J` | Left (decrement column `C`) | | `K` | Right (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 HM 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