Alien Blaster is a single-player shoot-the-aliens game in which the player moves a cannon left and right along the bottom of the screen and fires upward to destroy descending alien invaders before five of them land. The program defines two custom UDG characters (loaded via READ/POKE USR into slots \\a and \\b/\\c) to represent the two alien types — a “Raider” and a “Droid” — each worth different point values depending on how far they have descended. Collision detection is handled by comparing the cannon’s pixel X coordinate (derived from its column position) against the alien’s column, using PLOT/DRAW to render the laser beam and OVER 1 to erase it. The game tracks a persistent high score in variable ss across replays, and scoring is calculated as b+(ch*2), rewarding lower-altitude shots and the higher-value alien type.
Program Structure
The program is organized into clearly separated functional blocks:
- Lines 10–50: Initialization — UDG setup, high score reset.
- Lines 60–110: Per-game setup and instructions prompt.
- Lines 120–290: Main game loop — alien descent, cannon movement, firing.
- Lines 300–420: Alien landing, game-over sequence, replay prompt.
- Lines 430–580: Multi-page instructions screens.
- Lines 590–630: Title screen subroutine with musical sweep.
- Lines 640–670: Game-over sound effect subroutine.
- Lines 680–700: Column-correction subroutines selected by
wbased on alien spawn position. - Line 710: Instruction page header subroutine.
- Lines 720–740: UDG DATA for the two alien shapes (24 bytes total).
- Lines 750–760: SAVE with auto-run and a restart stub.
UDG Character Loading
Lines 40 reads 24 bytes of DATA in a FOR/NEXT loop using POKE USR "\\a"+n to define three UDG slots (\\a, \\b, \\c), each 8 bytes. Two alien sprites — Raider (\\b) and Droid (\\c) — are selected in-game by the random variable ch (1 or 2), displayed as CHR$(ch+144). The cannon is drawn with the third UDG (\\a).
Alien Spawning and Column Correction
An alien’s column c is chosen randomly in the range 1–30. Lines 160–180 then select subroutine address w based on the column value: columns 1–5 call line 690 (c=c+1), columns 6–25 call line 700 (no adjustment), and columns 26–30 call line 680 (c=c-1). This prevents aliens from spawning so close to the screen edge that the three-character sprite would be clipped.
Cannon Movement and Laser Firing
The cannon’s screen column is held in a, and its pixel X coordinate is calculated as x=(a*8)+12 at line 210. Movement uses the compact idiom on lines 220 and 280:
a=a+(INKEY$="2" AND a<=28)-(INKEY$="1" AND a>=1)
This exploits the fact that boolean expressions evaluate to 1 (true) or 0 (false), incrementing or decrementing a in a single assignment with boundary guards.
Firing (line 240) uses DRAW INK 5;0,y to draw a vertical laser beam 120 pixels upward from z=31, then erases it with DRAW OVER 1;0,y, giving a flash effect. The BEEP provides auditory feedback.
Collision Detection
Collision is detected at line 330 by comparing the cannon’s pixel X position x against the alien’s expected pixel X, calculated as (c*8)+4. This is a purely arithmetic check rather than attribute or pixel reading. If they do not match, execution falls through to line 340 which jumps back to line 250 (the alien movement subroutine), continuing the descent without registering a hit.
Scoring System
Upon a successful hit (line 360), the score increment is b+(ch*2), where b is the alien’s current row (2–18) and ch is the alien type (1 or 2). This means lower-altitude (closer to landing) kills score more, and the Droid (ch=2) is worth 4 extra points over the Raider. The cumulative score s is compared to the persistent high score ss at game over.
Sound Design
The program uses BEEP extensively for atmosphere:
- Title screen: a descending sweep
FOR n=-10 TO 40: BEEP .1,40-n. - Alien descent:
BEEP .01,19-bcreates a rising pitch as the alien approaches. - Hit explosion: a short loop
FOR n=-3 TO -1: BEEP .04,nproduces a low rumble. - Game over: subroutine at line 640 alternates tones with a nested loop structure.
Bugs and Anomalies
Line 650 contains a structural anomaly: BEEP .1,n:NEXT n appears after the loop at line 640 (FOR n=0 TO 2) has already consumed its NEXT n. This orphaned NEXT n will reuse the most recent loop variable n (value 3 after the FOR/NEXT at line 640), so BEEP .1,3 plays once and execution continues — a likely unintentional leftover of editing.
Line 200 prints the cannon using " \\a " (a space, the UDG, a space) but the sprite string in the listing appears as " \\a "; the alignment between the cannon’s character column a and its pixel coordinate x=(a*8)+12 is slightly offset by the leading space, which is compensated by the +12 offset in the pixel calculation rather than a pure column-to-pixel mapping.
The instructions loop at line 570 uses IF INKEY$<>"" THEN GO TO 120 followed by GO TO 570 — a correct wait-for-keypress pattern, but the key must still be held when line 570 is reached after line 570’s BEEP, which may occasionally require a long keypress to register reliably.
Source Code
10 REM
20 GO SUB 590
30 REM P
40 FOR n=0 TO 23:READ j:POKE USR "\a"+n,j:NEXT n
50 LET ss=0
60 LET a=10:LET s=0:LET q=1
70 LET z=31:LET y=120
80 PRINT AT 12,4;"DO YOU WANT INSTRUCTIONS"
90 BEEP .1,20:LET a$= INKEY$:IF a$="y" THEN GO TO 430
100 IF a$="n" THEN GO TO 120
110 IF a$="" THEN GO TO 90
120 BORDER 1:PAPER 1:INK 6:CLS
130 PRINT AT 1,0; BRIGHT 1; INK 3;"________________________________"; AT 19,0;"________________________________"
140 PRINT AT 0,2; BRIGHT 1; INK 5;"SCORE 0"; AT 0,16; BRIGHT 1; INK 5;"HIGH ";ss
150 LET c= INT (RND*30)+1:LET b=3
160 IF c <=5 THEN LET w=690
170 IF c>5 AND c<26 THEN LET w=700
180 IF c >=26 THEN LET w=680
190 LET ch= INT (RND*2)+1
200 PRINT AT 18,a; INK 6;" \a "; AT b-1,c-1;" "; AT b,c; INK 4; CHR$ (ch+144)
210 LET x=(a*8)+12
220 LET a=a+(INKEY$="2" AND a <=28)-(INKEY$="1" AND a >=1)
230 PLOT x,z:PLOT OVER 1;x,z
240 IF INKEY$="0" THEN DRAW INK 5;0,y:BEEP .025,20:PLOT x,z:DRAW OVER 1;0,y:GO TO 330
250 GO SUB w
260 LET b=b+1:BEEP .01,19-b:IF b=19 THEN GO TO 300
270 PRINT AT 18,a; INK 6;" \a "
280 LET a=a+(INKEY$="2" AND a <=28)-(INKEY$="1" AND a >=1)
290 GO TO 200
300 BEEP .5,-20
310 PRINT AT 18,c-1;" "; AT 21,q*2; INK 7; CHR$ (ch+144):IF q=5 THEN GO TO 370
320 LET q=q+1:GO TO 150
330 IF x=(c*8)+4 THEN GO TO 350
340 GO TO 250
350 FOR n=-3 TO -1:PRINT AT b,c; INK 1; INVERSE 1; CHR$ (ch+144):BEEP .04,n:NEXT n
360 LET s=s+(b+(ch*2)):PRINT AT 0,8; BRIGHT 1; INK 5;s:PRINT AT b,c;" ":GO TO 150
370 PRINT AT 10,12; INK 7;"GAME OVER":IF s >=ss THEN LET ss=s:PRINT AT 0,21; BRIGHT 1; INK 5;ss
380 GO SUB 640
390 PRINT AT 12,6; INK 6;"PRESS Y TO PLAY AGAIN"
400 IF INKEY$="y" THEN CLS :BEEP .3,30:GO TO 60
410 IF INKEY$="n" THEN CLS :STOP
420 GO TO 400
430 BORDER 2:PAPER 2:INK 7
440 GO SUB 710
450 PRINT '" THE ALIENS ARE INVADING YOUR "''" SYSTEM,YOUR ONLY HOPE IS TO "''" BLAST THEM BEFORE THEY LAND"''" AND COLONISE THE EARTH !"
460 PRINT ' INK 7;"\{20}\{1}\{18}\{1}WARNING...\{18}\{0}\{20}\{0}"
470 PRINT '" ONLY FIVE ALIENS HAVE TO LAND"''" TO TAKE OVER!!!"
480 PRINT #0;"PRESS ANY KEY FOR NEXT PAGE"
490 BEEP .1,16:BEEP .1,21:IF INKEY$="" THEN GO TO 490
500 GO SUB 710
510 PRINT '"TO MOVE RIGHT PRESS \{20}\{1}'2'\{20}\{0}"
520 PRINT '"TO MOVE LEFT PRESS \{20}\{1}'1'\{20}\{0}"
530 PRINT '"PRESS \{20}\{1}'0'\{20}\{0} TO FIRE"'''"THERE ARE TWO DIFFERENT ALIENS, ONE SCORES MORE THAN THE OTHER."
540 PRINT '"THE ALIENS ARE WORTH MORE THE NEARER THEY ARE TO THE PLANET."
550 PRINT AT 15,5; INK 5;"\b...RAIDER":PRINT AT 17,5; INK 4;"\c...DROID"
560 PRINT #0;"PRESS ANY KEY TO START"
570 BEEP .2,5:IF INKEY$ <>"" THEN GO TO 120
580 GO TO 570
590 BORDER 2:PAPER 2:INK 7:CLS
600 PRINT AT 10,9;"ALIEN BLASTER"
610 FOR n=-10 TO 40
620 BEEP .1,40-n
630 NEXT n:PAUSE 2:BEEP .5,20:BEEP 1,15:RETURN
640 FOR n=0 TO 2:BEEP .1,10:BEEP .1,15:NEXT n
650 BEEP .1,n:NEXT n
660 PAUSE PI:BEEP .25,15:BEEP .25,15
670 RETURN
680 LET c=c-1:RETURN :\{20}\{1} REM 1000\{20}\{0}
690 LET c=c+1:RETURN :\{20}\{1} REM 2000\{20}\{0}
700 RETURN :\{20}\{1} REM 3000\{20}\{0}
710 CLS :PRINT "ALIEN BLASTER":PRINT AT 0,0; OVER 1;"_____________":RETURN
720 DATA 0,24,24,153,153,255,129,129
730 DATA 60,126,219,126,90,129,66,36
740 DATA 60,36,60,126,255,36,66,129
750 SAVE "blaster" LINE 10
760 CLS :PRINT "hit a key":PAUSE NOT PI:GO TO 10
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.
