Earworm
New 10th anniversary edition of my acclaimed novel about what happens when AI and the music business collide.
Anaglyph Aliens is a type-in listing I wrote for Amtix CPC magazine, which was published in June 2024. Below you can play the game, read how it works, and copy the game listing to paste into your emulator. There's also a .dsk file to download.
This game is designed to work with 3D red/blue anaglyph glasses. You can buy them cheaply on eBay, or perhaps you have a pair from a comic or my book Cool Scratch Projects in Easy Steps.
Click the game window to activate it (including sound), and then use the cursor and Space keys to play. At the start, it draws the huge sprites. When the game ends, you can play again without going through this process.
You can play the game below, but the online emulator runs a bit slow and there is a bit more ghosting on the 3D effect. To see it in real time and with a better 3D effect, download my .dsk file to use in your emulator. This disc also includes BAS Invaders and my programs from Amstrad Action, Amstrad Computer User and my book The Basic Idea.
The 3D effect depends entirely on the separation between the red and cyan images. If that gets too big, the effect breaks down. The 3D effect looked really good to me using Winape and the standard window size, but broke down somewhat on an Amstrad monitor and when running the in-browser emulator with a very wide browser window.
You can try adjusting the size of the emulator window you're using, or sitting further back.
The effect is easiest to see if you sit square-on to the monitor and have the monitor close to eye height (that is: not looking down on it, and not looking from the side at it).
I've always been fascinated by 3D effects, as my article about how stereograms work and the 3D games in Cool Scratch Project in Easy Steps show. For the final issue of Amtix CPC in June 2024, I wanted to see whether it was possible to create games using 3D glasses in Amstrad BASIC. There isn't much prior art for this. Mike Singleton wrote a game called 3 Deep Space, which appeared on the Spectrum and other machines, but didn't review well. C&VG ran a 3D special in October 1983 with various type-ins (and some nice 3D illustrations), however they seemed to be limited by the colours available on the computers. I'm not aware of any other 8-bit games for 3D glasses, or any on the Amstrad. [Update! I've since been told by Rity at the CPCWIKI forum about French commercial games Bad Max and Relief Action which came with 3D glasses.]
The 3D effect is possible because the red lens lets red images through and blocks blue, while the blue lens lets blue through and blocks red. Because each eye can be shown a different view of the same object, there can be a sense of depth. The glasses are cheap on eBay and other places, by the way, if you don't have any to hand (search for 3D anaglyph glasses).
How effective the technique would be on the Amstrad depended on how well the machine's colours could match the red and blue lenses of the glasses. I created an experiment using the Winape emulator. For the first demo I simply drew boxes in random positions and at random depths. While there was some leakage of colours through the lenses, it was possible to see a 3D effect and recognise multiple levels of depth. It was also possible to use the older red/green 3D glasses by changing the colour of the right-eye ink from blue to green.
For the magazine listing in the final issue of Amtix CPC (pictured right), I created Anaglyph Aliens, which uses the 3D effect by moving aliens towards you, flying out of the screen.
There are a few interesting things about this program:
Here's the code listing, as it appeared in Amtix magazine. It's much more readable than many of my listings from the 80s! I think this listing achieves quite a bit for its length and would have gone down well in the 80s/90s, although without eBay it was much harder to get hold of 3D glasses then unless they were bundled with the magazine. You can use the Auto Type feature in Winape to paste this program into your emulator.
The version of the game that you see in this browser window adds a menu for choosing your glasses, as well as a couple of other small features and a speed optimisation.
10 REM Anaglyph Aliens - (C) 2024 Sean McManus - www.sean.co.uk
20 REM ----- SPRITE CODE - ESD2 - 1993
30 MEMORY 9999:FOR mem=40110 TO 40221:READ a$:a=VAL(("&")+a$):PRINT:POKE mem,a:NEXT:DATA DD,6E,0,DD,66,1,DD,5E,2,DD,56,3,CD,1D,BC,E5,DD,5E,4,DD,56,5,EB,4E,23,46,23,EB,E1,C5,E5,1A,AE,77,23,13,10,F9,E1,1,0,8,9,30,4,1,50,C0,9,C1,D,20,E8,C9
40 DATA DD,6E,4,DD,66,5,DD,5E,6,DD,56,7,CD,1D,BC,EB,DD,6E,8,DD,66,9,DD,4E,0,DD,46,2,71,23,70,23,C5,D5,1A,77,23,13,10,FA,D1,EB,1,0,8,9,30,4,1,50,C0,9,EB,C1,D,20,E7,C9
50 ON BREAK GOSUB 480:MODE 1:PAPER 0:PEN 1:BORDER 0:ink2=2:INK 0,0:INK 1,0:INK 2,ink2:INK 3,6:REM If you have green glasses change to ink2=9
60 SYMBOL 250,7,13,29,55,24,15,10,18:SYMBOL 251,224,176,184,236,24,240,80,72:SYMBOL 255,48,254,22,60,116,210,254,16:a$=CHR$(250)+CHR$(251):LOCATE 1,25:PRINT a$;CHR$(23)CHR$(1):WINDOW 1,40,1,24:PRINT SPACE$(10);a$;" Anaglyph Aliens ";a$
70 PRINT SPACE$(3);CHR$(164);"2024 Sean McManus - www.sean.co.uk":PRINT:PRINT"Wear red/blue 3D glasses to make the":PRINT"aliens pop out! Cursor keys move, Space fires. You must hit them in the centre. It's their only weak spot. Good luck!"
80 LOCATE #1,39,25:PRINT #1,a$;:WINDOW 1,40,10,24:INK 1,8:addr=10000:sprite=1:size=2:GOSUB 370:FOR size=4 TO 10:GOSUB 370:NEXT
90 LOCATE #1,8,25:PRINT #1,SPACE$(3);"Arming defence forces";SPACE$(6):PLOT 320,250,2:DRAWR 0,-100:PLOT 270,200:DRAWR 100,0:PLOT 340,250,3:DRAWR 0,-100:PLOT 290,200:DRAWR 100,0
100 DEG:FOR a=0 TO 360 STEP 10:PLOT 320+25*SIN(a),200+25*COS(a),2:PLOT 320+15*SIN(a),200+15*COS(a),2:PLOT 340+25*SIN(a),200+25*COS(a),3:PLOT 340+15*SIN(a),200+15*COS(a),3:SOUND 2,a,1,15,0,0,1:NEXT:CALL 40164,addr,135,125,65,50:sights=addr:addr=addr+3300
110 DIM r1(360),r2(360):FOR g=1 TO 360 STEP 10:r1(g)=RND*20:r2(g)=RND*20:NEXT:INK 1,0:INK 2,8:INK 3,8
120 MODE 1:FOR i=2 TO 3:FOR g=1 TO 360 STEP 20:o=275+(i*20):PLOT o+(20*SIN(g)),200+20*COS(g),i:DRAW o+((50+r1(g))*SIN(g+5)),200+(50+r2(g))*COS(g+5),i:DRAW o+(20*SIN(g+10)),200+20*COS(g+10):NEXT g,i:CALL 40164,addr,115,145,45,90:ERASE r1,r2:bang=addr
130 REM ----- GAME BEGINS
140 MODE 1:LOCATE 1,23:PEN 1:bldg$=" "+CHR$(143)+CHR$(140)+CHR$(148)+CHR$(132)+CHR$(141)+CHR$(150)+CHR$(142)+CHR$(156)+CHR$(157):FOR x=1 TO 40:PRINT MID$(bldg$,INT(RND*10)+1,1);:NEXT
150 PAPER 1:PEN 0:WHILE 1:LOCATE 1,24:PRINT SPACE$(79);CHR$(255);:INK 1,8:INK 2,0:INK 3,0:FOR g=1 TO 100:x=RND*640:y=RND*350+50:PLOT x,y,2:PLOTR -10,0,3:NEXT:INK 2,ink2:INK 3,6
160 score=0:landed=0:x=160:y=100:CALL 40110,sights,x-25,y+33:GOSUB 300:GOSUB 320:EVERY 20,1 GOSUB 340:WHILE landed<3:oldx=x:oldy=y
170 IF INKEY(2)=0 THEN y=y-20
180 IF INKEY(0)=0 THEN y=y+20
190 IF INKEY(8)=0 THEN x=x-20
200 IF INKEY(1)=0 THEN x=x+20
210 IF INKEY(47)=0 THEN GOSUB 450
220 IF x>280 THEN x=280 ELSE IF x<20 THEN x=20
230 IF y>160 THEN y=160 ELSE IF y<40 THEN y=40
240 IF x<>oldx OR y<>oldy THEN CALL 40110,sights,oldx-25,oldy+33:CALL 40110,sights,x-25,y+33:SOUND 2,x+y*20,5,15,0,0,8
250 WEND
260 WINDOW #2,15,27,12,14:PAPER #2,0:CLS #2:TAG:PLOT -50,-50,2:MOVE 250,204:PRINT"GAME OVER";:PLOT -50,-50,3:MOVE 260,204:PRINT"GAME OVER";:PLOT 224,174,1:DRAWR 208,0:DRAWR 0,48:DRAWR -208,0:DRAWR 0,-48:TAGOFF
270 FOR h=1 TO 6:FOR g=350 TO 500 STEP 25:SOUND 1,g,h*2,15:SOUND 2,g*2,h*2,15,0,0,8:SOUND 4,g/2,h*2,15:NEXT g,h:SOUND 1,956,150,15:SOUND 2,239,150,15:SOUND 4,468,150,15
280 FOR g=1 TO 3500:NEXT:WINDOW #2,1,40,1,22:PRINT #2,STRING$(24,CHR$(11)):WEND
290 REM ----- SET UP NEW ALIEN
300 alx=(INT(RND*8)*20)+80:aly=(INT(RND*5)*20)+80:distance=1:RETURN
310 REM ----- DRAW ALIEN
320 alienw=PEEK(addr(distance)):alienh=PEEK(addr(distance)+1):CALL 40110,addr(distance),alx-(alienw/1.3),aly+alienh/2:RETURN
330 REM ----- MOVE ALIEN
340 GOSUB 320:distance=distance+1:IF distance=9 THEN landed=landed+1:LOCATE (landed*10),25:PRINT a$;:IF landed=3 THEN g=REMAIN(1):RETURN ELSE GOSUB 300
350 GOSUB 320:SOUND 1,900-(50*distance),5,7+distance,0,0,10:SOUND 1,900,5,7+distance:SOUND 2,900,5,10,0,0,8:SOUND 2,900,5,10,0,0,10:SOUND 4,956,10,15,0,0,3:RETURN
360 REM ----- CREATE ENLARGED ALIEN
370 CLS:LOCATE #1,8,25:PRINT #1,"Making alien size:";size;"at &";HEX$(addr):FOR x=0 TO 32:FOR y=1 TO 16:IF (TEST(x,y) AND size>3) OR (TEST(x,y) AND x MOD 2=0 AND y MOD 2=0) THEN GOSUB 420
380 NEXT y,x:spritex=(200+(size*2))/2:spritey=(size*16+100)/2:spritew=(size*30+(20-size*4))/8:spriteh=size*8:CALL 40164,addr,spritex,spritey,spritew,spriteh
390 FOR g=1 TO 3:CALL 40110,addr,spritex,spritey:FOR h=1 TO 100 STEP 4:SOUND 1,h*15,1,15:SOUND 4,h*25,1,15:SOUND 2,900-h*5,1,15:NEXT h,g
400 addr(sprite)=addr:addr=addr+(spritew*spriteh)+50:sprite=sprite+1:RETURN
410 REM ----- PLOT ALIEN PIXELS
420 PLOT 200+x*size, y*size+100,3:DRAWR size,0:DRAWR 0,size:DRAWR -size,0:DRAWR 0,-size:PLOT 200+x*size+(20-size*4), y*size+100,2:DRAWR size,0:DRAWR 0,size:DRAWR -size,0:DRAWR 0,-size
430 SOUND 1,size*x+300,1,15:SOUND 2,size*x+400,5,15,0,0,7:SOUND 2,size*z+400,1,15:RETURN
440 REM ----- PLAYER FIRES
450 DI:FOR g=150 TO 50 STEP -20:SOUND 1,g,2,15:SOUND 4,g*2,2,15:NEXT
460 IF x=alx AND y=aly-20 THEN CALL 40110,bang,x-45,y+45:FOR g=1 TO 10 STEP 2:SOUND 7,956+(10*g),10,15,0,0,g:NEXT:GOSUB 320:score=score+10:LOCATE 1,25:PRINT score;:GOSUB 300:GOSUB 320:CALL 40110,bang,x-45,y+45
470 EI:RETURN
480 CALL &BC02:PAPER 0:PEN 1:MODE 2:PRINT"You have been playing...":PRINT:LIST
© Sean McManus. All rights reserved.
Visit www.sean.co.uk for free chapters from Sean's coding books (including Mission Python, Scratch Programming in Easy Steps and Coder Academy) and more!
New 10th anniversary edition of my acclaimed novel about what happens when AI and the music business collide.
A free 100-page ebook collecting my projects and tutorials for Raspberry Pi, micro:bit, Scratch and Python.
Web Design in Easy Steps, now in its 7th Edition, shows you how to make effective websites that work on any device.
Power up your Microsoft Excel skills with this powerful pocket-sized book of tips that will save you time and help you learn more from your spreadsheets.
This book, now fully updated for Scratch 3, will take you from the basics of the Scratch language into the depths of its more advanced features. A great way to start programming.
Code a space adventure game in this Python programming book published by No Starch Press.