RWAP wrote:Now if only I had time to do some QL programming - I am sure we could manage a cut down space invaders in 20 lines... (although it would be slow...!)
Did someone say a cut down space invaders in 20 lines?
OK, here's one. Sound effects and all. Just about makes it into 20 lines at the cost of some long lines.
Press cursor left or right to move your base laser left/right. Press space to fire at the invaders. They may fire back at you from time to time.
It's a bit c**p really, but just about meets the suggestion, crying out for someone to improve it (too tired to do more work on it tonight). Now to see if I can remember how to put the code, zip attachment and screen in...
100 REMark (very) cut-down invaders by Dilwyn Jones
110 WINDOW 484,252,0,0:BORDER 1,255 : CLS : CSIZE 2,0
120 inv$ = ' X X X X X X ' : invdrs=6 : basex = RND(0 TO 39) : invy = 1 : invx = 0 : direc = 1 : firey = 25 : AT 24,basex:PRINT'A'; : speed%=10 :speedcount%=speed%:AT invy,invx:PRINT inv$; : bomby = 0
130 REPeat program
140 key = CODE(INKEY$(1)) : IF key=32 THEN IF firey = 25 THEN firey=23 : firex = basex : END IF : END IF
150 IF key=192 OR key = 200 THEN AT 24,basex:PRINT' ';: basex = basex-(key=192 AND basex>0)+(key=200 AND basex<39) : AT 24,basex : PRINT'A'; : END IF
160 IF firey < 25 THEN
170 AT firey,firex : PRINT' ';
180 IF firey = invy THEN
190 IF firex >= invx AND firex<(invx+22) THEN IF inv$(firex-invx+1) = 'X' THEN BEEP 2000,10 : inv$(firex-invx+1) = ' ' : AT firey,firex : PRINT '*'; : invdrs = invdrs-1 : PAUSE 2 : AT firey,firex : PRINT' '; : firey = 25 : END IF : REMark hit invader
200 END IF
210 END IF
220 IF firey < 25 THEN firey = firey-1 : IF firey < 0 THEN firey = 25 : ELSE AT firey,firex : PRINT '|'; : END IF : END IF : speedcount% = speedcount%-1
230 IF speedcount%<1 THEN BEEP 10,50:speedcount% = speed% :invx = invx+direc:IF invx > (40-LEN(inv$)) THEN invx = 40-LEN(inv$): AT invy,invx : PRINT FILL$(' ',LEN(inv$));:direc=-direc:invy=invy+1:ELSE IF invx<0 THEN direc=-direc : invx = 0 : AT invy,invx : PRINT FILL$(' ',LEN(inv$)); : invy = invy+1:END IF : AT invy,invx : PRINT inv$; : END IF
240 IF bomby > 0 THEN AT bomby,bombx : PRINT ' '; : bomby = bomby+1 : AT bomby,bombx : PRINT'#'; : END IF : IF bomby > 23 THEN IF bombx = basex THEN BEEP 5000,50 : AT 0,0 : PRINT'Oops, the aliens got you...' : EXIT program : ELSE AT 24,bombx : PRINT' ';:bomby=0:END IF
250 IF bomby = 0 AND RND(1 TO 100) = 1 THEN
260 no=RND(1 TO invdrs):FOR x=1 TO LEN(inv$):IF inv$(x)='X' THEN no=no-1:IF no<=1 THEN bombx=x+invx-1: bomby=invy+1:AT bomby,bombx:PRINT'#';:EXIT x:END IF :END FOR x
270 END IF
280 IF inv$ = FILL$(' ',LEN(inv$)) THEN AT 0,0 : PRINT'Congratulations - you saved earth!!!' : EXIT program : REMark won
290 IF invy = 24 THEN BEEP 5000,20,70,50,1 : AT 0,0 : PRINT'Oops, the aliens landed.' : EXIT program:REMark landed
300 END REPeat program
invaders20_bas.zip
invaders20.jpg