DIM c1(200), c2(200), c3(200), c4(200), p1(100), p2(100), caches(4, 8)
DIM frag(200, 7), ctab(4, 5), etab(38), dt(22), shots(16, 3)
' Create the graphics
SCREEN 12
CIRCLE (20, 20), 19, 2
PAINT (20, 20), 2
DRAW "c15d8l10u12ta15r12ta0r10d2ta15l12ta0l10br10d10ta15r12ta0u10"
PAINT (22, 16), 15
CIRCLE (60, 20), 19, 1
PAINT (60, 20), 1
DRAW "c15bh4blh2u2e4r6f4d4g4d4g2h2u6e4h2l2g4bd15br3e2rf2dg2lh2u"
PAINT (60, 20), 15
PAINT (60, 30), 15
CIRCLE (100, 20), 19, 6
PAINT (100, 20), 6
DRAW "c15bl3d8l8u9ta15r10ta0r8dta15l10ta0l8br8d8ta15r10ta0u8d4r3u8ta70u10ta0l8d8u7ta70d10ta0r8l8d2"
PAINT (100, 17), 15
PAINT (100, 12), 15
CIRCLE (140, 20), 19, 4
PAINT (140, 20), 4
DRAW "c15bd12bl2e6r2e4u8h4l12g4d8f4r6dgdgd"
PAINT (140, 20), 15
DRAW "c4bh4r10bg3l8"
PSET (170, 10), 7
DRAW "d24f2r12e2u24h2l12g2"
PAINT (180, 20), 7
DRAW "c8bu8bl8d20fr10eu20hl10g"
PAINT (180, 20), 8
PSET (200, 10), 15
DRAW "d24f2r12e2u24h2l12g2"
PAINT (210, 20), 15
DRAW "c7bu8bl8d20fr10eu20hl10g"
PAINT (210, 20), 7
GET (0, 0)-(39, 39), c1()
GET (40, 0)-(79, 39), c2()
GET (80, 0)-(119, 39), c3()
GET (120, 0)-(159, 39), c4()
GET (170, 8)-(186, 36), p1()
GET (200, 8)-(216, 36), p2()
' Prepare precalc tables
FOR a = 1 TO 4
FOR b = 1 TO 5
READ ctab(a, b)
NEXT
NEXT
FOR a = 1 TO 22
READ dt(a)
NEXT
etab(0) = 32
etab(1) = 46
FOR a = 0 TO 9
etab(a + 2) = a + 48
NEXT
FOR a = 0 TO 25
etab(a + 12) = a + 65
NEXT
' Reset starting values
shipx = 310
levelup:
CLS
level = level + 1
pshoty = -10
cspeed = cspeed + 0.5
cx = 0: cy = 16
direction = 1
downrows = 20
FOR a = 1 TO 4
FOR b = 1 TO 8
caches(a, b) = 1
NEXT
NEXT
' Game loop
WHILE inkey <> 1
' Read keyboard scan codes
inkey = INP(96)
SELECT CASE inkey
CASE 75:
moveleft = 1
CASE 203:
moveleft = 0
CASE 77:
moveright = 1
CASE 205:
moveright = 0
CASE 57:
fire = 1
CASE 185:
fire = 0
END SELECT
'Handle phone "ship"
IF moveleft = 1 THEN acc = acc - 1
IF moveright = 1 THEN acc = acc + 1
IF fire = 1 AND pshoty < 0 AND dead = 0 THEN
pshoty = 460
pshotx = shipx + 6
fired = 8
END IF
LINE (shipx, 450)-(shipx + 17, 479), 0, BF
shipx = shipx + acc
acc = acc / 1.1
IF shipx < 0 THEN shipx = 0: acc = -acc / 2
IF shipx > 622 THEN shipx = 622: acc = -acc / 2
IF (dead = 0) THEN
IF fired > 0 THEN
PUT (shipx, 450), p2(), PSET
fired = fired - 1
ELSE
PUT (shipx, 450), p1(), PSET
END IF
END IF
LINE (pshotx, pshoty)-(pshotx + 3, pshoty + 7), 0, BF
IF pshotx > 0 THEN
pshoty = pshoty - 8
LINE (pshotx, pshoty)-(pshotx + 3, pshoty + 7), 14, BF
END IF
' Cache invader movement
SELECT CASE direction
CASE 1: ' Right
cx = cx + cspeed
FOR b = 7 TO 0 STEP -1
FOR a = 0 TO 3
IF caches(a + 1, b + 1) = 1 AND cx + b * 50 + 39 > 639 THEN
cx = cx - cspeed
downcount = downrows
direction = direction + 1
END IF
NEXT
NEXT
CASE 3: ' Left
cx = cx - cspeed
FOR b = 0 TO 7
FOR a = 0 TO 3
IF caches(a + 1, b + 1) = 1 AND cx + b * 50 < 0 THEN
cx = cx + cspeed
downcount = downrows
direction = direction + 1
END IF
NEXT
NEXT
CASE ELSE: ' Down
cy = cy + cspeed / 2
downcount = downcount - 1
IF downcount < 1 THEN direction = direction + 1
IF direction > 4 THEN direction = 1
END SELECT
' Cache invader collision and drawing
FOR a = 0 TO 3
FOR b = 0 TO 7
LINE (b * 50 + cxold, a * 50 + cyold)-(b * 50 + 40 + cxold, a * 50 + 40 + cyold), 0, BF
IF caches(a + 1, b + 1) = 1 THEN
' Touchdown!
IF a * 50 + cy + 39 > 455 THEN
cspeed = 0
IF dead = 0 THEN
FOR c = 1 TO 200
PSET (frag(c, 1), frag(c, 2)), 0
frag(c, 1) = shipx + 8
frag(c, 2) = 460
frag(c, 3) = RND * (RND - .5) * 20
frag(c, 4) = RND * (RND - .5) * 20 - 10
frag(c, 5) = ctab(3, INT(RND * 5) + 1)
NEXT
dead = 1
END IF
END IF
' Boom!
IF pshotx + 5 > b * 50 + cx AND pshotx < b * 50 + cx + 39 AND pshoty + 8 > a * 50 + cy AND pshoty < a * 50 + cy + 39 THEN
caches(a + 1, b + 1) = 0
LINE (pshotx, pshoty)-(pshotx + 3, pshoty + 7), 0, BF
pshoty = -1
FOR c = 1 TO 200
PSET (frag(c, 1), frag(c, 2)), 0
frag(c, 1) = b * 50 + cx + 19
frag(c, 2) = a * 50 + cy + 19
frag(c, 3) = RND * (RND - .5) * 20
frag(c, 4) = RND * (RND - .5) * 20 - 5
frag(c, 5) = ctab(a + 1, INT(RND * 5) + 1)
NEXT
numshot = numshot + 1
FOR c = (numshot + 4) \ 5 TO 22
dt(c) = dt(c) + 1
IF dt(c) > 37 THEN dt(c) = 0
NEXT
newlevel = 1
FOR d = 1 TO 4
FOR e = 1 TO 8
IF caches(d, e) = 1 THEN newlevel = 0
NEXT
NEXT
IF newlevel = 1 THEN GOTO levelup
ELSE
SELECT CASE a
CASE 0:
PUT (b * 50 + cx, a * 50 + cy), c1(), PSET
CASE 1:
PUT (b * 50 + cx, a * 50 + cy), c2(), PSET
CASE 2:
PUT (b * 50 + cx, a * 50 + cy), c3(), PSET
CASE 3:
PUT (b * 50 + cx, a * 50 + cy), c4(), PSET
END SELECT
END IF
END IF
NEXT
NEXT
cxold = cx: cyold = cy
' Explosion fragments
FOR a = 1 TO 200
PSET (frag(a, 1), frag(a, 2)), 0
frag(a, 1) = frag(a, 1) + frag(a, 3)
frag(a, 2) = frag(a, 2) + frag(a, 4)
frag(a, 4) = frag(a, 4) + 1
PSET (frag(a, 1), frag(a, 2)), frag(a, 5)
NEXT
' Spawn cache shots
numactiveshots = 0
FOR a = 1 TO 16
IF shots(a, 3) > 0 THEN numactiveshots = numactiveshots + 1
NEXT
IF numactiveshots < level + 2 THEN
shotfired = 0
DO
b = INT(RND * 8)
FOR a = 3 TO 0 STEP -1
IF caches(a + 1, b + 1) > 0 THEN
FOR c = 1 TO 16
IF shotfired = 0 AND shots(c, 3) < 1 THEN
shots(c, 1) = b * 50 + cx + 19
shots(c, 2) = a * 50 + cy + 39
shots(c, 3) = ctab(a + 1, 1)
shotfired = 1
END IF
NEXT
END IF
NEXT
LOOP WHILE shotfired = 0
END IF
' Handle and draw shots
FOR a = 1 TO 16
LINE (shots(a, 1), shots(a, 2))-(shots(a, 1) + 5, shots(a, 2) + 8), 0, BF
shots(a, 2) = shots(a, 2) + cspeed
IF shots(a, 3) > 0 THEN
' Shoot the phone!
IF shots(a, 2) > 445 THEN
IF shots(a, 1) < shipx + 17 AND shots(a, 1) + 5 > shipx AND dead = 0 THEN
FOR c = 1 TO 200
PSET (frag(c, 1), frag(c, 2)), 0
frag(c, 1) = shipx + 8
frag(c, 2) = 460
frag(c, 3) = RND * (RND - .5) * 20
frag(c, 4) = RND * (RND - .5) * 20 - 10
frag(c, 5) = ctab(3, INT(RND * 5) + 1)
NEXT
dead = 1
END IF
IF shots(a, 2) > 480 THEN
shots(a, 3) = 0
END IF
END IF
LINE (shots(a, 1), shots(a, 2))-(shots(a, 1) + 5, shots(a, 2) + 8), shots(a, 3), BF
END IF
NEXT
' "Score"
LOCATE 1, 29
FOR a = 1 TO 22
PRINT CHR$(etab(dt(a)));
NEXT
WHILE INP(986) = 0: WEND
WHILE INP(986) = 8: WEND
WEND
' Fun numbers
DATA 2,10,8,7,15,1,9,8,7,15
DATA 6,14,8,7,15,4,12,8,7,15
DATA 20,35,34,18,17,11,4,1
DATA 35,35,21,32,13,9,11,34
DATA 31,29,20,16,16,10
|