QB64.org Forum

Active Forums => Programs => Topic started by: SierraKen on July 23, 2019, 01:45:42 am

Title: Robot Invaders
Post by: SierraKen on July 23, 2019, 01:45:42 am
I've been wanting to make a game like this since a friend of mine made something similar, but different, back in the 90's. When I found out how to make that spiral yesterday, I thought to myself today, why not make an enemy that uses that to fly around in a spiral? So I played with it this evening and got it to go in the spiral, and then fly back out of the spiral. Then it appears somewhere else randomly on the screen. That is your only enemy on this game. I know more enemies would make the game more interesting, but this game is more of a challenging game in the fact that it's a lot harder to shoot him than the Alphabet Invaders was lol. But it's also hard to keep away from him firing as well. So, have fun with the game. There's no ending to it except after 5 lives. And I didn't make a High Scores sheet for this one, maybe if I make more of an advanced one later on. But I'm pretty amazed at myself that I can finally do something like this. Tell me what you think, thanks. There's only the code to get for this one. Oh, and one of the tricky parts was figuring out where to put the INKEY$ since the robot uses loops to fly, so I put GOSUBs to the INKEY$ in both loops, and other GOSUBs, which makes it a bit messy, but it works. :)

(Note: The much better Version 2 is below on this forum page.)

Code: QB64: [Select]
  1. 'Game made on July 22, 2019
  2. 'By Ken G.
  3. 'Freeware
  4. begin:
  5. _TITLE "Robot Invaders"
  6. SCREEN _NEWIMAGE(800, 600, 32)
  7. PRINT "                                 R O B O T     I N V A D E R S"
  8. PRINT "                                         by Ken G."
  9. PRINT "                       Use left and right arrow keys to move back and forth."
  10. PRINT "                            Use up or down arrow keys to stop moving."
  11. PRINT "                                    Use space bar to fire."
  12. PRINT "                                      Esc to end anytime."
  13. INPUT "                                   Press Enter to start."; start$
  14. lives = 5
  15. points = 0
  16. ushoot = 0
  17. shooting = 0
  18. s = 0
  19. xt = 400: yt = 550
  20. LINE (xt, yt)-(xt + 20, yt + 20), _RGB32(128, 139, 255), BF
  21. LINE (xt + 10, yt)-(xt + 10, yt - 10), _RGB32(128, 139, 255)
  22. go:
  23. xx = INT(RND * 550) + 50
  24. yy = INT(RND * 300) + 50
  25.  
  26. FOR d = 160 TO 0 STEP -.125
  27.     _LIMIT 1000
  28.     s = s + 1
  29.     x = COS(s * 3.141592 / 180) * d
  30.     y = SIN(s * 3.151492 / 180) * d
  31.     LINE (x + xx, y + yy)-(x + xx - 10, y + yy - 10), _RGB32(127, 216, 127)
  32.     LINE (x + xx + 20, y + yy)-(x + xx + 30, y + yy - 10), _RGB32(127, 216, 127)
  33.     LINE (x + xx, y + yy)-(x + xx + 20, y + yy + 20), _RGB32(127, 216, 127), BF
  34.     LINE (x + xx + 5, y + yy + 5)-(x + xx + 8, y + yy + 8), _RGB32(0, 0, 0), BF
  35.     LINE (x + xx + 12, y + yy + 5)-(x + xx + 15, y + yy + 8), _RGB32(0, 0, 0), BF
  36.     LINE (x + xx + 5, y + yy + 13)-(x + xx + 15, y + yy + 16), _RGB32(0, 0, 0), BF
  37.     _DELAY .004
  38.     LINE (x + xx, y + yy)-(x + xx + 20, y + yy + 20), _RGB32(0, 0, 0), BF
  39.     LINE (x + xx, y + yy)-(x + xx - 10, y + yy - 10), _RGB32(0, 0, 0)
  40.     LINE (x + xx + 20, y + yy)-(x + xx + 30, y + yy - 10), _RGB32(0, 0, 0)
  41.     GOSUB keyboard:
  42.     GOSUB shoot:
  43.     GOSUB youshoot2:
  44. FOR d = 0 TO 160 STEP .125
  45.     _LIMIT 1000
  46.     s = s - 1
  47.     x = COS(s * 3.141592 / 180) * d
  48.     y = SIN(s * 3.151492 / 180) * d
  49.     LINE (x + xx, y + yy)-(x + xx - 10, y + yy - 10), _RGB32(127, 216, 127)
  50.     LINE (x + xx + 20, y + yy)-(x + xx + 30, y + yy - 10), _RGB32(127, 216, 127)
  51.     LINE (x + xx, y + yy)-(x + xx + 20, y + yy + 20), _RGB32(127, 216, 127), BF
  52.     LINE (x + xx + 5, y + yy + 5)-(x + xx + 8, y + yy + 8), _RGB32(0, 0, 0), BF
  53.     LINE (x + xx + 12, y + yy + 5)-(x + xx + 15, y + yy + 8), _RGB32(0, 0, 0), BF
  54.     LINE (x + xx + 5, y + yy + 13)-(x + xx + 15, y + yy + 16), _RGB32(0, 0, 0), BF
  55.     _DELAY .004
  56.     LINE (x + xx, y + yy)-(x + xx + 20, y + yy + 20), _RGB32(0, 0, 0), BF
  57.     LINE (x + xx, y + yy)-(x + xx - 10, y + yy - 10), _RGB32(0, 0, 0)
  58.     LINE (x + xx + 20, y + yy)-(x + xx + 30, y + yy - 10), _RGB32(0, 0, 0)
  59.     GOSUB keyboard:
  60.     GOSUB shoot:
  61.     GOSUB youshoot2:
  62. GOTO go:
  63.  
  64. keyboard:
  65. _LIMIT 1000
  66. a$ = INKEY$
  67. IF a$ = CHR$(27) THEN END
  68. IF a$ = CHR$(0) + CHR$(77) THEN r = 1: l = 0
  69. IF r = 1 THEN
  70.     LINE (xt, yt)-(xt + 20, yt + 20), _RGB32(0, 0, 0), BF
  71.     LINE (xt + 10, yt)-(xt + 10, yt - 10), _RGB32(0, 0, 0)
  72.     xt = xt + 1
  73.     IF xt > 780 THEN xt = 780
  74.     LINE (xt, yt)-(xt + 20, yt + 20), _RGB32(128, 139, 255), BF
  75.     LINE (xt + 10, yt)-(xt + 10, yt - 10), _RGB32(128, 139, 255)
  76. IF a$ = CHR$(0) + CHR$(75) THEN l = 1: r = 0
  77. IF l = 1 THEN
  78.     LINE (xt, yt)-(xt + 20, yt + 20), _RGB32(0, 0, 0), BF
  79.     LINE (xt + 10, yt)-(xt + 10, yt - 10), _RGB32(0, 0, 0)
  80.     xt = xt - 1
  81.     IF xt < 0 THEN xt = 0
  82.     LINE (xt, yt)-(xt + 20, yt + 20), _RGB32(128, 139, 255), BF
  83.     LINE (xt + 10, yt)-(xt + 10, yt - 10), _RGB32(128, 139, 255)
  84. IF a$ = CHR$(0) + CHR$(72) OR a$ = CHR$(0) + CHR$(80) THEN
  85.     r = 0: l = 0
  86.  
  87.  
  88. IF a$ = " " THEN GOSUB youshoot:
  89.  
  90. youshoot:
  91. _LIMIT 1000
  92. IF ushoot = 0 THEN
  93.     sx2 = xt + 10
  94.     sy2 = yt - 11
  95.     ushoot = 1
  96.     SOUND 400, .5
  97.  
  98. youshoot2:
  99. _LIMIT 1000
  100. IF ushoot = 1 THEN
  101.     CIRCLE (sx2, sy2), 5, _RGB32(0, 0, 0)
  102.     sy2 = sy2 - 3
  103.     IF sy2 < 0 THEN ushoot = 0: RETURN
  104.     CIRCLE (sx2, sy2), 5, _RGB32(255, 0, 0)
  105.     IF sx2 > x + xx - 1 AND sx2 < x + xx + 21 AND sy2 > y + yy - 1 AND sy2 < y + yy + 21 THEN
  106.         CIRCLE (sx2, sy2), 3, _RGB32(0, 0, 0)
  107.         SOUND 200, 1
  108.         SOUND 100, 1
  109.         FOR explosion = 1 TO 30
  110.             CIRCLE (x + xx + 10, y + yy + 10), explosion, _RGB32(255, 0, 0)
  111.             _DELAY .02
  112.             CIRCLE (x + xx + 10, y + yy + 10), explosion, _RGB32(0, 0, 0)
  113.         NEXT explosion
  114.         LINE (x + xx - 21, y + yy - 21)-(x + xx + 41, y + yy + 41), _RGB32(0, 0, 0), BF
  115.         points = points + 100
  116.         lives$ = STR$(lives)
  117.         points$ = STR$(points)
  118.         _TITLE "Robot Invaders      Lives: " + lives$ + "      Score: " + points$
  119.         _DELAY .5
  120.         ushoot = 0
  121.     END IF
  122.  
  123. shoot:
  124. _LIMIT 1000
  125. IF shooting = 0 THEN
  126.     sh = INT(RND * 10000) + 1
  127.     IF sh < 9970 THEN RETURN
  128.     sx = x + xx + 10
  129.     sy = y + yy + 10
  130.     shooting = 1
  131.     SOUND 300, .5
  132. IF shooting = 1 THEN
  133.     CIRCLE (sx, sy), 5, _RGB32(0, 0, 0)
  134.     sy = sy + 3
  135.     IF sy > 620 THEN shooting = 0: RETURN
  136.     CIRCLE (sx, sy), 5, _RGB32(255, 0, 0)
  137.     IF sx > xt - 1 AND sx < xt + 21 AND sy > yt - 1 AND sy < yt + 21 THEN
  138.         CIRCLE (sx, sy), 5, _RGB32(0, 0, 0)
  139.         SOUND 200, 1
  140.         SOUND 100, 1
  141.         FOR explosion2 = 1 TO 30
  142.             CIRCLE (xt + 10, yt + 10), explosion2, _RGB32(255, 0, 0)
  143.             _DELAY .02
  144.             CIRCLE (xt + 10, yt + 10), explosion2, _RGB32(0, 0, 0)
  145.         NEXT explosion2
  146.         lives = lives - 1
  147.         lives$ = STR$(lives)
  148.         points$ = STR$(points)
  149.         _TITLE "Robot Invaders      Lives: " + lives$ + "      Score: " + points$
  150.         _DELAY 1
  151.         LINE (xt - 22, yt - 42)-(xt + 42, yt + 42), _RGB32(0, 0, 0), BF
  152.         IF lives = 0 THEN
  153.             LOCATE 20, 40: PRINT "G A M E   O V E R"
  154.             LOCATE 22, 40: PRINT "Score: "; points
  155.             LOCATE 24, 40: INPUT "Play Again (Yes/No)", ag$
  156.             IF ag$ = "Y" OR ag$ = "y" OR ag$ = "YES" OR ag$ = "yes" OR ag$ = "Yes" OR ag$ = "YEs" OR ag$ = "yES" OR ag$ = "yeS" THEN GOTO begin:
  157.             END
  158.         END IF
  159.         shooting = 0
  160.         RETURN
  161.     END IF
  162.  
  163.  
Title: Re: Robot Invaders
Post by: Petr on July 23, 2019, 02:55:04 am
Hi SierraKen,

Great idea, nice workmanship. The computer beat me several times in a row. Nice work :-D

So, now i am beat computer, so it is better... :-D
Title: Re: Robot Invaders
Post by: Ashish on July 23, 2019, 08:39:22 am
Hi SierraKen! I like this!
Similar to a program which can be found here - "programs/samples/pete/mooncr/mooncr.bas" inside the QB64 folder.
Title: Re: Robot Invaders
Post by: bplus on July 23, 2019, 10:15:55 am
Another good one, nice job!

PS: The readability of the program using GOSUBs is a vast improvement over the program that used only GOTO's.
Title: Re: Robot Invaders
Post by: johnno56 on July 23, 2019, 10:22:36 am
Cool game... I'm 'still' getting killed off... but a cool game never the less...

J
Title: Re: Robot Invaders
Post by: SierraKen on July 23, 2019, 11:58:10 am
Thanks everyone! I'm going to try to make more enemies and ways they fly. It will dramatically increase the length of the code but I believe it will be worth it. :) I will also make it a tiny bit easier by slowing the robots down.
Title: Re: Robot Invaders
Post by: SierraKen on July 23, 2019, 12:16:53 pm
Neat Ashish, I want to see it but I am not able to find the URL. What is the entire URL to it, or the URL to the forum post of it? Thanks.
Title: Re: Robot Invaders
Post by: Ashish on July 23, 2019, 12:20:29 pm
Nevermind. I include the code for you. (Go where you installed qb64. Then goto programs->samples->pete->mooncr->mooncr.bas)
Code: QB64: [Select]
  1. REM - written for QBasic / QuickBasic (freeware) -
  2. REM - V.26
  3. REM - by Daniel Kupfer
  4. REM - for more info look at the end / press f1 in title
  5. REM - any problems / questions ? mail: dk1000000@aol.com
  6.  
  7. DEFINT A-Z
  8. scx = 159: scy = 99
  9. xp = scx: yp = 172: vp = 6: vsh = 6
  10. xpmin = 0: xpmax = 319: shmax = 15: emax = 7: esmax = 3: fmax = 15
  11. stmax = 31: exmax = 7
  12. SND = 1: bonplay& = 20000
  13. pi! = 3.14158: pi2! = pi! / 2: pi4! = pi! / 4
  14. cts1 = 0: cts2 = 4: cts3 = 10
  15.  
  16. DIM tae(201), tne(201): n = shmax
  17. DIM xsh(n), ysh(n): n = stmax
  18. DIM xst(n), yst(n), xst!(n), yst!(n), cst(n), vst(n): n = emax
  19. DIM xe!(n), ye!(n), ae(n), dae(n), ne(n), ce(n), ste(n)
  20. DIM ze(n), zze(n), tpe(n), tce(n): n = exmax
  21. DIM xex(n), yex(n), stex(n), zex(n), tex(n): n = esmax
  22. DIM xes!(n), yes!(n), dxes!(n), dyes!(n), stes(n), tes(n)
  23. DIM aes(n), des(n): n = fmax
  24. DIM fx!(n), fy!(n), dfx!(n), dfy!(n), fc(n), ft(n): n = 11
  25. DIM ptse(n), dble(n), anie(n), adde(n), zoome(n)
  26. DIM table(n), c1e(n), c2e(n), expe(n), c1ee(2, n), c2ee(2, n): n = 7
  27. DIM tce0(n), xec(n), yec(n), aec(n): n = 12
  28. DIM xc!(n), yc!(n), zc!(n), cc(n), ac(n), nc(n)
  29. DIM ENEMY$(20, 3), CRASH$(4), bin(4), CH$(42): n = 7
  30. DIM vbos(n), vsbos(n), tsbos(n), fsbos(n), ptsbos(n), hrbos(n)
  31. DIM BOSS$(n), STAGE$(n)
  32. DIM cp(95), SFINAL$(2, 9), CREDIT$(50)
  33. A5$ = STRING$(4, CHR$(170)) + STRING$(4, CHR$(85))
  34.      
  35. FOR e = 1 TO 11: READ p, d, m, a, z, T, ex
  36. ptse(e) = p: dble(e) = d: anie(e) = m: adde(e) = a: zoome(e) = z
  37. table(e) = T: expe(e) = ex: NEXT e
  38. DATA 10,0,0,0,64,1,1, 20,0,0,0,64,2,1, 25,0,0,0,64,2,1
  39. DATA 40,0,0,0,64,5,1, 50,0,0,0,64,4,1, 200,0,0,0,64,6,1
  40. DATA 250,0,0,0,64,7,1, 100,1,0,1,64,2,1, 120,0,0,0,64,3,1
  41. DATA 120,1,3,1,64,2,1, 160,0,2,0,48,3,1
  42.  
  43. FOR s = 0 TO 2
  44. FOR e = 1 TO 11: READ c1, c2: c1ee(s, e) = c1: c2ee(s, e) = c2: NEXT e: NEXT s
  45. DATA 7,13, 6,14, 5,15, 5,11, 3,15, 2,10, 2,10, 4,12, 1,14, 2,14, 9,15
  46. DATA 4,13, 2,10, 1,4,  7,15, 4,14, 3,11, 3,11, 5,13, 2,15, 2,14, 9,15
  47. DATA 5,14, 3,11, 2,14, 12,14, 14,4, 4,12, 4,12, 6,14, 3,15, 6,14, 4,12
  48.  
  49. REM  - - - - BOSS SETUP - - - - - -
  50.  
  51. FOR n = 1 TO 7: READ a$, s$: BOSS$(n) = a$: STAGE$(n) = s$: NEXT n
  52. DATA "MYKOR MASTER","VEGA SYSTEM","PHOENIX","ALPHA CENTAURI"
  53. DATA "EVIL BATSY","DARK PLANET","QUARRIOR","AQUARUIS"
  54. DATA "MC FISHKING","NEPTUN","BEEBOP QUEEN","MOONBASE"
  55. DATA "MOTHERSHIP","EARTH"
  56. FOR n = 1 TO 7: READ v, ts, f, p, r: vbos(n) = v: tsbos(n) = ts
  57. fsbos(n) = f: ptsbos(n) = p: hrbos(n) = r: NEXT n
  58. DATA 1,1,4,1000,20, 1,4,6,2500,20, 2,1,8,4000,20, 1,5,10,7500,20
  59. DATA 1,3,100,10000,24, 2,2,10,16000,20, 1,0,0,25000,40
  60. FOR n = 0 TO 3: READ c: csb(n) = c: NEXT n
  61. DATA 4,12,14,10
  62.  
  63. REM  - - - - ESHOT SETUP - - - -
  64. FOR n = 1 TO 5: READ v, d: ves(n) = v: ses(n) = d: NEXT n
  65. DATA 5,2, 4,2, 2,4, 3,2, 3,2
  66.  
  67. n = 1
  68. DO: READ a, T: tae(n) = a: tne(n) = T: n = n + 1
  69. LOOP UNTIL a = -1 AND T = -1
  70. nte = n - 1
  71. PATTERN1:
  72. DATA 0,100, -900,1, 0,32, -900,1, 0,50, -900,1, 0,8, -900,1
  73. DATA 0,70, 900,1, 0,10, 900,1, 0,50, -900,1, 30,60 ,0,90
  74. DATA 30,30, 0,50, 900,1, 0,14, 900,1, 0,20, 900,1, 0,16
  75. DATA 900,1, 0,20, 900,1, 0,14, 900,1, 0,20, 900,1, 0,16
  76. DATA 900,1, 0,20, 900,1, 0,14, 900,1, 0,40, 900,2, 0,0
  77. PATTERN2:
  78. DATA -30,30, 30,75, 0,34, -30,95, 0,34, 30,95, 0,34, -30,95
  79. DATA  0,34, 30,95, 0,34, -30,95, 0,34, 30,50, 0,25, 30,30
  80. DATA  0,60, 60,30, 0,110, -60,31, 0,90, 60,31, 0,60, -60,32
  81. DATA  0,30, 60,32, 30,28, 0,20, 0,0, 0,0, 0,0, 0,0
  82. PATTERN3:
  83. DATA -90,20, 90,30, -90,30, 90,20, -90,20, 90,40, 90,10, -90,20
  84. DATA  90,20, -90,30, 90,20, -90,20, 90,20, -90,21, 0,20, 0,0
  85. DATA  90,20, -90,30, 90,30, -90,20, 90,20, -90,40, -90,10, 90,20
  86. DATA -90,20, 90,30, -90,20, 90,20, -90,20, 90,21, 0,20, 0,0
  87. PATTERN4:
  88. DATA  30,60, -30,-30, 30,60, 0,40, 30,20, 0,30, 30,90, -30,90
  89. DATA -30,90, 30,45, 0,20, -30,15, 0,10, 30,15, -30,15, 30,15
  90. DATA  0,80, 30,5, 0,40, 30,5, 0,40, 30,5, 0,40, 30,5
  91. DATA  0,40, 30,180, 0,120, 0,0, 0,0, 0,0, 0,0, 0,0
  92. PATTERN5:
  93. DATA  0,130, 30,60, 0,105, 90,20, 0,60, -90,20, 0,20, 90,20
  94. DATA  0,60, 90,10, 0,80, 90,20, 0,80, -90,20, 0,80, 90,20
  95. DATA  0,60, 30,270, 0,50, 0,0, 0,0, 0,0, 0,0, 0,0
  96. PATTERN6:
  97. DATA  -30,85, 0,50, 30,0, -30,80, 0,60, 30,80, 0,60, -30,80
  98. DATA  0,60, 30,80, 0,60, -30,80, 0,60, 30,50, 0,25, 30,30
  99. DATA  0,60, 60,30, 0,110, -60,31, 0,90, 60,31, 0,60, -60,32
  100. DATA  0,30, 60,32, 30,28, 0,20, 0,0, 0,0, 0,0, 0,0
  101. PATTERN7:
  102. DATA -30,60, 0,80, 0,0, 0,0, 30,60, 0,80, 0,0, 0,0
  103. DATA -1,-1
  104.  
  105. FOR n = 1 TO 7: READ T, x, y, a, v, c: tce0(n) = T: xec(n) = x: yec(n) = y
  106. aec(n) = a: vec(n) = v: crec(n) = c: NEXT n
  107. DATA 0,0,20,0,4,7, 40,159,119,900,4,7
  108. DATA 72,159,119,900,4,7, 104,149,109,900,4,7
  109. DATA 136,320,20,1800,4,7
  110. DATA 160,159,50,900,4,7, 192,159,50,900,4,7
  111.  
  112. FOR n = 0 TO 9: READ x, y: pcx(n) = x: pcy(n) = y: NEXT n
  113. DATA 0,-2, -10,-2, 10,-2, -10,3, 10,3
  114. DATA 0,-5, -14,-4, 14,-4, -14,3, 14,3
  115.  
  116. GOSUB LOAD.SPRITES
  117. GOSUB LOAD.SOUNDS
  118. GOSUB LOAD.CHARSET
  119.  
  120. FOR n = 0 TO shmax: ysh(n) = -1: NEXT n
  121. FOR n = 0 TO stmax: GOSUB CREATE.STAR: NEXT n
  122. FOR n = 0 TO emax: ste(n) = -1: ce(n) = 2: NEXT n
  123. FOR n = 0 TO esmax: stes(n) = -1: NEXT n
  124.  
  125.  
  126. REM - - - - - - - - TITLE SCREEN - - - - - - - -
  127. x = -40: zmax = 40
  128. FOR n = 0 TO 7: READ nc, cc
  129. xc!(n) = x: yc!(n) = 26: zc!(n) = 200: nc(n) = nc: cc(n) = cc
  130. x = x + 7: NEXT n
  131. FOR n = 8 TO 9: READ nc, cc
  132. xc!(n) = x + 55: yc!(n) = yc!(1) + 30: zc!(n) = zmax: nc(n) = nc: cc(n) = cc
  133. x = x + 7: NEXT n
  134. DATA 29,15, 31,15, 31,15, 30,15, 19,15, 34,15, 17,15, 32,15, 9,15, 9,15
  135.  
  136. REM  - - - LEVEL SETUP - - -
  137. FOR n = 1 TO 9: READ T, r, s, h
  138. ltpe(n) = T: lrad(n) = r: lsum(n) = s: lhit(n) = h: NEXT n
  139. DATA 1,14,1,1, 1,14,2,1, 2,12,2,1, 3,12,2,1
  140. DATA 4,12,2,1, 5,14,2,1, 8,16,1,3, 10,14,1,3
  141. DATA 6,12,4,1
  142.  
  143. RESTORE CREDITS
  144. FOR n = 1 TO 34: READ a$: CREDIT$(n) = a$: NEXT n
  145.  
  146. x = 100: y = 100: c1 = 6: c2 = 14: a = 0: z = 4
  147. e = 6: f = 0: GOSUB DRAW.ESPRITE
  148.  
  149. GOSUB WAITKEY0: GOSUB TITLE
  150.  
  151. STAGE = 1: LEVEL = 1: stbos = -1: tbos = 1
  152. GOSUB LOAD.LEVEL
  153. REM                        ---> player setup
  154. ssec(1) = 1: ssec(2) = 0: ssec(3) = 0: GOSUB SETUP.SHIP
  155. stp = 0:                    REM status player
  156. score& = 0
  157. GOSUB DRAW.PLAYER1
  158. n = INT(2 * RND)
  159. IF n = 0 AND SND = 1 THEN PLAY SLAUNCH$
  160. IF n = 1 AND SND = 1 THEN PLAY SNEWPL1$
  161. GOSUB WAITFIRE: REM GOTO GAME.FINISH
  162. GOSUB ENTER.STAGE
  163.  
  164. MAIN:
  165. k0 = k: k = INP(96): k$ = INKEY$
  166. IF k = 1 THEN END
  167. IF k = 31 THEN SND = 1 - SND: GOSUB WAITKEY0
  168. IF k = 25 THEN GOSUB PAUSE.MODE
  169. IF k = 29 AND k0 <> 29 THEN GOSUB FIRE.SHOT
  170. GOSUB KEYS
  171. GOSUB MOVE.PLAYER
  172. GOSUB MOVE.SHOT
  173. GOSUB MOVE.ENEMY
  174. GOSUB MOVE.BOSS
  175. GOSUB MOVE.ESHOT
  176. WAIT &H3DA, 8: WAIT &H3DA, 8, 8
  177. GOSUB DRAW.ESHOT
  178. GOSUB DRAW.ENEMY
  179. GOSUB DRAW.BOSS
  180. GOSUB TEST.HIT.SHOT
  181. GOSUB TEST.HIT.PLAYER
  182. GOSUB DRAW.SHOT
  183. GOSUB DRAW.EVENT
  184. GOSUB DRAW.PLAYER
  185. GOSUB DRAW.STAR
  186. LOCATE 1, 30: PRINT score&
  187. GOSUB CREATE.ESHOT
  188. crec1 = crec1 - 1: IF crec1 = 0 THEN crec1 = crec0: GOSUB CREATE.ENEMY
  189. cnt1 = (cnt1 + 1) AND 255
  190. GOSUB TEST.LEVELEND
  191. REM GOSUB DOCKING
  192. GOTO MAIN
  193.  
  194.  
  195. MOVE.BOSS:
  196. IF stbos < 0 THEN RETURN
  197. xbos! = xbos! + dxbos!: ybos! = ybos! + dybos!
  198. IF hbos = 1 AND ybos! > 10 AND tbos < 7 THEN ybos! = ybos! - 3
  199. IF xbos! < 10 THEN dxbos! = 1
  200. IF xbos! > 309 THEN dxbos! = -1
  201. IF ybos! < 10 THEN dybos! = 1
  202. IF ybos! > 99 THEN dybos! = -1
  203. GOSUB SHOT.BOSS
  204. IF INT(100 * RND) < 1 THEN GOSUB ACTIV.BOSS
  205.  
  206. SHOT.BOSS:
  207. IF tbos = 7 THEN GOTO SHOT.SUPERBOSS
  208. r = fsbos(tbos) * STAGE
  209. IF INT(1000 * RND) > r THEN RETURN
  210. x = xbos!: y = ybos!: T = tsbos(tbos): s = ses(T)
  211. IF T = 3 THEN s = 2 + INT(5 * RND)
  212. GOSUB FIRE.ESHOT
  213.  
  214. SHOT.SUPERBOSS:
  215. GOSUB CREATE.SUPERENEMY
  216.  
  217. CREATE.SUPERENEMY:
  218. IF INT(8 * RND) > 0 THEN RETURN
  219. n = (eptr + 1) AND emax: IF ste(n) <> -1 THEN RETURN
  220. T = tpe + 1: mt = table(T)
  221. ye!(n) = ybos!: ae(n) = 900 + 180 * RND - 90
  222. xe!(n) = xbos!
  223. ze(n) = 64: zze(n) = zoome(T)
  224. ste(n) = 0: tpe(n) = T
  225. tce(n) = tce0(mt) + INT(2 * RND) * 4
  226. GOSUB LOADPTR.ENEMY
  227.  
  228. ACTIV.BOSS:
  229. a! = INT(8 * RND) * pi4!
  230. dxbos! = COS(a!) * vbos(tbos): dybos! = SIN(a!) * vbos(tbos)
  231. IF tbos = 7 THEN dybos! = 0
  232.  
  233. DRAW.BOSS:
  234. IF stbos = -1 THEN RETURN
  235. IF stbos < 0 THEN GOTO DRAW.BOSS1
  236. x = xbos!: y = ybos!
  237. ON tbos GOSUB DBOSS1, DBOSS2, DBOSS3, DBOSS4, DBOSS5, DBOSS6, DBOSS7
  238. IF bin(1) = 0 THEN hbos = 0
  239. DRAW.BOSS1:
  240. stbos = stbos + 1: GOSUB DRAW.BDOTS
  241. IF stbos < -100 AND SND = 1 THEN SOUND 37 + 120 * RND, .4
  242. IF stbos = -90 THEN GOTO DRAW.BOSS2
  243. IF stbos > -96 AND stbos < -48 AND PLAY(0) = 0 AND SND = 1 THEN PLAY SBOSPTS$
  244. DRAW.BOSS2:
  245. FOR e = 0 TO emax: ste(e) = -1: NEXT e: cresum = 0
  246. pts& = ptsbos(tbos): GOSUB LOAD.SCORE
  247. evcnt = 50: evpts = pts&: evtpe = 1
  248.                    
  249. DRAW.BDOTS:
  250. FOR m = 0 TO fmax
  251. x = fx!(m): y = fy!(m)
  252. LINE (x, y)-(x + 1, y + 1), fc(m), BF
  253. fx!(m) = fx!(m) + dfx!(m): fy!(m) = fy!(m) + dfy!(m)
  254.  
  255. DRAW.EVENT:
  256. IF evcnt <= 0 THEN RETURN
  257. evcnt = evcnt - 1: yc! = 70: ac = 0: sc = 4: T$ = evtxt$
  258. IF evtpe = 1 THEN xc! = 160: i = evpts: cc = 15 * RND: GOSUB DRAW.INTF
  259. IF evtpe = 2 THEN xc! = 159 - LEN(T$) * 4: cc = 15: GOSUB DRAW.TXTZ
  260.  
  261. BINARY.CNT:
  262. bin(1) = 1 - bin(1): b2 = bin(2): b3 = bin(3)
  263. IF bin(1) = 0 THEN bin(2) = 1 - bin(2)
  264. IF bin(2) < b2 THEN bin(3) = 1 - bin(3)
  265. IF bin(3) < b3 THEN bin(4) = 1 - bin(4)
  266.  
  267. TEST.LEVELEND:
  268. IF emovcnt > 0 OR expcnt > 0 OR stbos <> -1 THEN etimer = 0: RETURN
  269. etimer = etimer + 1: IF etimer < 25 THEN RETURN
  270. etimer = 0
  271. IF (LEVEL AND 7) = 5 THEN GOSUB DOCKING:                REM level 3 + 7
  272. GOSUB ADVANCE.LEVEL
  273. GOTO MAIN
  274.  
  275. PAUSE:
  276. DO: WAIT &H3DA, 8: WAIT &H3DA, 8, 8: c = c - 1: LOOP UNTIL c = 0
  277.  
  278. WAITFIRE:
  279. GOSUB WAITKEY0
  280. t0! = TIMER
  281. k = INP(96): k$ = INKEY$
  282. t1! = TIMER - t0!
  283. LOOP UNTIL k = 29 OR t1! > 4
  284. GOSUB WAITKEY0
  285.  
  286. KEYS:
  287. REM IF k0 = 75 OR k0 = 77 THEN RETURN
  288. IF k = 75 THEN dxp = -vp: k1 = 203
  289. IF k = 77 THEN dxp = vp: k1 = 205
  290. IF k = k1 THEN dxp = 0
  291.  
  292. MOVE.PLAYER:
  293. IF stp < 0 THEN GOTO CREATE.PLAYER
  294. xp = xp + dxp
  295. IF xp > xpmax THEN xp = xpmax
  296. IF xp < xpmin THEN xp = xpmin
  297.  
  298. CREATE.PLAYER:
  299. IF stp < -1 THEN RETURN
  300. stp = 0: f = 0
  301. FOR q = 1 TO 3
  302. IF ssec(q) > -1 THEN f = 1
  303. IF ssec(q) = 0 THEN ssec(q) = 1: f = 1: EXIT FOR
  304. IF f = 0 THEN stp = 1
  305. IF f = 1 AND SND = 1 THEN PLAY SNEWPL2$
  306. GOSUB SETUP.SHIP
  307.  
  308. SETUP.SHIP:
  309. sss0 = 0: sss1 = 0: s = 0
  310. IF ssec(1) = 1 THEN s = s OR 1
  311. IF ssec(2) = 1 THEN s = s OR 2
  312. IF ssec(3) = 1 THEN s = s OR 2
  313. IF s = 3 THEN sss0 = 1
  314. IF s = 2 THEN sss1 = 1
  315.  
  316. FIRE.SHOT:
  317. IF stp > 0 THEN RETURN
  318. IF sss0 = 1 THEN sss1 = 1 - sss1
  319. IF sss1 = 0 AND ssec(1) = 1 THEN GOSUB FIRE.SHOT1: s = 1
  320. IF sss1 = 1 AND ssec(2) = 1 THEN GOSUB FIRE.SHOT2: s = 2
  321. IF sss1 = 1 AND ssec(3) = 1 THEN GOSUB FIRE.SHOT3: s = 2
  322. FIRE.SHOT1:
  323. IF ysh(cts1) > 0 THEN RETURN
  324. xsh(cts1) = xp: ysh(cts1) = yp - 4
  325. cts1 = cts1 + 1: IF cts1 = 4 THEN cts1 = 0
  326. IF PLAY(0) = 0 AND SND = 1 THEN PLAY SLASER1$
  327. FIRE.SHOT2:
  328. IF ysh(cts2) > 0 OR ysh(cts2 + 1) > 0 THEN RETURN
  329. xsh(cts2) = xp - 9: ysh(cts2) = yp + 3
  330. xsh(cts2 + 1) = xp + 9: ysh(cts2 + 1) = yp + 3
  331. cts2 = cts2 + 2: IF cts2 = 10 THEN cts2 = 4
  332. IF PLAY(0) = 0 AND SND = 1 THEN PLAY SLASER2$
  333. FIRE.SHOT3:
  334. IF ysh(cts3) > 0 OR ysh(cts3 + 1) > 0 THEN RETURN
  335. xsh(cts3) = xp - 14: ysh(cts3) = yp + 10
  336. xsh(cts3 + 1) = xp + 14: ysh(cts3 + 1) = yp + 10
  337. cts3 = cts3 + 2: IF cts3 = 16 THEN cts3 = 10
  338. IF PLAY(0) = 0 AND SND = 1 THEN PLAY SLASER2$
  339.  
  340. REFR.SCREEN:
  341. WAIT &H3DA, 8, 8: WAIT &H3DA, 8
  342. scr = 1 - scr: SCREEN 7, 0, 1 - scr, scr: CLS
  343. REFR.DOCKSCREEN:
  344. WAIT &H3DA, 8, 8: WAIT &H3DA, 8
  345. scr = 1 - scr: SCREEN 7, 0, 1 - scr, scr
  346. VIEW (1, 25)-(318, 198), 0, 0: VIEW
  347.  
  348. MOVE.SHOT:
  349. FOR n = 0 TO shmax: ys = ysh(n)
  350. IF ys < 0 THEN GOTO MOVE.SHOT1
  351.    ys = ys - vsh: ysh(n) = ys
  352. MOVE.SHOT1:
  353.  
  354. MOVE.ENEMY:
  355. emovcnt = 0
  356. FOR n = 0 TO emax
  357. IF ste(n) < 0 THEN GOTO MOVE.ENEMY1
  358. ne(n) = ne(n) - 1: IF ne(n) <= 0 THEN GOSUB LOADPTR.ENEMY
  359.  a! = ae(n) * (pi! / 1800): emovcnt = emovcnt + 1
  360.  dx! = COS(a!) * vec: dy! = -SIN(a!) * vec
  361.  xe!(n) = xe!(n) + dx! / 2: ye!(n) = ye!(n) + dy! / 2
  362.  ae(n) = (ae(n) + dae(n)) MOD 3600
  363.  IF ze(n) < zze(n) THEN ze(n) = ze(n) + 1
  364.  IF ABS(xe!(n) - scx) > 180 OR ABS(ye!(n) - scy) > 120 THEN GOSUB RESET.ENEMY
  365. MOVE.ENEMY1:
  366.  
  367. MOVE.ESHOT:
  368. FOR n = 0 TO esmax
  369. IF stes(n) < 0 THEN GOTO MOVE.ESHOT1
  370.  xes!(n) = xes!(n) + dxes!(n): yes!(n) = yes!(n) + dyes!(n)
  371.  aes(n) = aes(n) + 1
  372.  IF ABS(xes!(n) - scx) > 160 OR ABS(yes!(n) - scy) > 100 THEN stes(n) = -1
  373. MOVE.ESHOT1:
  374.  
  375. DRAW.ESHOT:
  376. FOR n = 0 TO esmax
  377. IF stes(n) < 0 THEN GOTO DRAW.ESHOT1
  378.  x = xes!(n): y = yes!(n): a = aes(n): d = des(n)
  379.  T = tes(n)
  380.  ON T GOSUB DESHOT1, DESHOT2, DESHOT3, DESHOT4, DESHOT5
  381. DRAW.ESHOT1:
  382.  
  383. DESHOT1:
  384. c = 1
  385. LINE (x - 1, y - 2)-(x + 1, y + 2), c, B
  386. LINE (x, y - 3)-(x, y + 3), c
  387. LINE (x, y - 2)-(x, y + 2), 15
  388. DESHOT2:
  389. CIRCLE (x, y), d, 4: PAINT (x, y), 10, 4
  390. DESHOT3:
  391. f! = 1 + SIN(a / 4) * .4: f2! = d * .7
  392. CIRCLE (x, y), d + .5, 7, , , f!
  393. CIRCLE (x, y), d, 15, , , f!
  394. LINE (x - d * .1 / f! - 1, y - d * .3 * f!)-(x - 1, y), 7, B
  395. DESHOT4:
  396. a = (a * 30) MOD 360: z = 4: c = 15: e = 1: GOSUB DRAW.SSPRITE
  397. DESHOT5:
  398. a = (a * 9) MOD 360: z = 4: c = 15: e = 2: GOSUB DRAW.SSPRITE
  399.  
  400. CREATE.ESHOT:
  401. IF STAGE <= 1 THEN RETURN
  402. r = (20 / STAGE) * RND: IF r > 0 THEN RETURN
  403. e = INT((emax + 1) * RND)
  404. IF ye!(e) > 80 OR ste(e) < 0 THEN RETURN
  405. x = xe!(e): y = ye!(e)
  406. T = 1 - (tpe = 10): s = ses(T): GOSUB FIRE.ESHOT
  407. FIRE.ESHOT:
  408. escnt = (escnt + 1) AND esmax: n = escnt
  409. IF stes(n) > -1 THEN RETURN
  410.  xes!(n) = x: yes!(n) = y: v = ves(T)
  411.  a! = pi2! - (pi! / 8) * RND + pi4!: dx! = COS(a!) * v: dy! = SIN(a!) * v
  412.  IF SGN(xp - x) <> SGN(dx!) THEN dx! = -dx!
  413.  dxes!(n) = dx!: dyes!(n) = dy!
  414.  stes(n) = 0: tes(n) = T: aes(n) = 0: des(n) = s
  415. IF PLAY(0) > 0 OR SND = 0 THEN RETURN
  416. ON T GOSUB SESHOT1, SESHOT2, SESHOT3, SESHOT3, SESHOT3
  417.  
  418. SESHOT1:
  419. PLAY SSHOOT2$: RETURN
  420. SESHOT2:
  421. PLAY SSHOOT2$: RETURN
  422. SESHOT3:
  423. PLAY SSHOOT3$: RETURN
  424.  
  425. RESET.STAR:
  426. xst(n) = 320 * RND: yst(n) = 0 * RND: cst(n) = INT(15 * RND) + 1
  427. CREATE.STAR:
  428. xst(n) = 320 * RND: yst(n) = 200 * RND: cst(n) = INT(8 * RND)
  429.  
  430. RESET.ENEMY:
  431. IF tbos = 7 THEN GOSUB RESET.SUPERENEMY
  432. mt = table(tpe)
  433. xe!(n) = xec(mt): ye!(n) = yec(mt): ze(n) = 9
  434. RESET.SUPERENEMY:
  435. IF (n AND 1) = 1 THEN ste(n) = -1
  436.  
  437. CREATE.ENEMY:
  438. n = eptr: eptr = (eptr + 2) AND emax
  439. IF ste(n) <> -1 THEN RETURN
  440. crecnt = crecnt + 1: IF crecnt > cresum THEN RETURN
  441. T = tpe: mt = table(T)
  442. xe!(n) = xec(mt): ye!(n) = yec(mt): ae(n) = aec(mt)
  443. ze(n) = 9: zze(n) = zoome(T)
  444. ste(n) = 0: tpe(n) = T: tce(n) = tce0(mt)
  445. GOSUB LOADPTR.ENEMY
  446. IF PLAY(0) = 0 AND SND = 1 THEN PLAY SNEW1$
  447.  
  448. LOADPTR.ENEMY:
  449. c = tce(n): dae(n) = tae(c): ne(n) = tne(c)
  450. c = c + 1: IF tae(c) = 0 AND tne(c) = 0 THEN c = tce0(mt)
  451. tce(n) = c
  452.  
  453. DRAW.STAR:
  454. dy = (cnt1 AND 1)
  455. FOR n = 0 TO stmax
  456. x = xst(n): y = yst(n): c = cst(n): y = y + dy
  457. IF POINT(x, y) = 0 THEN PSET (x, y), c
  458. yst(n) = y: IF y > 200 THEN GOSUB RESET.STAR
  459. stcnt = (stcnt + 1) AND stmax: n = stcnt
  460. IF INT(2 * RND) = 0 THEN n = stmax * RND: GOSUB CREATE.STAR
  461.  
  462. DRAW.PLAYER:
  463. IF stp > 0 THEN GOTO DRAW.GAMEOVER
  464. IF stp < 0 THEN GOTO DRAW.SHIPEXPLODE
  465. IF ssec(1) = 1 THEN x = xp: y = yp + 0: c = 4: GOSUB DRAW.SHIP1
  466. IF ssec(2) = 1 THEN x = xp: y = yp + 6: c = 9: GOSUB DRAW.SHIP2
  467. IF ssec(3) = 1 THEN x = xp: y = yp + 15: c = 5: GOSUB DRAW.SHIP3
  468.  
  469. DRAW.ESTAR:
  470. FOR n = 0 TO stmax
  471. x = xst(n): y = yst(n): c = cst(n)
  472. x = x + 1: IF x > 320 THEN x = 0: yst(n) = 10 + 180 * RND
  473. PSET (x, y), c: xst(n) = x
  474. c = 12 + INT(4 * RND): IF c = 13 OR c < 12 THEN c = 0
  475. n = stmax * RND: cst(n) = c
  476.  
  477.  
  478. DRAW.SHIPEXPLODE:
  479. stp = stp + 1: IF stp > -10 THEN RETURN
  480. x0 = xp: y0 = yp + 6
  481. IF SND = 1 THEN SOUND 37 + f1! * RND, .5
  482. f1! = f1! * .85
  483. FOR n = 1 TO 5
  484. x = fx!(n): y = fy!(n): a = ft(n): c = fc(n): z = dfx!(n)
  485. e$ = CRASH$(1): GOSUB DRAW.SPRITE
  486. IF bin(2) = 1 THEN GOSUB CREATE.SHIPEXPLODE
  487.  
  488. CREATE.SHIPEXPLODE:
  489. FOR n = 1 TO 5
  490. fx!(n) = x0 + 24 * RND - 12: fy!(n) = y0 + 14 * RND - 7
  491. ft(n) = 360 * RND: c = 12 + INT(4 * RND): IF c = 13 THEN c = 15
  492. fc(n) = c: dfx!(n) = INT(3 * RND) + 2
  493.  
  494. DRAW.SHIP1:
  495. LINE (x, y - 3)-(x - 6, y + 3), c
  496. LINE (x, y - 3)-(x + 6, y + 3), c
  497. LINE (x - 6, y + 4)-(x + 6, y + 4), c
  498. PAINT (x, y), c, c
  499. REM c = SGN(cnt1 AND 8) * 14
  500. LINE (x, y + 0)-(x, y + 2), 14
  501. LINE (x - 5, y + 5)-(x - 5, y + 5), c
  502. LINE (x + 5, y + 5)-(x + 5, y + 5), c
  503. DRAW.SHIP2:
  504. LINE (x - 4, y - 1)-(x + 4, y + 4), c, BF
  505. LINE (x - 10, y - 2)-(x - 9, y + 3), c, B
  506. LINE (x + 9, y - 2)-(x + 10, y + 3), c, B
  507. LINE (x - 9, y + 4)-(x + 9, y + 4), c
  508. LINE (x - 1, y + 0)-(x - 1, y + 2), 14
  509. LINE (x + 1, y + 0)-(x + 1, y + 2), 14
  510. DRAW.SHIP3:
  511. LINE (x - 8, y)-(x - 4, y - 4), c
  512. LINE (x - 4, y - 4)-(x + 4, y - 4), c
  513. LINE (x + 4, y - 4)-(x + 8, y), c
  514. LINE (x - 8, y)-(x - 4, y + 4), c
  515. LINE (x - 4, y + 4)-(x + 4, y + 4), c
  516. LINE (x + 4, y + 4)-(x + 8, y), c
  517. PAINT (x, y), c, c
  518. LINE (x - 13, y)-(x + 13, y), c
  519. LINE (x - 14, y - 4)-(x - 13, y + 3), c, B
  520. LINE (x + 13, y - 4)-(x + 14, y + 3), c, B
  521. PSET (x - 13, y + 3), 0: PSET (x + 13, y + 3), 0
  522. LINE (x - 2, y - 1)-(x - 2, y + 1), 14
  523. LINE (x, y - 1)-(x, y + 1), 14
  524. LINE (x + 2, y - 1)-(x + 2, y + 1), 14
  525.  
  526. DRAW.SHOT:
  527. FOR n = 0 TO shmax: xs = xsh(n): ys = ysh(n)
  528. IF ys < 0 THEN GOTO DRAW.SHOT1
  529.    LINE (xs, ys)-(xs, ys + 3), 14
  530. DRAW.SHOT1:
  531.  
  532. expcnt = 0
  533. FOR n = 0 TO exmax
  534. IF stex(n) = 0 THEN GOTO DRAW.EXP1
  535.    T = tex(n): c = 12 + (cnt1 AND 1) * 4: a = ae(n) / 10
  536.    x = xex(n): y = yex(n): z = zex(n) / 16
  537.    e$ = CRASH$(T): GOSUB DRAW.SPRITE
  538.    ae(n) = (ae(n) + 0) MOD 3600: stex(n) = stex(n) - 1
  539.    expcnt = expcnt + 1
  540. DRAW.EXP1:
  541.  
  542. DRAW.ENEMY:
  543. FOR n = 0 TO emax
  544. s = ste(n): IF s < 0 THEN GOTO DRAW.ENEMY1
  545.  a = ae(n) / 10: z = ze(n) / 16
  546.  x = xe!(n): y = ye!(n)
  547.  e = tpe(n): f = bin(anie(e)) * 2
  548.  c1 = c1e(e): c2 = c2e(e): GOSUB DRAW.ESPRITE
  549. DRAW.ENEMY1:
  550.  
  551. DRAW.GAMEOVER:
  552. stp = stp + 1
  553. IF k = 29 AND stp > 50 THEN GOTO GAME.OVER
  554. IF stp > 400 THEN GOTO GAME.OVER
  555. ac = 0: sc = 4: cc = 15
  556. yc! = 90
  557. xc! = 120: T$ = "GAME": GOSUB DRAW.TXTF
  558. xc! = 168: T$ = "OVER": GOSUB DRAW.TXTF
  559.  
  560. GAME.OVER:
  561. IF SND = 1 THEN PLAY SEND$
  562. GOSUB WAITKEY0
  563. sc = 8: ac = 0
  564. k = INP(96): k$ = INKEY$
  565. GOSUB DRAW.ESTAR
  566. cc = 16 * RND
  567. T$ = "WELL DONE": xc! = 80: yc! = 60: GOSUB DRAW.TXTZ
  568. LOCATE 14, 11
  569. PRINT "SCORE: "; score&; "PTS"
  570. LOOP UNTIL k = 29
  571.  
  572. DRAW.SPRITE:
  573. x$ = LTRIM$(STR$(x)): y$ = LTRIM$(STR$(y))
  574. a$ = LTRIM$(STR$(a)): c$ = LTRIM$(STR$(c))
  575. z$ = LTRIM$(STR$(z))
  576. s$ = "S" + z$ + "TA" + a$ + "C" + c$ + "bm" + x$ + "," + y$ + e$
  577. IF z > 1 THEN s$ = s$ + "P" + c$ + "," + c$
  578. DRAW s$
  579. DRAW.SSPRITE:
  580. x$ = LTRIM$(STR$(x)): y$ = LTRIM$(STR$(y))
  581. a$ = LTRIM$(STR$(a)): c$ = LTRIM$(STR$(c)): z$ = LTRIM$(STR$(z))
  582. s$ = "S" + z$ + "TA" + a$ + "C" + c$ + "bm" + x$ + "," + y$ + SHOT$(e)
  583. DRAW s$
  584. DRAW.ESPRITE:
  585. x$ = LTRIM$(STR$(x)): y$ = LTRIM$(STR$(y))
  586. a$ = LTRIM$(STR$(a)): c1$ = LTRIM$(STR$(c1)): c2$ = LTRIM$(STR$(c2))
  587. z$ = LTRIM$(STR$(z))
  588. e1$ = ENEMY$(e, f): e2$ = ENEMY$(e, f + 1)
  589. s$ = "S" + z$ + "TA" + a$ + "C" + c1$ + "bm" + x$ + "," + y$ + e1$
  590. IF z > 1 THEN s$ = s$ + "P" + c1$ + "," + c1$
  591. s$ = s$ + "C" + c2$ + e2$
  592. IF z > 1 THEN s$ = s$ + "P" + c2$ + "," + c2$
  593. DRAW s$
  594.  
  595. DRAW.PLAYER1:
  596. SCREEN 7, 0, 0, 0: CLS
  597. cc = 15: yc! = 90
  598. xc! = 120: T$ = "PLAYER": GOSUB DRAW.TXT
  599. xc! = 182: i = 1: GOSUB DRAW.INTF
  600.  
  601. TEST.HIT.SHOT:
  602. FOR n = 0 TO shmax: xs = xsh(n): ys = ysh(n)
  603. IF ys < 0 THEN GOTO TEST.HIT.SHOT1
  604.    c = POINT(xs, ys) + POINT(xs, ys + 1) + POINT(xs, ys + 2)
  605.    IF c > 0 THEN GOSUB HIT.SHOT
  606. TEST.HIT.SHOT1:
  607.  
  608. TEST.HIT.PLAYER:
  609. IF stp <> 0 THEN RETURN
  610. c = POINT(xp, yp - 3) + POINT(xp, yp + 2) + POINT(xp - 3, yp) + POINT(xp + 3, yp)
  611. IF c <= 0 THEN RETURN
  612. c1 = POINT(319, 199) * 4
  613. c2 = POINT(0, 0) + POINT(319, 0) + POINT(0, 199) + POINT(319, 199)
  614. IF c1 = c2 AND c1 > 0 THEN RETURN
  615. GOSUB HIT.PLAYER
  616.  
  617. HIT.SHOT:
  618. x! = xs: y! = ys: r1! = hitrad
  619. FOR e = 0 TO emax
  620. IF ste(e) <> 0 THEN GOTO HIT.SHOT1
  621.  dx! = xe!(e) - x!: dy! = ye!(e) - y!
  622.  r! = SQR(dx! * dx! + dy! * dy!)
  623.  IF r! < r1! THEN ysh(n) = -1: GOSUB HIT.ENEMY: EXIT FOR
  624. HIT.SHOT1:
  625. IF stbos < 0 THEN RETURN
  626. dx! = xbos! - x!: dy! = ybos! - y!
  627. rr! = SQR(dx! * dx! + dy! * dy!)
  628. IF rr! < hrbos(tbos) THEN ysh(n) = -1: GOSUB HIT.BOSS
  629.  
  630. HIT.BOSS:
  631. IF PLAY(0) = 0 AND SND = 1 THEN PLAY SHITBOS1$
  632. IF stbos < 0 THEN RETURN
  633. IF stbos = 0 THEN GOTO EXP.BOSS
  634. stbos = stbos - 1: hbos = 1
  635. xex(0) = x!: yex(0) = y!: stex(0) = 12
  636. zex(0) = 32: tex(0) = 2
  637. GOSUB ACTIV.BOSS
  638.  
  639. EXP.BOSS:
  640. stbos = -160: dx = 48: d = 2
  641. IF tbos = 7 THEN dx = 120: d = 4
  642. FOR m = 0 TO exmax
  643. xex(m) = xbos! + dx * RND - dx * .5: yex(m) = ybos! + 32 * RND - 16
  644. stex(m) = 30 + 30 * RND
  645. zex(m) = (3 + INT(d * RND)) * 16: tex(m) = 1
  646. FOR m = 0 TO fmax
  647. fx!(m) = xbos!: fy!(m) = ybos!: a! = pi! * 2 * RND
  648. dfx!(m) = COS(a!) * 4: dfy!(m) = SIN(a!) * 4
  649. fc(m) = 15
  650.  
  651. PLAY.ENEMY.CRASH:
  652. IF T = 1 THEN PLAY SETYPE1$
  653. IF T = 2 THEN PLAY SETYPE2$
  654. IF T = 3 THEN PLAY SETYPE3$
  655. IF T = 4 THEN PLAY SETYPE4$
  656. IF T = 5 THEN PLAY SETYPE1$
  657. IF T = 6 THEN PLAY SETYPE1$
  658. IF T = 7 THEN PLAY SETYPE1$
  659. IF T = 8 THEN PLAY SETYPE8$
  660. IF T = 9 THEN PLAY SETYPE9$
  661. IF T = 10 THEN PLAY SETYPE10$
  662. IF T = 11 THEN PLAY SETYPE11$
  663.  
  664. HIT.ENEMY:
  665. IF PLAY(0) = 0 AND SND = 1 THEN T = tpe(e): GOSUB PLAY.ENEMY.CRASH
  666. ste(e) = -1: GOSUB CREATE.EXP
  667. hitcnt = hitcnt + 1: pts& = ptse(tpe(e)) * STAGE: GOSUB LOAD.SCORE
  668. T = tpe(e)
  669. IF dble(T) = 0 THEN RETURN         ' unteilbar/teilbar
  670. SPLIT.ENEMY:
  671. f = e + 1
  672. ste(e) = 0: ae(e) = 900: ze(e) = zoome(T + 1): zze(e) = ze(e)
  673. ste(f) = 0: ae(f) = 900: ze(f) = zoome(T + 1): zze(f) = ze(f)
  674. tpe(e) = T + 1: tpe(f) = T + 1
  675. mt1 = table(T + 1): mt2 = table(T + 1)
  676. tce(e) = tce0(mt1): tce(f) = tce0(mt2): tce(e) = 72: tce(f) = 88
  677. dae(e) = tae(tce(e)): ne(e) = tne(tce(e))
  678. dae(f) = tae(tce(f)): ne(f) = tne(tce(f))
  679. xe!(f) = xe!(e): ye!(f) = ye!(e)
  680. IF PLAY(0) = 0 AND SND = 1 THEN PLAY SSPLIT$
  681.  
  682. HIT.PLAYER:
  683. REM LOCATE 2, 1: PRINT "HIT ON PLAYER!"
  684. stp = -35: f1! = 600
  685. FOR q = 1 TO 3
  686. IF ssec(q) = 1 THEN ssec(q) = -1: EXIT FOR
  687. GOSUB SETUP.SHIP
  688. x0 = xp: y0 = yp + 6: GOSUB CREATE.SHIPEXPLODE
  689.  
  690. CREATE.EXP:
  691. exptr = (exptr + 1) AND exmax
  692. IF stex(exptr) > 0 THEN RETURN
  693. xex(e) = xe!(e): yex(e) = ye!(e): stex(e) = 30
  694. zex(e) = ze(e): tex(e) = 1
  695.  
  696. LOAD.SCORE:
  697. B& = bonplay&
  698. s& = score&: score& = score& + pts&
  699. IF (score& MOD B&) > (s& MOD B&) THEN RETURN
  700. SCREEN 7, 0, scr, scr
  701. FOR q = 1 TO 3: IF ssec(q) = -1 THEN ssec(q) = 0: EXIT FOR
  702. x = 160: y = 20: c = 4
  703. ON q GOSUB DRAW.SHIP1, DRAW.SHIP2, DRAW.SHIP3
  704. sc = 4: ac = 0: cc = 15
  705. T$ = "BONUS PLAYER": xc! = 178: yc! = 17: GOSUB DRAW.TXTZ
  706. IF ssec(1) = 0 THEN ssec(1) = 1: ssec(2) = 0: ssec(3) = 0: GOSUB SETUP.SHIP
  707. IF SND = 1 THEN PLAY SBONPLAY$
  708. c = 50: GOSUB PAUSE: SCREEN 7, 0, 1 - scr, scr
  709.  
  710. REM  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  711.  
  712. DOCKING:
  713. REM REM PLAY SDOCK1$: DO: LOOP UNTIL PLAY(0) = 0
  714. ss1 = 0: ss2 = 0
  715. IF ssec(1) = 1 THEN ss1 = ss1 OR 1
  716. IF ssec(2) = 1 THEN ss1 = ss1 OR 2
  717. IF ssec(3) = 1 THEN GOTO DOCK.END
  718. IF ssec(3) = 0 THEN ss2 = 4: dp = 5
  719. IF ssec(2) = 0 THEN ss2 = 2: dp = 0
  720. IF ss2 = 0 THEN GOTO DOCK.END
  721. xb = scx: yb = 172
  722. xp! = xb - 30 + 60 * RND: yp! = 100: vxp! = 0: vyp! = 0
  723. dyp! = 0: IF ss1 = 3 THEN dyp! = 6
  724. fcnt = 0: FOR n = 0 TO fmax: ft(n) = -1: NEXT n
  725. grav! = .01 + ss1 * .006
  726. dfuel = 1000: dtime! = 10
  727. FOR n = 0 TO 1: SCREEN 7, 0, n, n: CLS
  728. LOCATE 4, 9: PRINT "Time": LOCATE 4, 27: PRINT "Fuel"
  729. GOSUB DRAW.VALUES: LOCATE 9, 12: PRINT "Docking Sequence"
  730. GOSUB WAITFIRE: timer0! = TIMER + dtime!
  731.  
  732. DOCK.MAIN:
  733. k0 = k: k = INP(96): k$ = INKEY$
  734. IF k = 1 THEN END
  735. IF k = 29 THEN GOSUB THRUST
  736. IF k = 75 THEN vxp! = vxp! - .03
  737. IF k = 77 THEN vxp! = vxp! + .03
  738. vyp! = vyp! + grav!
  739. GOSUB MOVE.SECTION
  740. GOSUB MOVE.FIRE
  741. GOSUB REFR.DOCKSCREEN
  742. WAIT &H3DA, 8: WAIT &H3DA, 8, 8
  743. GOSUB DRAW.SECTION
  744. GOTO TEST.HIT.BASE
  745. DOCK.MAIN1:
  746. dtime! = timer0! - TIMER
  747. GOSUB DRAW.DSTAR
  748. GOSUB DRAW.VALUES: GOSUB DRAW.FIRE
  749. cnt1 = (cnt1 + 1) AND 255
  750. GOTO TEST.DOCK.OUT
  751. GOTO DOCK.MAIN
  752.  
  753. THRUST:
  754. IF dfuel = 0 THEN RETURN
  755. vyp! = vyp! - .07: dfuel = dfuel - 8: IF dfuel < 0 THEN dfuel = 0
  756. IF SND = 1 THEN SOUND 37 + 80 * RND, .3
  757. GOSUB CREATE.FIRE
  758.  
  759. DRAW.DSTAR:
  760. FOR n = 0 TO stmax
  761. x = xst(n): y = yst(n): c = cst(n)
  762. IF POINT(x, y) = 0 THEN PSET (x, y), c
  763. IF cnt1 = 0 THEN RETURN
  764. n = stmax * RND: xst(n) = 300 * RND + 10: yst(n) = 180 * RND + 10
  765.  
  766. TEST.DOCK.OUT:
  767. IF xp! < 0 OR xp! > 319 OR yp! < 32 OR yp! > 199 THEN GOTO DOCK.OUT
  768. IF dtime! < .1 THEN GOTO DOCK.OUT
  769. GOTO DOCK.MAIN
  770.  
  771. DRAW.VALUES:
  772. LOCATE 6, 8: PRINT INT(dtime! * 10) / 10
  773. LOCATE 6, 26: PRINT INT(dfuel / 10)
  774.  
  775. DOCK.END:
  776.  
  777. MOVE.FIRE:
  778. FOR n = 0 TO fmax: IF ft(n) < 0 THEN GOTO MOVE.FIRE1
  779. fx!(n) = fx!(n) + dfx!(n): fy!(n) = fy!(n) + dfy!(n): ft(n) = ft(n) - 1
  780. IF POINT(fx!(n), fy!(n)) = 9 THEN dfy!(n) = -dfy!(n) / 2
  781. MOVE.FIRE1:
  782. CREATE.FIRE:
  783. IF ft(fcnt) >= 0 THEN RETURN
  784. a! = pi2! + 1 * RND - .5: dv! = ABS(pi2! - a!) * 2: v! = 2 - dv!
  785. fx!(fcnt) = xp!: fy!(fcnt) = yp! + 4
  786. dfx!(fcnt) = COS(a!) * v! + vxp!: dfy!(fcnt) = SIN(a!) * v! + vyp!
  787. ft(fcnt) = 8: fc(fcnt) = 14 - INT(2 * RND) * 8
  788. fcnt = (fcnt + 1) AND fmax
  789. DRAW.FIRE:
  790. FOR n = 0 TO fmax: IF ft(n) < 0 THEN GOTO DRAW.FIRE1
  791. x = fx!(n): y = fy!(n): PSET (x, y), fc(n)
  792. DRAW.FIRE1:
  793.  
  794. MOVE.SECTION:
  795. xp! = xp! + vxp!: yp! = yp! + vyp!
  796.  
  797. DRAW.SECTION:
  798. IF (ss1 AND 1) = 1 THEN x = xp!: y = yp! - dyp!: c = 4: GOSUB DRAW.SHIP1
  799. IF (ss1 AND 2) = 2 THEN x = xp!: y = yp!: c = 9: GOSUB DRAW.SHIP2
  800. IF ss2 = 2 THEN x = xb: y = yb: c = 9: GOSUB DRAW.SHIP2
  801. IF ss2 = 4 THEN x = xb: y = yb: c = 5: GOSUB DRAW.SHIP3
  802.  
  803. TEST.HIT.BASE:
  804. n = dp
  805. x = xb + pcx(n): y = yb + pcy(n)
  806. IF POINT(x, y) > 0 THEN GOTO TEST.DOCK.OK
  807. c = 14: IF (cnt1 AND 16) = 0 THEN c = 0
  808. PSET (x, y), c
  809. FOR n = dp + 1 TO dp + 4
  810. x = xb + pcx(n): y = yb + pcy(n)
  811. IF POINT(x, y) > 0 THEN GOTO DOCK.CRASH
  812. REM PSET (x, y), 14
  813. GOTO DOCK.MAIN1
  814.  
  815. TEST.DOCK.OK:
  816. IF ABS(xp! - xb) > 3 THEN GOTO DOCK.CRASH
  817. IF vyp! > .8 THEN GOTO DOCK.CRASH
  818. GOTO DOCK.OK
  819.  
  820. DOCK.OK:
  821. xp! = xb: yp! = yb + pcy(db) - 4
  822. IF (ss1 AND 2) = 2 THEN yp! = yp! - 3
  823. GOSUB REFR.DOCKSCREEN: SCREEN 7, 0, scr, scr: CLS
  824. GOSUB DRAW.VALUES
  825. LOCATE 9, 15: PRINT "Right On !"
  826. IF ss2 = 2 THEN ssec(2) = 1: GOSUB SETUP.SHIP
  827. IF ss2 = 4 THEN ssec(3) = 1: GOSUB SETUP.SHIP
  828. IF SND = 1 THEN PLAY SDOCK2$
  829. DO: LOOP WHILE PLAY(0) > 0: c = 20: GOSUB PAUSE
  830. T = INT(dtime! * 10) / 10: f = dfuel / 10: s = 200 * T + 10 * f
  831. LOCATE 13, 6: PRINT "Bonus = 200 x"; T
  832. LOCATE 15, 6: PRINT "      +  10 x"; f; " ="; s; "x"; STAGE
  833. pts& = s * STAGE: GOSUB LOAD.SCORE
  834. IF SND = 1 THEN PLAY SRGTON$
  835. GOSUB WAITFIRE
  836.  
  837. DOCK.OUT:
  838. SCREEN 7, 0, scr, scr
  839. LOCATE 9, 10: PRINT "Section Out of Range"
  840. GOSUB WAITFIRE
  841.  
  842. DOCK.CRASH:
  843. s = 0: z1 = 4: f1! = 40
  844. FOR n = 1 TO 200
  845. a1 = 3600 * RND: c1 = (s AND 1) * 3 + 12
  846. c2 = 15 - (s AND 1) * 3
  847. IF s = 0 THEN z2 = 3 + 4 * RND: a2 = 3600 * RND: c2 = 15
  848. GOSUB REFR.DOCKSCREEN: GOSUB DRAW.VALUES
  849. LOCATE 9, 13: PRINT "Sorry, no Bonus"
  850. x = xp!: y = yp!: a = a1 / 10: c = c1: z = z1
  851. e$ = CRASH$(1): GOSUB DRAW.SPRITE
  852. x = xb: y = yb: a = a2 / 10: c = c2: z = z2
  853. e$ = CRASH$(1): GOSUB DRAW.SPRITE
  854. s = (s + 1) AND 7
  855. GOSUB DOCK.CRASH.SND
  856. GOSUB WAITFIRE
  857.  
  858. DOCK.CRASH.SND:
  859. f2! = f1! * RND: f1! = f1! * .98
  860. IF n < 150 AND SND = 1 THEN SOUND 37 + f2! * f2!, .3
  861.  
  862. REM - - - - - - - - - - - - - - - - - - - - - - - -
  863.  
  864.  
  865. ADVANCE.LEVEL:
  866. LEVEL = LEVEL + 1
  867. IF STAGE = 6 AND LEVEL = 10 THEN GOTO SUPER.LEVEL
  868. IF LEVEL = 9 THEN GOTO BOSS.LEVEL
  869. IF LEVEL = 10 THEN GOTO WARP.LEVEL
  870. IF LEVEL = 11 THEN GOTO GAME.FINISH
  871. GOSUB LOAD.LEVEL
  872.  
  873. SUPER.LEVEL:
  874. STAGE = 7: GOSUB ENTER.STAGE
  875. tbos = tbos + 1: GOSUB BOSS.LEVEL
  876. stbos = 50
  877. LEVEL = 9: GOSUB LOAD.LEVEL
  878. LEVEL = 10: cresum = 24: hitsum = 24
  879. c1e(6) = 4: c2e(6) = 12
  880. c1e(7) = 12: c2e(7) = 14
  881.  
  882. BOSS.LEVEL:
  883. evcnt = 70: evtpe = 2: evtxt$ = BOSS$(STAGE)
  884. stbos = 8 + tbos * 4: abos = 0
  885. xbos! = scx: ybos! = 50: dxbos! = 0: dybos! = 0
  886. cresum = 0: crecnt = 0: hitcnt = 0: hitsum = 0
  887.  
  888. LOAD.LEVEL:
  889. n = LEVEL
  890. hitrad = lrad(n): tpe = ltpe(n): mt = table(tpe)
  891. vec = vec(mt)
  892. cresum = lsum(n) + (STAGE - 1) * 2
  893. crecnt = 0: hitcnt = 0: hitsum = cresum * lhit(n)
  894. crec0 = crec(mt): crec1 = crec0
  895. s = (STAGE - 1) MOD 3:             REM LOAD COLOR TABLE
  896. FOR e = 1 TO 11: c1e(e) = c1ee(s, e): c2e(e) = c2ee(s, e): NEXT e
  897.  
  898. WARP.LEVEL:
  899. dyp! = .5: dys! = .5: ypp = yp: yp! = yp
  900. f1! = 0
  901. FOR o = 1 TO 260
  902. IF INP(96) = 1 THEN END
  903. GOSUB DRAW.WARPSTAR
  904. GOSUB DRAW.PLAYER
  905. yp = yp!: yp! = yp! - dyp!: dyp! = dyp! * 1.01: dys! = dys! + .1
  906. WAIT &H3DA, 8, 8: WAIT &H3DA, 8
  907. SCREEN 7, 0, 1 - scr, scr: scr = 1 - scr: CLS
  908. IF o > 30 AND o < 150 THEN LOCATE 10, 14: PRINT " WARP OUT ! "
  909. IF o < 180 THEN f1! = f1! + 3
  910. IF o = 180 THEN f1! = 5000
  911. IF o > 60 THEN c1 = 1: c2 = 31: c3 = 2: GOSUB INC.PALETTE
  912. IF o > 180 THEN c1 = 0: c2 = 0: c3 = 4: GOSUB INC.PALETTE: f1! = f1! * .92
  913. IF SND = 1 THEN SOUND 37 + f1! * RND, .3
  914. SCREEN 7, 0, scr, scr: CLS
  915. c1 = 0: c2 = 0: c3 = 4
  916. FOR o = 1 TO 16: WAIT &H3DA, 8: WAIT &H3DA, 8, 8: GOSUB DEC.PALETTE: NEXT o
  917. yp = ypp
  918. REM IF SND = 1 THEN PLAY SFAROUT2$: PLAY SFAROUT2$
  919. REM c = 70: GOSUB PAUSE
  920. REM DO: LOOP UNTIL PLAY(0) < 4
  921. LEVEL = 2: STAGE = STAGE + 1
  922. GOSUB LOAD.LEVEL
  923. tbos = tbos + 1: IF tbos > 6 THEN tbos = 1
  924. c = 20: GOSUB PAUSE
  925. GOSUB ENTER.STAGE
  926.  
  927. ENTER.STAGE:
  928. evcnt = 70: evtpe = 2: evtxt$ = "STAGE " + LTRIM$(STR$(STAGE))
  929. GOSUB LOAD.3DSTAR
  930. SCREEN 7, 0, 2, 0: CLS
  931. xs! = 159: ys! = 160: rs! = 20
  932. ON STAGE GOSUB DSTG1, DSTG2, DSTG3, DSTG4, DSTG5, DSTG6, DSTG7
  933. REM IF SND = 1 THEN PLAY SSTAGE1$
  934.  
  935. ENTER.STAGE1:
  936. xs! = 159: ys! = 99: rs! = 8: rsmax! = 40: cnt = 0
  937. u$ = "STAGE " + LTRIM$(STR$(STAGE)): tptr = 0: mode = 0
  938. sss = -(STAGE > 2 AND STAGE < 7): fs! = 1.02: cnt1 = 10: cnt2 = 0
  939. k = INP(96): k$ = INKEY$
  940. rs! = rs! * fs!: vs! = 1.08
  941. IF rs! >= rsmax! AND mode = 0 THEN rs! = rsmax!: vs! = 1.02
  942. GOSUB ENTER.STAGE2
  943. IF cnt < 160 AND mode = 0 THEN GOSUB ENTER.STAGE3
  944. IF (cnt AND 7) = 7 THEN GOSUB ENTER.STAGE5
  945. cnt = cnt + 1: IF cnt > 300 THEN GOSUB ENTER.STAGE4
  946. IF mode = 1 AND sss = 1 AND SND = 1 THEN SOUND 37 + cnt1 * RND, 1: cnt1 = (cnt1 * 1.2) MOD 32000
  947. IF cnt2 = 4 AND SND = 1 THEN PLAY SSTAGE2$
  948. IF k = 29 AND rs! >= rsmax! THEN GOSUB ENTER.STAGE4
  949. LOOP WHILE rs! < 200
  950.  
  951. ENTER.STAGE2:
  952. IF sss = 0 THEN PCOPY 2, 1 - scr: RETURN
  953. GOSUB DRAW.3DSTAR
  954. ON STAGE - 2 GOSUB DSTG3, DSTG4, DSTG5, DSTG6
  955. ENTER.STAGE3:
  956. T$ = LEFT$(u$, tptr)
  957. xc! = 136: yc! = 24: ac = 0: sc = 4: cc = 15
  958. GOSUB DRAW.TXTZ
  959. T$ = STAGE$(STAGE)
  960. xc! = 159 - LEN(T$) * 4: yc! = 44: ac = 0: sc = 4: cc = 15
  961. s = (cnt AND 8)
  962. IF tptr <= 8 OR s > 0 AND cnt2 < 24 THEN RETURN
  963. GOSUB DRAW.TXTZ: cnt2 = cnt2 + 1
  964. ENTER.STAGE4:                   REM launch
  965. mode = 1: fs! = 1.04: RETURN
  966. ENTER.STAGE5:
  967. tptr = tptr + 1: IF tptr < 8 THEN SOUND 622, 1
  968.  
  969.  
  970. SAVE.PALETTE:
  971. OUT &H3C7, 0
  972. FOR c = 0 TO 95: cp(c) = INP(&H3C9): NEXT c
  973. LOAD.PALETTE:
  974. OUT &H3C8, 0
  975. FOR c = 0 TO 95: OUT &H3C9, cp(c): NEXT c
  976. INC.PALETTE:
  977. FOR c = c1 TO c2: OUT &H3C7, c
  978. a = INP(&H3C9): a = a + c3: IF a > 63 THEN a = 63
  979. B = INP(&H3C9): B = B + c3: IF B > 63 THEN B = 63
  980. d = INP(&H3C9): d = d + c3: IF d > 63 THEN d = 63
  981. OUT &H3C8, c: OUT &H3C9, a: OUT &H3C9, B: OUT &H3C9, d
  982. DEC.PALETTE:
  983. FOR c = c1 TO c2: OUT &H3C7, c
  984. a = INP(&H3C9): a = a - c3: IF a < 0 THEN a = 0
  985. B = INP(&H3C9): B = B - c3: IF B < 0 THEN B = 0
  986. d = INP(&H3C9): d = d - c3: IF d < 0 THEN d = 0
  987. OUT &H3C8, c: OUT &H3C9, a: OUT &H3C9, B: OUT &H3C9, d
  988.  
  989. DRAW.WARPSTAR:
  990. dys = dys!
  991. FOR n = 0 TO stmax
  992. x = xst(n): y = yst(n)
  993. LINE (x, y)-(x, y + dys), cst(n)
  994. y = y + dys: yst(n) = y: IF y > 200 THEN yst(n) = -20: xst(n) = 320 * RND
  995.  
  996.  
  997. REM - - - - - - - - - - - - - - - - - - - - -
  998. REM - - - - - - CREDITS - - - - - - -
  999.  
  1000. GAME.FINISH:
  1001. GOSUB WAITKEY0
  1002. sc = 8: ac = 0: s = 1: GOSUB LOAD.SONG: GOSUB LOAD.3DSTAR
  1003. tcnt = 24: tptr = 0: cnt1 = -100: dy = 24: vs! = 1.06: cnt2 = 120
  1004. k = INP(96): k$ = INKEY$
  1005. GOSUB DRAW.3DSTAR
  1006. d = 2: cc = 13
  1007. IF cnt1 < 0 THEN cnt1 = cnt1 + 1: cc = 16 * RND: d = 0
  1008. IF tptr > 28 THEN d = 0: cnt2 = cnt2 - 1
  1009. IF cnt2 = 0 THEN s = 2: GOSUB LOAD.SONG
  1010. tcnt = tcnt - d
  1011. IF tcnt = 0 THEN tcnt = dy: tptr = tptr + 1
  1012. yc! = tcnt - dy
  1013. FOR n = 1 TO 11
  1014. T$ = CREDIT$(n + tptr)
  1015. xc! = 20: GOSUB DRAW.TXTZ
  1016. yc! = yc! + dy
  1017. WAIT &H3DA, 8: WAIT &H3DA, 8, 8
  1018. GOSUB REFR.SCREEN: GOSUB PLAY.SONG
  1019. LOOP UNTIL (k = 29 AND cnt1 >= 0)
  1020. GOTO GAME.OVER
  1021.  
  1022. LOAD.SONG:
  1023. nsong = s: stsong = 1: tsong = 1: RETURN
  1024.  
  1025. PLAY.SONG:
  1026. IF stsong < 1 THEN RETURN
  1027. PLAY SFINAL$(nsong, tsong)
  1028. tsong = tsong + 1: IF tsong > 7 THEN stsong = 0
  1029.  
  1030. LOAD.3DSTAR:
  1031. FOR n = 0 TO stmax
  1032. x = 26 * RND - 13: y = 20 * RND - 10
  1033. xst!(n) = x * x * SGN(x): yst!(n) = y * y * SGN(y)
  1034. DRAW.3DSTAR:
  1035. FOR n = 0 TO stmax
  1036. x! = xst!(n): y! = yst!(n): c = cst(n)
  1037. r! = SQR(x! * x! + y! * y!)
  1038. x! = x! * vs!: y! = y! * vs!
  1039. IF r! > 160 THEN r! = 2 + 6 * RND: a! = pi! * 2 * RND: x! = COS(a!) * r!: y! = SIN(a!) * r!
  1040. PSET (scx + x!, scy - y!), 15
  1041. xst!(n) = x!: yst!(n) = y!
  1042.  
  1043.  
  1044.  
  1045.  
  1046. REM - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1047. TITLE:
  1048. a = 0: CH = 0: mode1 = 1: mode2 = 6: cnt = 35
  1049. TITLE.MAIN:
  1050. k = INP(96): k$ = INKEY$: IF k = 1 THEN END
  1051. IF k = 29 THEN RETURN
  1052. IF k = 31 THEN SND = 1 - SND: GOSUB WAITKEY0
  1053. IF k = 59 THEN GOSUB TITLE.HELP
  1054. GOSUB CARE.TITLE
  1055. GOSUB CARE.MENU
  1056. GOTO TITLE.MAIN
  1057.  
  1058. CARE.TITLE:
  1059. GOSUB MOVE.TITLE: IF mode1 > 4 THEN RETURN
  1060. cc = 15: GOSUB DRAW.TITLE: GOSUB DRAW.YEAR
  1061. WAIT &H3DA, 8, 8: WAIT &H3DA, 8
  1062. GOSUB REFR.TITLE
  1063.  
  1064. DRAW.TITLE:
  1065. FOR n = 0 TO 7
  1066. nc = nc(n): ac = 0
  1067. xc! = xc!(n): yc! = yc!(n): zc! = zc!(n)
  1068. GOSUB DRAW.CHAR3D
  1069. DRAW.YEAR:
  1070. IF CH < 8 THEN RETURN
  1071. FOR n = 8 TO 9
  1072. nc = nc(n): ac = 0
  1073. xc! = xc!(n): yc! = yc!(n): zc! = zc!(n)
  1074. GOSUB DRAW.CHAR3D
  1075.  
  1076. MOVE.TITLE:
  1077. ON mode1 GOTO MTIT1, MTIT2, MTIT3, MTIT4
  1078. MTIT1:
  1079. zc!(CH) = zc!(CH) - 12: IF zc!(CH) <= zmax AND SND = 1 THEN PLAY SCRASH8$
  1080. IF zc!(CH) <= zmax THEN CH = CH + 1
  1081. IF CH > 7 THEN mode1 = mode1 + 1: cnt = 2000
  1082. MTIT2:
  1083. xc!(8) = xc!(8) - 2: yc!(8) = yc!(8) - 1
  1084. xc!(9) = xc!(9) - 2: yc!(9) = yc!(9) - 1
  1085. SOUND cnt, .4: cnt = cnt - 44
  1086. IF yc!(8) <= yc!(7) + 8 THEN mode1 = mode1 + 1: cnt = 35
  1087. MTIT3:
  1088. cnt = cnt - 1: IF cnt = 34 AND SND = 1 THEN PLAY SCRASH9$
  1089. IF cnt = 0 THEN cnt = 35: mode1 = mode1 + 1
  1090. MTIT4:
  1091. SCREEN 7, 0, scr, scr
  1092. scx = scx - 1: cc = 14: GOSUB DRAW.TITLE
  1093. scx = scx + 2: cc = 14: GOSUB DRAW.TITLE: scx = scx - 1
  1094. scy = scy - 1: cc = 14: GOSUB DRAW.TITLE
  1095. scy = scy + 2: cc = 14: GOSUB DRAW.TITLE: scy = scy - 1
  1096. cc = 4: GOSUB DRAW.TITLE
  1097. mode1 = mode1 + 1: mode2 = 1
  1098. sss = scx
  1099. FOR scx = sss - 2 TO sss + 2: cc = 15: GOSUB DRAW.YEAR: NEXT scx
  1100. x = 214: y = 15
  1101. CIRCLE (x, y), 5, 15: PAINT (x, y), 15, 15
  1102. CIRCLE (x - 3, y - 1), 5, 1: PAINT (x - 3, y - 1), 1, 1
  1103.  
  1104. REFR.TITLE:
  1105. SCREEN 7, 0, scr, 1 - scr: scr = 1 - scr
  1106. LINE (0, 0)-(319, 120), 0, BF
  1107.  
  1108. CARE.MENU:
  1109. IF mode2 < 6 THEN GOTO DRAW.MENU
  1110. DRAW.MENU:
  1111. WAIT &H3DA, 8, 8: WAIT &H3DA, 8
  1112. ON mode2 GOTO DMEN1, DMEN2, DMEN3, DMEN4, DMEN5
  1113. DMEN1:
  1114. cnt = cnt - 1: IF cnt = 0 THEN cnt = 35: mode2 = mode2 + 1
  1115. DMEN2:
  1116. SCREEN 7, 0, scr, scr
  1117. x = 40: y = 66: a = 90: c1 = 8: c2 = 15: f = 0: z = 4
  1118. FOR e = 1 TO 5: GOSUB DRAW.ESPRITE: REM PSET (x, y), 10
  1119. y = y + 18: NEXT e
  1120. mode2 = mode2 + 1: x = 58
  1121. DMEN3:
  1122. IF (x AND 7) > 0 THEN GOTO DMEN31
  1123. y = 70: c1 = 15
  1124. FOR e = 1 TO 5
  1125. REM LINE (x, y)-(x + 1, y + 1), 7, BF
  1126. REM PSET (x, y + 1), 15: PSET (x + 1, y), 8
  1127. LINE (x, y)-(x + 1, y), 8
  1128. LINE (x, y + 1)-(x + 1, y + 1), 15
  1129. y = y + 18: NEXT e
  1130. DMEN31:
  1131. x = x + 1: IF x >= 208 THEN mode2 = mode2 + 1
  1132. DMEN4:
  1133. ac = 0: sc = 4: cc = 15: yc! = 64
  1134. FOR e = 1 TO 5
  1135. i = ptse(e): xc! = 220: GOSUB DRAW.INTF
  1136. T$ = "PTS": xc! = 234: GOSUB DRAW.TXTF: yc! = yc! + 18
  1137. ac = 0: sc = 4: cc = 7
  1138. xc! = 54: yc! = 162: T$ = "PRESS F1 FOR BRIEFING": GOSUB DRAW.TXTZ
  1139. mode2 = mode2 + 1
  1140. DMEN5:
  1141. ac = 0: sc = 4: cc = 16 * RND
  1142. xc! = 100: yc! = 180: T$ = "PRESS FIRE": GOSUB DRAW.TXTZ
  1143.  
  1144.  
  1145. REM - - - - - - - - - - - - - - - - -
  1146.  
  1147. DRAW.CHAR3D:
  1148. zf! = 100 / zc!: sc = zf! * 4
  1149. xd = INT(scx + xc! * zf!): yd = INT(scy - yc! * zf!)
  1150. x$ = LTRIM$(STR$(xd)): y$ = LTRIM$(STR$(yd))
  1151. ta$ = LTRIM$(STR$(ac)): c$ = LTRIM$(STR$(cc))
  1152. zs$ = LTRIM$(STR$(sc))
  1153. s$ = "TA" + ta$ + "S" + zs$ + "C" + c$ + "bm" + x$ + "," + y$ + CH$(nc)
  1154. DRAW s$
  1155.  
  1156. DRAW.CHAR:
  1157. xd = xc!: yd = yc!
  1158. x$ = LTRIM$(STR$(xd)): y$ = LTRIM$(STR$(yd))
  1159. ta$ = LTRIM$(STR$(ac)): c$ = LTRIM$(STR$(cc))
  1160. zs$ = LTRIM$(STR$(sc))
  1161. s$ = "TA" + ta$ + "S" + zs$ + "C" + c$ + "bm" + x$ + "," + y$ + CH$(nc)
  1162. DRAW s$
  1163.  
  1164. DRAW.FCHAR:
  1165. xd = xc!: yd = yc!
  1166. x$ = LTRIM$(STR$(xd)): y$ = LTRIM$(STR$(yd))
  1167. ta$ = LTRIM$(STR$(ac)): c$ = LTRIM$(STR$(cc))
  1168. zs$ = LTRIM$(STR$(sc))
  1169. s$ = "TA" + ta$ + "S" + zs$ + "C" + c$ + "bm" + x$ + "," + y$ + CH$(nc)
  1170. DRAW s$: x$ = LTRIM$(STR$(xd - 1))
  1171. s$ = "TA" + ta$ + "S" + zs$ + "C" + c$ + "bm" + x$ + "," + y$ + CH$(nc)
  1172. DRAW s$: x$ = LTRIM$(STR$(xd + 1))
  1173. s$ = "TA" + ta$ + "S" + zs$ + "C" + c$ + "bm" + x$ + "," + y$ + CH$(nc)
  1174. DRAW s$
  1175.  
  1176. DRAW.INTF:
  1177. sc = 4: x! = xc!: ac = 0: sc = 4
  1178. FOR m = 0 TO 5
  1179. nc = i MOD 10
  1180. GOSUB DRAW.FCHAR
  1181. xc! = xc! - 10: i = INT(i / 10): IF i = 0 THEN EXIT FOR
  1182. NEXT m: xc! = x!
  1183.  
  1184. DRAW.TXTF:
  1185. sc = 4: l = LEN(T$)
  1186. FOR m = 1 TO l
  1187. nc = ASC(MID$(T$, m, 1)) - 48
  1188. GOSUB DRAW.FCHAR
  1189. xc! = xc! + 9
  1190.  
  1191. DRAW.TXT:
  1192. sc = 4: l = LEN(T$)
  1193. FOR m = 1 TO l
  1194. nc = ASC(MID$(T$, m, 1)) - 48
  1195. GOSUB DRAW.CHAR
  1196. xc! = xc! + 9
  1197.  
  1198. DRAW.TXTZ:
  1199. l = LEN(T$)
  1200. FOR m = 1 TO l: nc = ASC(MID$(T$, m, 1)) - 48
  1201. IF nc >= 0 THEN GOSUB DRAW.CHAR
  1202. xc! = xc! + sc * 2
  1203.  
  1204. WAITKEY0:
  1205. DO: k = INP(96): k$ = INKEY$: LOOP WHILE k < 128
  1206.  
  1207. PAUSE.MODE:
  1208. GOSUB WAITKEY0: SCREEN 7, 0, scr, scr
  1209. LOCATE 11, 16: COLOR 14: PRINT "- PAUSE -"
  1210. DO: k$ = INKEY$: k = INP(96): LOOP UNTIL k = 25
  1211. GOSUB WAITKEY0
  1212.  
  1213. REM - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1214.  
  1215. DBOSS1:
  1216. c1 = 13: c2 = 12: IF hbos = 1 THEN c1 = 15: c2 = 15
  1217. LINE (x - 10, y - 25)-(x, y - 32), 1
  1218. LINE (x, y - 32)-(x + 10, y - 25), 1
  1219. LINE (x - 10, y - 25)-(x + 10, y - 25), 1
  1220. PAINT (x, y - 30), c1, 1
  1221. LINE (x - 16, y)-(x, y + 16), 5
  1222. LINE (x, y + 16)-(x + 16, y), 5
  1223. LINE (x - 16, y)-(x + 16, y), 5
  1224. PAINT (x, y + 8), c1, 5
  1225. LINE (x, y + 15)-(x + 15, y), 5
  1226. LINE (x - 15, y)-(x, y + 15), 5
  1227. CIRCLE (x, y), 30, 5, -pi! * 2, -pi!, .85
  1228. PAINT (x, y - 10), c2, 5
  1229. CIRCLE (x - 11, y - 17), 4, 14: PAINT (x - 11, y - 17), 15, 14
  1230. CIRCLE (x + 10, y - 12), 8, 14: PAINT (x + 10, y - 12), 15, 14
  1231. CIRCLE (x - 15, y), 8, 14, -pi! * 2, -pi!, .85: PAINT (x - 15, y - 4), 15, 14
  1232. CIRCLE (x + 30, y), 8, 14, -pi! * .55, -pi!, .85: PAINT (x + 26, y - 3), 15, 14
  1233. s = SIN(cnt1 / 1) * 20 + 30
  1234. IF PLAY(0) = 0 AND s > 37 THEN SOUND s, .2
  1235.  
  1236. DBOSS2:
  1237. c1 = 6: c2 = 14: IF hbos = 1 THEN c1 = 15
  1238. s = SGN(dybos!)
  1239. IF s > 0 THEN abos = abos + 2
  1240. IF s = 0 THEN abos = abos + 15
  1241. IF s < 0 THEN abos = abos + 30
  1242. dy1 = SIN(abos / 100) * 5: dy2 = SIN(abos / 100) * 10
  1243. LINE (x, y - 9)-(x + 20, y - 6 + dy1), c1
  1244. LINE (x + 20, y - 6 + dy1)-(x + 32, y - 1 + dy2), c1
  1245. LINE (x + 32, y - 1 + dy2)-(x + 32, y + 3 + dy2), c1
  1246. LINE (x + 32, y + 3 + dy2)-(x, y + 7), c1
  1247. LINE (x, y + 7)-(x - 32, y + 3 + dy2), c1
  1248. LINE (x - 32, y + 3 + dy2)-(x - 32, y - 1 + dy2), c1
  1249. LINE (x - 32, y - 1 + dy2)-(x - 20, y - 6 + dy1), c1
  1250. LINE (x - 20, y - 6 + dy1)-(x, y - 9), c1
  1251. PAINT (x, y), c1, c1
  1252. yy! = y + 4: dy! = dy2 / 7
  1253. FOR xx = 2 TO 32 STEP 4
  1254. x1 = x + xx: x2 = x - xx
  1255. LINE (x1, yy!)-(x1 + 1, yy! + 5), c1, B
  1256. LINE (x2 - 1, yy!)-(x2, yy! + 5), c1, B
  1257. yy! = yy! + dy!
  1258. NEXT xx
  1259. LINE (x, y - 9)-(x - 6, y - 3), c2
  1260. LINE (x - 6, y - 3)-(x, y + 12), c2
  1261. LINE (x, y + 12)-(x + 6, y - 3), c2
  1262. LINE (x + 6, y - 3)-(x, y - 9), c2
  1263. PAINT (x, y), c2, c2
  1264. CIRCLE (x, y - 13), 4, c1, , , 1: PAINT (x, y - 13), c2, c1
  1265. LINE (x, y + 11)-(x - 11, y + 23), c1
  1266. LINE (x - 11, y + 23)-(x, y + 19), c1
  1267. LINE (x, y + 19)-(x + 11, y + 23), c1
  1268. LINE (x + 11, y + 23)-(x, y + 11), c1
  1269. PAINT (x, y + 16), c2, c1
  1270. LINE (x - 1, y - 11)-(x + 1, y - 11), c1
  1271. PSET (x - 4, y - 17), c1
  1272. PSET (x + 4, y - 17), c1
  1273. LINE (x - 2, y - 14)-(x + 2, y - 14), c1
  1274. LINE (x - 2, y - 11)-(x - 2, y - 10), 0
  1275. LINE (x + 2, y - 11)-(x + 2, y - 10), 0
  1276.  
  1277. DBOSS3:
  1278. c1 = 6: c2 = 14: IF hbos = 1 THEN c1 = 15: c2 = 15
  1279. c3 = 4: abos = abos + 1: d = abos AND 63
  1280. IF d < 4 THEN c3 = 15 - d / 2
  1281. LINE (x, y - 6)-(x + 7, y - 7), c1
  1282. LINE (x + 7, y - 7)-(x + 12, y - 10), c1
  1283. LINE (x + 12, y - 10)-(x + 20, y - 7), c1
  1284. LINE (x + 20, y - 7)-(x + 24, y + 1), c1
  1285. LINE (x + 24, y + 1)-(x + 25, y + 9), c1
  1286. LINE (x + 25, y + 9)-(x + 20, y + 16), c1
  1287. LINE (x + 19, y + 16)-(x + 15, y + 7), c1
  1288. LINE (x + 15, y + 7)-(x + 6, y + 2), c1
  1289. LINE (x + 6, y + 2)-(x, y + 6), c1
  1290. LINE (x, y - 6)-(x - 7, y - 7), c1
  1291. LINE (x - 7, y - 7)-(x - 12, y - 10), c1
  1292. LINE (x - 12, y - 10)-(x - 20, y - 7), c1
  1293. LINE (x - 20, y - 7)-(x - 24, y + 1), c1
  1294. LINE (x - 24, y + 1)-(x - 25, y + 9), c1
  1295. LINE (x - 25, y + 9)-(x - 20, y + 16), c1
  1296. LINE (x - 19, y + 16)-(x - 15, y + 7), c1
  1297. LINE (x - 15, y + 7)-(x - 6, y + 2), c1
  1298. LINE (x - 6, y + 2)-(x, y + 6), c1
  1299.  
  1300. LINE (x + 18, y + 11)-(x + 24, y + 9), c1
  1301. PAINT (x + 20, y + 13), c2, c1
  1302. LINE (x - 18, y + 11)-(x - 24, y + 9), c1
  1303. PAINT (x - 20, y + 13), c2, c1
  1304. PAINT (x, y), 2, c1
  1305. LINE (x + 3, y)-(x + 5, y - 2), c3
  1306. LINE (x - 3, y)-(x - 5, y - 2), c3
  1307. LINE (x + 6, y + 2)-(x, y + 6), 4
  1308. LINE (x - 6, y + 2)-(x, y + 6), 4
  1309.  
  1310. DBOSS4:
  1311. c1 = 9: c2 = 11: c3 = 15: IF hbos = 1 THEN c1 = 15
  1312. CIRCLE (x, y), 30, c1, 0, pi!, .85
  1313. CIRCLE (x, y), 30, c1, pi!, pi! * 2, .1
  1314. PAINT (x, y - 10), 0, c1
  1315. abos = (abos + 1) AND 255
  1316. FOR xx = x - 24 TO x + 24 STEP 5
  1317. a1! = abos + xx + 1: r1! = SIN(a1! / 4.33)
  1318. a2! = abos + xx + 2: r2! = SIN(a2! / 3.97)
  1319. a3! = abos + xx + 3: r3! = SIN(a3! / 3.67)
  1320. yy = y - 4 - r2!: f1 = 40 - ABS(xx - x): f2 = f1 / 5
  1321. x1 = xx + f2 * r1!: x2 = xx + f2 * r2!: x3 = xx + f2 * r3!
  1322. LINE (xx, yy)-(x1, yy + 16), c2
  1323. LINE (x1, yy + 16)-(x2, yy + 30), c2
  1324. LINE (x2, yy + 30)-(x3, yy + 30 + f2 * 2), c2
  1325. NEXT xx
  1326. CIRCLE (x, y), 30, c3, 0, pi!, .1
  1327.  
  1328. DBOSS5:
  1329. c1 = 9: dy = 0: abos = abos + 1
  1330. IF (abos AND 63) > 40 THEN dy = 1
  1331. IF hbos = 1 THEN c1 = 15: dy = -2
  1332. CIRCLE (x, y), 20, c1, , , .6
  1333. PAINT (x, y), c1, c1
  1334. LINE (x - 6, y - 12)-(x + 11, y - 24), c1
  1335. LINE (x + 11, y - 24)-(x + 8, y - 14), c1
  1336. LINE (x + 8, y - 14)-(x + 16, y - 8), c1
  1337. PAINT (x + 3, y - 16), c1, c1
  1338. LINE (x - 7, y + 12)-(x + 2, y + 20), c1
  1339. LINE (x + 2, y + 20)-(x + 7, y + 12), c1
  1340. PAINT (x, y + 16), c1, c1
  1341. LINE (x + 18, y)-(x + 40, y - 12), c1
  1342. LINE (x + 18, y)-(x + 40, y + 12), c1
  1343. LINE (x + 40, y - 12)-(x + 36, y), c1
  1344. LINE (x + 36, y)-(x + 40, y + 12), c1
  1345. PAINT (x + 24, y), c1, c1
  1346. CIRCLE (x - 7, y - 4), 5, 15, , , .9: PAINT (x - 7, y - 4), 15, 15
  1347. CIRCLE (x - 7, y - 4 + dy), 2, 0, , , .9: PAINT (x - 7, y - 4 + dy), 0, 0
  1348.  
  1349. DBOSS6:
  1350. a = ((abos MOD 7) - 3) * 12: abos = abos + 1
  1351. c1 = 6: c2 = 14: c3 = 11: IF hbos = 1 THEN c1 = 15
  1352. a! = a * pi! / 180: r = 20: s = 1
  1353. FOR q = -2 TO 1
  1354. s = SGN(q + .5): a! = -a!
  1355. x1 = COS(a!) * r * s: y1 = SIN(a!) * r
  1356. CIRCLE (x + x1, y - y1), 8, c3: PAINT (x + x1, y - y1), c3, c3
  1357. x2 = COS(a! - .36) * r * s: y2 = SIN(a! - .36) * r
  1358. LINE (x, y)-(x + x2, y - y2), c3
  1359. x3 = COS(a! + .36) * r * s: y3 = SIN(a! + .36) * r
  1360. LINE (x, y)-(x + x3, y - y3), c3
  1361. PAINT (x + x1 * .4, y - y1 * .4), c3, c3
  1362. CIRCLE (x, y), 11, c1, , , 1.2: PAINT (x, y), c1, c1
  1363. CIRCLE (x, y - 12), 8, c1, -pi! * 1.9, -pi! * 1.1, .8
  1364. PAINT (x, y - 14), c1, c1
  1365. CIRCLE (x - 5, y - 14), 4, 7, , , .8
  1366. PAINT (x - 5, y - 14), A5$, 7
  1367. CIRCLE (x + 5, y - 14), 4, 7, , , .8
  1368. PAINT (x + 5, y - 14), A5$, 7
  1369. LINE (x - 8, y - 3)-(x + 8, y - 1), c2, BF
  1370. LINE (x - 7, y + 4)-(x + 7, y + 6), c2, BF
  1371. c = cnt1 AND 127
  1372. IF PLAY(0) = 0 AND SND = 1 AND c < 32 THEN SOUND 1600 + 200 * RND, .6
  1373.  
  1374. DBOSS7:
  1375. c1 = 4: c2 = 12: abos = abos + 1: s = SGN(abos AND 16) * 10
  1376. c3 = 4: IF hbos = 1 THEN c3 = 15
  1377. IF stbos < 12 THEN c3 = 1
  1378. c4 = csb(stbos / 16)
  1379. CIRCLE (x - 32, y - 14), 4, 2, , , 1
  1380. CIRCLE (x, y - 12), 20, 15
  1381. CIRCLE (x + 32, y - 14), 4, 2, , , 1
  1382. CIRCLE (x, y - 13), 7, 15, -pi! * 2, -pi!
  1383. PAINT (x, y - 14), c4, 15
  1384. PAINT (x - 32, y - 15), s, 2
  1385. PAINT (x + 32, y - 15), 10 - s, 2
  1386. LINE (x - 50, y - 10)-(x + 50, y - 10), c1
  1387. LINE (x - 25, y + 10)-(x + 25, y + 10), c1
  1388. LINE (x - 50, y - 10)-(x - 80, y), c1
  1389. LINE (x - 80, y)-(x - 80, y + 4), c1
  1390. LINE (x - 80, y + 4)-(x - 25, y + 10), c1
  1391. LINE (x + 50, y - 10)-(x + 80, y), c1
  1392. LINE (x + 80, y)-(x + 80, y + 4), c1
  1393. LINE (x + 80, y + 4)-(x + 25, y + 10), c1
  1394. PAINT (x, y), c1, c1
  1395. PAINT (x - 40, y), c1, c1: PAINT (x + 40, y), c1, c1
  1396. LINE (x - 40, y - 13)-(x - 43, y - 11), c1
  1397. LINE (x - 40, y - 13)-(x + 40, y - 13), c1
  1398. LINE (x + 40, y - 13)-(x + 43, y - 11), c1
  1399. PAINT (x, y - 12), c2, c1
  1400. LINE (x - 80, y - 1)-(x + 80, y + 3), 14, BF
  1401. xx = x - 88 + (abos MOD 24)
  1402. FOR q = 1 TO 7
  1403. LINE (xx, y - 1)-(xx + 11, y + 3), 0, BF
  1404. xx = xx + 24
  1405. LINE (x - 80, y + 4)-(x - 25, y + 10), c3
  1406. LINE (x - 25, y + 10)-(x + 25, y + 10), c3
  1407. LINE (x + 80, y + 4)-(x + 25, y + 10), c3
  1408.  
  1409. REM  - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1410.  
  1411. DSTG1:
  1412. a1! = pi! - .7
  1413. FOR n = 1 TO 21
  1414. r1 = 400 + 20 * RND
  1415. x1 = COS(a1!) * r1 + 300: y1 = 450 - SIN(a1!) * r1
  1416. FOR m = 1 TO 20
  1417.  a2! = pi! * 2 * RND
  1418.  r = 36 * RND: x2 = x1 + COS(a2!) * r: y2 = y1 + SIN(a2!) * r
  1419.  PSET (x2, y2), 1
  1420.  r = 28 * RND: x2 = x1 + COS(a2!) * r: y2 = y1 + SIN(a2!) * r
  1421.  PSET (x2, y2), 9
  1422.  r = 16 * RND: x2 = x1 + COS(a2!) * r: y2 = y1 + SIN(a2!) * r
  1423.  PSET (x2, y2), 11
  1424.  r = 12 * RND: x2 = x1 + COS(a2!) * r: y2 = y1 + SIN(a2!) * r
  1425.  PSET (x2, y2), 15
  1426. a1! = a1! - .05
  1427.  
  1428. DSTG2:
  1429. c1 = 11: c2 = 9: c3 = 1
  1430. FOR n = 1 TO 32
  1431. x = 320 * RND: y = 200 * RND
  1432. c = 12 + INT(4 * RND): IF c = 13 THEN c = 4
  1433. PSET (x, y), c
  1434. x = 169: y = 109
  1435. CIRCLE (x, y), 36, 9, , , 1
  1436. CIRCLE (x, y), 37, 1, , , .94
  1437. CIRCLE (x - 19, y - 16), 18, c1, pi2! * 3, pi2! * 4
  1438. CIRCLE (x + 19, y - 16), 18, c1, pi2! * 2, pi2! * 3
  1439. CIRCLE (x - 19, y + 16), 18, c1, pi2! * 0, pi2! * 1
  1440. CIRCLE (x + 19, y + 16), 18, c1, pi2! * 1, pi2! * 2
  1441. LINE (x, y - 17)-(x, y - 50), c1
  1442. LINE (x, y + 17)-(x, y + 42), c1
  1443. LINE (x - 20, y)-(x - 48, y), c1
  1444. LINE (x + 20, y)-(x + 44, y), c1
  1445. LINE (x, y - 40)-(x, y - 50), c2
  1446. LINE (x, y + 40)-(x, y + 45), c2
  1447. LINE (x - 34, y)-(x - 48, y), c2
  1448. LINE (x + 34, y)-(x + 44, y), c2
  1449. LINE (x, y - 50)-(x, y - 54), c3
  1450. LINE (x, y + 45)-(x, y + 50), c3
  1451. LINE (x - 48, y)-(x - 52, y), c3
  1452. LINE (x + 44, y)-(x + 48, y), c3
  1453. PAINT (x, y), 15, c1
  1454.  
  1455. DSTG3:
  1456. x = xs!: y = ys!: r1 = rs!: rsmax! = 30
  1457. c1 = 4: c2 = 14: c3 = 4: a2! = 0
  1458.  
  1459. a2! = a2! + .03
  1460. r2 = 0: n = 0: a! = 0
  1461. FOR a! = 0 TO pi! * 2 STEP .2
  1462.  x0 = x1: y0 = y1
  1463.  f = (r1 / 6) * RND: a1! = a! + .1 * RND
  1464.  r = r1 + r2 * f: r2 = 1 - r2
  1465.  x1 = SIN(a1! + a2!) * r + x: y1 = COS(a1! + a2!) * r + y
  1466.  IF n = 0 THEN x2 = x1: y2 = y1
  1467.  IF n > 0 THEN LINE (x0, y0)-(x1, y1), c1
  1468.  n = n + 1
  1469. NEXT a!
  1470. LINE (x1, y1)-(x2, y2), c1
  1471. PAINT (x, y), c2, c1
  1472. CIRCLE (x, y), r1 - 2, c3, , , 1
  1473. PAINT (x, y), 0, c3
  1474.  
  1475.  
  1476. DSTG4:
  1477. x = xs!: y = ys!: r1 = rs!: rsmax! = 60
  1478. c1 = 1: c2 = 9: c3 = 11: c4 = 11
  1479.  
  1480. CIRCLE (x, y), r1, c1
  1481. CIRCLE (x, y), r1, c2, pi2! * 3, pi2!
  1482.  
  1483. CIRCLE (x, y), r1 * .84, c1, pi2!, pi2! * 3, 3
  1484. PAINT (x - r1 * .5, y), c1, c1
  1485. CIRCLE (x, y), r1 * .84, c2, pi2!, pi2! * 3, 3
  1486. PAINT (x + r1 * .5, y), c2, c2
  1487.  
  1488. x1 = x - r1 * .36: y1 = y - r1 * .16
  1489. CIRCLE (x1, y1), r1 * .16, c2, , , .7: PAINT (x1, y1), c2, c2
  1490. x1 = x - r1 * .8: y1 = y - r1 * .05
  1491. CIRCLE (x1, y1), r1 * .16, c2, , , 1.8: PAINT (x1, y1), c2, c2
  1492. x1 = x - r1 * .6: y1 = y + r1 * .05
  1493. CIRCLE (x1, y1), r1 * .2, c2, , , 1: PAINT (x1, y1), c2, c2
  1494. x1 = x - r1 * .3: y1 = y + r1 * .1
  1495. CIRCLE (x1, y1), r1 * .3, c2: PAINT (x1, y1), c2, c2
  1496. x1 = x - r1 * .3: y1 = y + r1 * .1
  1497. CIRCLE (x1, y1), r1 * .3, c3, -pi2! * 3.1, -pi2! * .95
  1498. PAINT (x1 + r1 * .1, y1), c3, c3
  1499.  
  1500. x1 = x + r1 * .24: y1 = y - r1 * .5
  1501. CIRCLE (x1, y1), r1 * .16, c3, , , .8: PAINT (x1, y1), c3, c3
  1502. x1 = x + r1 * .33: y1 = y - r1 * .3
  1503. CIRCLE (x1, y1), r1 * .2, c3, , , .9: PAINT (x1, y1), c3, c3
  1504. x1 = x + r1 * .46: y1 = y - r1 * .46
  1505. CIRCLE (x1, y1), r1 * .14, c3, , , .9: PAINT (x1, y1), c3, c3
  1506.  
  1507. x1 = x + r1 * .02: y1 = y + r1 * .75
  1508. CIRCLE (x1, y1), r1 * .12, c3, , , .4: PAINT (x1, y1), c3, c3
  1509. x1 = x + r1 * .07: y1 = y + r1 * .67
  1510. CIRCLE (x1, y1), r1 * .15, c3, , , .4: PAINT (x1, y1), c3, c3
  1511. x1 = x + r1 * .2: y1 = y + r1 * .6
  1512. CIRCLE (x1, y1), r1 * .15, c3, , , .66: PAINT (x1, y1), c3, c3
  1513.  
  1514. x1 = x + r1 * .9: y1 = y + r1 * .02
  1515. CIRCLE (x1, y1), r1 * .14, c3, , , 3: PAINT (x1, y1), c3, c3
  1516. x1 = x + r1 * .7: y1 = y + r1 * .13
  1517. CIRCLE (x1, y1), r1 * .17, c3, , , 1.2: PAINT (x1, y1), c3, c3
  1518.  
  1519. x1 = x - r1 * .01: y1 = y - r1 * .8
  1520. CIRCLE (x1, y1), r1 * .12, c3, -pi2! * 2.5, -pi2! * 1.3, .2: PAINT (x1 + r1 * .06, y1), c3, c3
  1521. x1 = x - r1 * .08: y1 = y - r1 * .8
  1522. CIRCLE (x1, y1), r1 * .12, c2, -pi2! * 1, -pi2! * 2.8, .2
  1523. PAINT (x1 - r1 * .04, y1), c2, c2
  1524.  
  1525. CIRCLE (x, y), r1, c4, pi2! * .28, pi2! * .7
  1526.  
  1527.  
  1528. DSTG5:
  1529. x = xs!: y = ys!: r1 = rs!: rsmax! = 50
  1530. c1 = 6: c2 = 4: c3 = 12: c4 = 4
  1531. a1! = pi2! * 2: a2! = pi2! * 4: f! = .2
  1532. CIRCLE (x, y), r1, c2
  1533. PAINT (x, y), c1, c2
  1534. CIRCLE (x, y - r1 * .8), r1 * .2, c2, a1!, a2!, f!
  1535. CIRCLE (x, y - r1 * .7), r1 * .5, c2, a1!, a2!, f!
  1536. CIRCLE (x, y - r1 * .56), r1 * .74, c2, a1!, a2!, f!
  1537. CIRCLE (x, y - r1 * .4), r1 * .89, c2, a1!, a2!, f!
  1538. CIRCLE (x, y - r1 * .32), r1 * .93, c2, a1!, a2!, f!
  1539. CIRCLE (x, y - r1 * .16), r1 * .98, c2, a1!, a2!, f!
  1540. CIRCLE (x, y + r1 * .06), r1 * 1, c2, a1!, a2!, f!
  1541. CIRCLE (x, y + r1 * .29), r1 * .94, c2, a1!, a2!, f!
  1542. CIRCLE (x, y + r1 * .42), r1 * .87, c2, a1!, a2!, f!
  1543. CIRCLE (x, y + r1 * .6), r1 * .69, c2, a1!, a2!, f!
  1544. PAINT (x, y - r1 * .16), c2, c2
  1545. PAINT (x, y + r1 * .38), c2, c2
  1546. PAINT (x, y + r1 * .78), c2, c2
  1547. CIRCLE (x, y), r1, c3, pi2! * .2, pi2! * 1.4
  1548. a1! = pi2! * 1.5: a2! = pi2! * .5
  1549. CIRCLE (x, y + r1 * .04), r1 * 1.6, c4, pi2! * 1.42, pi2! * .58, f!
  1550. CIRCLE (x, y + r1 * .04), r1 * 1.76, c1, pi2! * 1.36, pi2! * .64, f!
  1551. CIRCLE (x, y + r1 * .04), r1 * 1.8, c4, pi2! * 1.36, pi2! * .64, f!
  1552.  
  1553.  
  1554. DSTG6:
  1555. x = xs!: y = ys!: r1 = rs!: rsmax! = 60
  1556. c1 = 8: c2 = 7: c3 = 15: c4 = 8
  1557. a1! = -pi2! * 1.1: a2! = -pi2! * 3 * .9
  1558.  
  1559. CIRCLE (x, y), r1, c1
  1560. CIRCLE (x, y), r1, c2, pi2!, pi2! * 3
  1561.  
  1562. CIRCLE (x, y), r1 * .84, c2, pi2! * 3, pi2!, 1.6
  1563. PAINT (x - r1 * .5, y), c2, c2
  1564. CIRCLE (x, y), r1 * .84, c1, pi2! * 3, pi2!, 1.6
  1565. PAINT (x + r1 * .8, y), c1, c1
  1566.  
  1567. x1 = x - r1 * .25: y1 = y - r1 * .2
  1568. CIRCLE (x1, y1), r1 * .24, c1: PAINT (x1, y1), c1, c1
  1569. CIRCLE (x1, y1), r1 * .24, c3, a1!, a2!: PAINT (x1 - r1 * .05, y1), c3, c3
  1570. CIRCLE (x1 - r1 * .02, y1), r1 * .18, c2: PAINT (x1, y1), c2, c2
  1571. x1 = x - r1 * .8: y1 = y - r1 * .04
  1572. CIRCLE (x1, y1), r1 * .13, c1, , , 1.6: PAINT (x1, y1), c1, c1
  1573. CIRCLE (x1, y1), r1 * .13, c3, a1!, a2!, 1.6: PAINT (x1 - r1 * .05, y1), c3, c3
  1574. CIRCLE (x1 - r1 * .01, y1), r1 * .08, c2, , , 1.6: PAINT (x1, y1), c2, c2
  1575. x1 = x - r1 * .5: y1 = y + r1 * .3
  1576. CIRCLE (x1, y1), r1 * .1, c1, , , 1: PAINT (x1, y1), c1, c1
  1577. CIRCLE (x1, y1), r1 * .1, c3, -a1!, -a2!, 1
  1578.  
  1579. x1 = x + r1 * .14: y1 = y - r1 * .55
  1580. CIRCLE (x1, y1), r1 * .13, c1, , , .66: PAINT (x1, y1), c1, c1
  1581. x1 = x + r1 * .3: y1 = y + r1 * .1
  1582. CIRCLE (x1, y1), r1 * .2, c1, , , .9: PAINT (x1, y1), c1, c1
  1583. x1 = x + r1 * .02: y1 = y + r1 * .75
  1584. CIRCLE (x1, y1), r1 * .12, c1, , , .4: PAINT (x1, y1), c1, c1
  1585. x1 = x - r1 * .07: y1 = y + r1 * .5
  1586. CIRCLE (x1, y1), r1 * .15, c1, , , .8: PAINT (x1, y1), c1, c1
  1587. x1 = x - r1 * .01: y1 = y - r1 * .8
  1588. CIRCLE (x1, y1), r1 * .12, c1, , , .2: PAINT (x1 + r1 * .06, y1), c1, c1
  1589. CIRCLE (x1, y1), r1 * .12, c3, -a1!, -a2!, .2
  1590.  
  1591. x1 = x + r1 * .9: y1 = y + r1 * .05
  1592. CIRCLE (x1, y1), r1 * .1, c4, , , 3: PAINT (x1, y1), c4, c4
  1593. CIRCLE (x1, y1), r1 * .1, c2, -a1!, -a2!, 3
  1594. CIRCLE (x1 + r1 * .02, y1), r1 * .1, c2, -a1!, -a2!, 3
  1595. x1 = x + r1 * .7: y1 = y + r1 * .2
  1596. CIRCLE (x1, y1), r1 * .15, c4, , , 1.5: PAINT (x1, y1), c4, c4
  1597. CIRCLE (x1, y1), r1 * .15, c2, -a1!, -a2!, 1.5
  1598. CIRCLE (x1 + r1 * .02, y1), r1 * .15, c2, -a1!, -a2!, 1.5
  1599. x1 = x + r1 * .62: y1 = y - r1 * .35
  1600. CIRCLE (x1, y1), r1 * .05, c4, , , 1.2: PAINT (x1, y1), c4, c4
  1601. CIRCLE (x1, y1), r1 * .05, c2, -a1!, -a2!, 1.2
  1602. CIRCLE (x1 + r1 * .02, y1), r1 * .05, c2, -a1!, -a2!, 1.2
  1603.  
  1604. DSTG7:
  1605. c1 = 1: c2 = 9: c3 = 11: c4 = 15: c5 = 2: c6 = 10
  1606. FOR n = 1 TO 32
  1607. x = 320 * RND: y = 200 * RND: c = 7 + INT(2 * RND) * 8
  1608. PSET (x, y), c
  1609. x = -20: y = 330: r1 = 300
  1610. CIRCLE (x, y), r1, c1: PAINT (0, 199), c1, c1
  1611. CIRCLE (x, y), r1 * .985, c2: PAINT (0, 199), c2, c2
  1612. CIRCLE (x, y), r1 * .97, c3: PAINT (0, 199), c3, c3
  1613. CIRCLE (x, y), r1 * .955, c4: PAINT (0, 199), c4, c4
  1614. CIRCLE (x, y), r1 * .94, c3: PAINT (0, 199), c3, c3
  1615. CIRCLE (x, y), r1 * .925, c2: PAINT (0, 199), c2, c2
  1616. CIRCLE (x, y), r1 * .91, c1: PAINT (0, 199), c1, c1
  1617. y1 = 0
  1618. RESTORE EARTH
  1619. x0 = x1: y0 = y1: READ x1, y1
  1620. IF y0 > 0 AND y1 > 0 THEN LINE (x0, y0)-(x1, y1), c5
  1621. LOOP UNTIL x1 = -1 AND y1 = -1
  1622. PAINT (0, 199), c6, c5
  1623. PAINT (130, 199), c6, c5
  1624.  
  1625. EARTH:
  1626. DATA 0,119, 24,121, 40,124, 70,134, 69,138, 62,140, 79,148, 73,148, 84,155
  1627. DATA 82,154, 86,157, 88,162, 80,161, 70,158, 73,164, 88,172, 70,182
  1628. DATA 52,180, 48,183, 52,187, 51,193, 46,193, 62,199, 0,0
  1629. DATA 108,199, 114,186, 124,177, 123,172, 131,172, 138,185, 144,186, 147,192
  1630. DATA 154,194, 161,195, 165,199
  1631. DATA -1,-1
  1632.  
  1633. REM  - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1634.  
  1635. LOAD.SPRITES:
  1636. ENEMY$(1, 0) = "br5h8d4g4f4d4e8bl5"
  1637. ENEMY$(1, 1) = "br4h5d3g2f2d3e5bl4"
  1638. ENEMY$(1, 2) = "br6h5l2d10r2e5bl2"
  1639. ENEMY$(1, 3) = "bl1h7d5g2f2d5e7bl3"
  1640. ENEMY$(2, 0) = "br4e2h8g6f4g4f6e8h2bl4"
  1641. ENEMY$(2, 1) = "bl4e4f4g4h4br4"
  1642. ENEMY$(3, 0) = "e7l14f3d8g3r14h7bl1"
  1643. ENEMY$(3, 1) = "br6bu5l10bd10r10"
  1644. ENEMY$(4, 0) = "bu3br5d6g6l6e6u6h6r6f6bd3bl3"
  1645. ENEMY$(4, 1) = "bl5d3g5r4e5u6h5l4f5d3br2"
  1646. ENEMY$(5, 0) = "br3f3g3h3g5h3e5h5e3f5e3f3g3bl2"
  1647. ENEMY$(5, 1) = "br2e3d6h3br1"
  1648. ENEMY$(6, 0) = "g9l5e3u3e3h3u3h3r5f9bl4"
  1649. ENEMY$(6, 1) = "bl7e2r8f2g2l8h2br7"
  1650. ENEMY$(7, 0) = "h5l5f5g5r5e5bl3"
  1651. ENEMY$(7, 1) = "bl4u2r16f1r4f1g1l4g1l16u2l3br8"
  1652. ENEMY$(8, 0) = "bu4br7d8g4l6h5u8e4r6 f5"
  1653. ENEMY$(8, 1) = "bl1bd1g5l8e5r8bl7bd3"
  1654. ENEMY$(9, 0) = "bd5br6g2l4h5u7e4r2 l1"
  1655. ENEMY$(9, 1) = "bd10bl4e3r5g4l4u1br3bu2"
  1656. ENEMY$(10, 0) = "br7g9l3h3u3e3h3u3e3r3f9bl7"
  1657. ENEMY$(10, 1) = "br7g3l6h3e3r6f3bl8"
  1658. ENEMY$(10, 2) = "br6g4l10h2u4e2r10f4bl6"
  1659. ENEMY$(10, 3) = "br7g3l6h3e3r6f3bl7"
  1660. ENEMY$(11, 0) = "br7g9l3h3u3e3h3u3e3r3f9bl7"
  1661. ENEMY$(11, 1) = "br7g3l6h3e3r6f3bl8"
  1662. ENEMY$(11, 2) = "br6g4l10h2u4e2r10f4bl6"
  1663. ENEMY$(11, 3) = "br7g3l6h3e3r6f3bl7"
  1664.  
  1665. CRASH$(1) = "br4bu4h8d8g8r8f8u8e8l8bd4"
  1666. CRASH$(2) = "br4f4l4d4h4g4u4l4e4h4r4u4f4e4d4r4g4bl4"
  1667. CRASH$(3) = "br4d8h4l8e4u8f4r8g4bl4"
  1668.  
  1669. SHOT$(1) = "bl2bu2r2d4r2"
  1670. SHOT$(2) = "bl2bu2r4d4l4u4"
  1671.  
  1672. LOAD.CHARSET:
  1673. CH$(0) = "br1r3f2d4g1l3h2u4e1"
  1674. CH$(1) = "br3ng1d7nl2r2"
  1675. CH$(2) = "bd2u1e1r3f1d1g2l1g2d1r5"
  1676. CH$(3) = "r5g3r2f1d2g1l3h1"
  1677. CH$(4) = "br4bd7u7g4d1r5"
  1678. CH$(5) = "br5l5d2r4f1d3g1l3h1"
  1679. CH$(6) = "br5l2g3d2f2r3e1u1h2l3g1"
  1680. CH$(7) = "r5d1g3d3"
  1681. CH$(8) = "br2r2f1d1g1l3g1d2f1r4e1u1h2l2h2e1r1"
  1682. CH$(9) = "bd7br1r2e3u2h2l3g1d1f2r3e1"
  1683. CH$(17) = "bd7u3nr5u2e2r1f2d5"
  1684. CH$(18) = "nd7r3f1d1g1bl3r4f1d2g1l4"
  1685. CH$(19) = "br4l2g2d4f1r3e1"
  1686. CH$(20) = "bd7u7r4f1d4g2l3"
  1687. CH$(21) = "nr4d3nr3d3f1r4"
  1688. CH$(22) = "br5l4g1d2nr3d4"
  1689. CH$(23) = "br4l2g2d4f1r3e1u3l2"
  1690. CH$(24) = "d7bu4r5bu3d7"
  1691. CH$(25) = "br2r2bl1d7bl1r2"
  1692. CH$(26) = "br1r4d5g2l2u1"
  1693. CH$(27) = "d7bu4r1ne3nf4"
  1694. CH$(28) = "d7r5"
  1695. CH$(29) = "bd7u6e1f2e2f1d6"
  1696. CH$(30) = "bd7u7f5nd2u5"
  1697. CH$(31) = "br2r2f1d4g2l2h1u4e2"
  1698. CH$(32) = "bd7u7r4f1d2g1l4"
  1699. CH$(33) = "br1r2f2d4nh2nf1g1l2h2u4e1"
  1700. CH$(34) = "bd7u7r4f1d1g1l4br1f4"
  1701. CH$(35) = "br5l3g2f1r3f1d2g1l5"
  1702. CH$(36) = "r6bl3d7"
  1703. CH$(37) = "d5f2r3e1u6"
  1704. CH$(38) = "d6f1e4u3"
  1705. CH$(39) = "d6f1e2nu2f2e1u6"
  1706. CH$(40) = "r1f2d3f2r1bl6r1e2bu3e2r1"
  1707. CH$(41) = "d2f3nd2e3u2"
  1708. CH$(42) = "r6d1g6r6"
  1709.  
  1710. LOAD.SOUNDS:
  1711. REM 2,7,10,13,15,19,22,25,27,31,34,39,43,46,58
  1712. SLASER1$ = "MBT255l64n58n57n56n55n54"
  1713. SLASER2$ = "MBT255l48n58n56n54n52n58n56n54n52"
  1714. SSHOOT1$ = "MBT255l64n63n61n58n55n58"
  1715. SSHOOT2$ = "MBT255l64n61n58n55"
  1716. SSHOOT3$ = "MBT255l48n7n10n7"
  1717. SETYPE1$ = "MBT255l32n39n34n31n27n25n22n19n15n13n10n7n2"
  1718. SETYPE2$ = "MBT255l40n60n59n58n57n19n13n10n7n2n7n5n1n3n1n2n1"
  1719. SETYPE3$ = "MBT255l32n36n24n1n17n2n19n0n11n1n15n3n17n2n9n1n6n2n4n1n3n1"
  1720. SETYPE4$ = "MBT255l64n50n48n45n41n36n50n47n43n37n33n26n19n12n1n9n1n7n1n5n1n3n1"
  1721. SETYPE6$ = "MBT255l40n39n31n25n19n13n7n2n7n10n7n13n15n19n15n22n25n27n25n31n34n39n34n43n46"
  1722. SETYPE8$ = "MBT255l32n2n7n10n13n15n19n22n25n27n31n34n39n43n46n58"
  1723. SETYPE9$ = "MBT255l40n58n46n43n39n34n31n27n25n22n19n15n13"
  1724. SETYPE10$ = "MBT255l32n56n55n53n50n45n43n41n40n41n43n45n50n53n55n56"
  1725. SETYPE11$ = "MBT255l64n70n69n68n67n66n65n64n63n62n61n60"
  1726. SCRASH8$ = "MBT255l64n58n25n19n13n10n7n2n7n5n1n3n1n2n1"
  1727. SCRASH9$ = "MBT255l32n30n1n23n2n19n3n14n2n15n1n11n1n7n1n4n1n5n1n3n1n2n1n0n1n3n1n2n1"
  1728. SNEW1$ = "MBT255l24n58n57n58n53n57n58"
  1729. SNEWPL1$ = "MBT255l3n25n32"
  1730. SNEWPL2$ = "MBT255l8n25n32"
  1731. SDOCK2$ = "MBT255l32n15n17n15n17n20n25n29n32n37"
  1732. SRGTON$ = "MBT80l24n27n0l24n27n29n34n31n34n31l12n29l24n29n32l6n36l24n38n34n31n38n34n31n38n34l12n39l24n38l8n39"
  1733. SLAUNCH$ = "MBT96l64n27l8n22l16n22l4n27n34l16n0n22MLl4n27n34MSl24n39n0n0l32n39n0l48n39n0l64n39n0n39n0l32n39n0n39n0l48n39n0n39n0l24n51MN"
  1734. SFAROUT1$ = "MBT80l8n22l12n22l8n26l12n26l8n29l12n29l8n34l12n34l8n22l12n22l8n26l12n26l8n29l12n29l8n34l12n34"
  1735. SFAROUT2$ = "MBT80l64n17l8n22l12n22l64n17l8n26l12n26l64n17l8n29l12n29l64n17l8n34l12n34"
  1736. SEND$ = "MBT96l6n22l16n27l2n25l16n27l8n25n27n29l16n25n27l48n25n27l12n29l32n27n29n27n29l4n34"
  1737. SBONPLAY$ = "MBT64l64n15n22n19n22n19n22n27l32n34"
  1738. SHITBOS1$ = "MBT255l64n63n62n61n60n50n40n30n20n13n10n8n7n5n4n3n2n1n1n1"
  1739. SBOSPTS$ = "MBT255l64n46n45n44n43n42n41n40n39n38n37n36n35n34"
  1740. SSTAGE1$ = "MBMST64l32n40n0n40n40n0n40n40n40n40n0n40n40n0n40n0n40n0n40n40n40n0n40n0MN"
  1741. SSTAGE2$ = "MBT255l32n19n22n25n27n31n34n39n43n46"
  1742.  
  1743. SFINAL$(1, 1) = "MBMNT64l4n25l24n18n18l4n25l24n18n18l24n25n0n30n0l4n25"
  1744. SFINAL$(1, 2) = "MBMNT64l24n18n18l24n25n0n30n0l3n32"
  1745. SFINAL$(1, 3) = "MBMNT64l24n23n23l24n28n0n30n0l8n32l24n34l4n35"
  1746. SFINAL$(1, 4) = "MBMNT64l6n37l6n34l8n30n28n32n35"
  1747. SFINAL$(1, 5) = "MBMLT64l8n39l6n37l6n34l8n30n28n32n35n39l6n42"
  1748. SFINAL$(1, 6) = "MBMLT64l64n37n42n49n37n42n49n37n42n49n37n42n49n37n42n49n37n42n49l16n42"
  1749. SFINAL$(1, 7) = "MBMLT64"
  1750. SFINAL$(2, 1) = "MBMNT64l6n13n15n18n20n25l24n23n22l12n20l6n23l24n22n20l12n18n22n18l6n20"
  1751. SFINAL$(2, 2) = "MBMLT64l64n25n30n37MNl16n0l24n13n13n18n0n18n18n20n0n20n20n25n0n25n25n23n22n20n0"
  1752. SFINAL$(2, 3) = "MBMNT64l24n23n0n23n23n22n20n18n0l12n22l24n23n0n18n0n22n0l4n20"
  1753. SFINAL$(2, 4) = "MBMNT64l16n8n8n8n0n8n0n8n0n8n8n8n0n8n0"
  1754. SFINAL$(2, 5) = "MBMNT48l64n20l4n32MLl12n32n30n29n27n25l4n30l24n32n34l4n32"
  1755. SFINAL$(2, 6) = "MBMNT48l12n8l4n32MLl12n32n30n29n27T64n25l4n35l24n37n39"
  1756. SFINAL$(2, 7) = "MBMLT64l64n25n37n25n37n25n37n25n37n25n37n25n37n25n37n25n37l8n37"
  1757.  
  1758. CREDITS:
  1759. DATA " ", " ", " "
  1760. DATA "   YOU SAVED", "   THE GALAXY", " ", " ", " ", " "
  1761. DATA " CONGRATULATIONS", " ", "  THE MISSION", "IS ACCOMPLISHED"
  1762. DATA " ", "THE ALIENS HAVE", "     LEFT", " AND THE EARTH"
  1763. DATA "  IS NOW FREE", " ", "YOU HAVE BROUGHT", " BACK PEACE TO"
  1764. DATA "   OUR GALAXY", " ", "WE WILL THANK", " YOU FOREVER"
  1765. DATA " ", "    THE FORCE", "WILL BE WITH YOU", "     ALWAYS"
  1766. DATA " ", " ", " ", " ", "     THE END"
  1767.  
  1768.  
  1769. TITLE.HELP:
  1770. RESTORE THELP.TEXT
  1771. SCREEN 7, 0, 2, 2: tcnt = 0: tpos = 0: sss = 0
  1772. CLS : COLOR 15, 1
  1773.  
  1774. THELP.MAIN:
  1775. k = INP(96): k$ = INKEY$: da = 0
  1776. IF k = 1 THEN COLOR 15, 0: SCREEN 7, 0, scr, scr: GOTO WAITKEY0
  1777. WAIT &H3DA, 8: WAIT &H3DA, 8, 8
  1778. IF tcnt < 22 THEN GOSUB THELP.SOFT
  1779. IF k = 80 OR k = 77 OR tcnt < 22 THEN GOSUB THELP.SCROLL
  1780. IF k = 72 THEN RESTORE THELP.TEXT: CLS : tcnt = 0: tpos = 0: sss = 0
  1781. GOTO THELP.MAIN
  1782.  
  1783. THELP.SOFT:
  1784. a = 16024 + (tpos) * 80
  1785. OUT &H3D4, 12: OUT &H3D5, INT(a / 256)
  1786. OUT &H3D4, 13: OUT &H3D5, a AND 255
  1787.  
  1788. THELP.SCROLL:
  1789. tpos = (tpos + 1) AND 3
  1790. IF tpos <> 2 OR sss > 0 THEN RETURN
  1791. LOCATE 24, 1: READ T$: PRINT T$: tcnt = tcnt + 1
  1792. IF T$ = "XXX" THEN sss = 1
  1793. IF SND = 1 THEN SOUND 600, .2
  1794.  
  1795. THELP.TEXT:
  1796. DATA "- INCOMING MESSAGE -"
  1797. DATA ""
  1798. DATA "                        16.Dec. 2011"
  1799. DATA ""
  1800. DATA "THE UNITED EARTH ADMINISTRATION"
  1801. DATA "- - - - - - - - - - - - - - - -"
  1802. DATA ""
  1803. DATA ""
  1804. DATA "ALIENS HAVE INVADED TO OUR GALAXY."
  1805. DATA "THEY BUILD BASES TO NEARBY STARS "
  1806. DATA "IN RANGE OF SEVERAL LIGHT YEARS."
  1807. DATA "BEFORE WE COULD START ANY COUNTER"
  1808. DATA "MEASURES TO PROTECT OURSELF,"
  1809. DATA "THEY NOTICED OUR TELEMITRY SIGNALS,"
  1810. DATA "SENT BETWEEN THE EARTH AND OUR"
  1811. DATA "SATELLITES "
  1812. DATA ""
  1813. DATA "THEY REACHED OUR SOLAY SYSTEM AND"
  1814. DATA "INSTANTLY OCCUPIED ONE PLANET"
  1815. DATA "AFTER ANOTHER, STARTING WITH PLUTO"
  1816. DATA "OVER TO NEPTUN, SATURN, JUPITER AND"
  1817. DATA "FINALLY THE EARTH MOON, WHERE THEY  >>"
  1818. DATA "LOCATED THEIR GIANT NEXUS MOTHERSHIP"
  1819. DATA ""
  1820. DATA "WITH DESTROYING OUR SPACE STATION"
  1821. DATA "AND SEVERAL ORBIT SHUTTLES, COSTING"
  1822. DATA "OVER 10.000 HUMAN LIFES, THEYïVE"
  1823. DATA "DEMONSTRATED THEIR EXTREMELY AGRESSIVE
  1824. DATA "INTENTIONS"
  1825. DATA ""
  1826. DATA "ITS ASSUMED FOR CLEAR THAT THE"
  1827. DATA "MOTHERSHIP PREPARES FOR THE FINAL"
  1828. DATA "ATTACK ON THE EARTH"
  1829. DATA "AND IF THIS HAPPENS MANKIND CAN KISS"
  1830. DATA "THE DAYïS GOODBYE, THATS FOR SURE"
  1831. DATA ""
  1832. DATA "GOD, WE NEED SOMEONE WHO BLOWS THESE"
  1833. DATA "BASTARDS TO PIECES !"
  1834. DATA "WE NEED TO DESTROY ALL THEIR HOMEBASES"
  1835. DATA "TO BREAK UP THEIR SUPPLY LINE,"
  1836. DATA "STARTING AT THE VEGA CONSTELLATION"
  1837. DATA "37 LIGHTYEARS AWAY"
  1838. DATA ""
  1839. DATA ">> So, fine, but what has all this"
  1840. DATA "to do with me ? << YOU ASK
  1841. DATA ""
  1842. DATA "CAUSE ALL OUR ASTRONAUTS HAVE SUDDENLY"
  1843. DATA "GONE ON VACATION 3 DAYS AGO,"
  1844. DATA "WE ENGAGED YOU. YOUïRE OUR LAST HOPE !"
  1845. DATA ""
  1846. DATA "ALTHOUGH YOURE NO ASTRONAUT, NOT EVEN
  1847. DATA "A PILOT, THAT DOESNïT REALLY MATTER."
  1848. DATA ""
  1849. DATA "WEïVE SIMPLIFIED THE SHIPïS CONTROLS SO"
  1850. DATA "THAT EVEN AN AVERAGE CLEVER SPACE-COW"
  1851. DATA "CAN FLY IT"
  1852. DATA "LOOK, ITS REALLY EASY:"
  1853. DATA "","",""
  1854. DATA "- - - - - - - - - - - - - - - - - - -"
  1855. DATA "Lunar Module Control Keys"
  1856. DATA "","",""
  1857. DATA "Arrow Left / Num 4    = Move Left "
  1858. DATA "Arrow Left / Num 6    = Move Right"
  1859. DATA "Left Strg             = Fire / Thrust"
  1860. DATA "S                     = Sound On/Off"
  1861. DATA "P                     = Pause"
  1862. DATA "
  1863. DATA "Hint:"
  1864. DATA "Use the Num-Keys for better control"
  1865. DATA "","",""
  1866. DATA "Bonus Ship given every 20000 Pts"
  1867. DATA "Successful Docking increases Firepower"
  1868. DATA "Hitpoints increase every Stage"
  1869. DATA ""
  1870. DATA "- - - - - - - - - - - - - - - - - - -"
  1871. DATA "","","",""
  1872. DATA "YOU ARE SUPPLIED WITH 3 SEPERATE LUNAR"
  1873. DATA "MODULES, OUTFITTET WITH A STAR-DRIVE"
  1874. DATA "AND HIGH-VOLTAGE PLASMA LAUNCHERS"
  1875. DATA ""
  1876. DATA "THE MODULES CAN BE FLOWN SEPERATLY OR"
  1877. DATA "CONNECTED, WHICH GIVES AN EXTRA
  1878. DATA "FIRE-POWER."
  1879. DATA "HOWEVER, TO SAVE MODULES, THEY ARE"
  1880. DATA "DISCONNECTED AUTOMATICALLY WHEN POSSIBLE"
  1881. DATA "OR WHEN ONE OF THEM GETS DESTROYED."
  1882. DATA ""
  1883. DATA "IF THIS HAPPENS, YOU SHOULD BE EJECTED"
  1884. DATA "AND WHEN YOUïVE BEEN EJECTED, YOU
  1885. DATA "SHOULD ENTER THE NEXT INTACT SECTION"
  1886. DATA "AUTOMATICALLY."
  1887. DATA ""
  1888. DATA "- Why SHOULD ?
  1889. DATA ""
  1890. DATA "THE SYSTEMïS NOT PERFECT YET, CAUSE"
  1891. DATA "THE SHIPïS COMPUTER CRASHES FROM"
  1892. DATA "TIME TO TIME. BUT DONïT PANIC,"
  1893. DATA "OUR ENGINEERS WILL FIX THAT BY SENDING"
  1894. DATA "YOU UPDATE VERSIONS OF THE SHIPïS"
  1895. DATA "COMPUTERïS OPERATING SYSTEM"
  1896. DATA "(Windows 2011 v4.1.0.2.1-beta-beta)"
  1897. DATA ""
  1898. DATA ""
  1899. DATA "THE EARTH BASE WILL TRY TO SUPPLY YOU"
  1900. DATA "CONSTANTLY WITH NEW MODULES"
  1901. DATA ""
  1902. DATA "BUT PLEASE HANDLE WITH CARE,"
  1903. DATA "WE CANïT BAKE THEM LIKE BREADS"
  1904. DATA ""
  1905. DATA "GOOD LUCK!"
  1906. DATA "","","","",""
  1907. DATA "END OF MESSAGE."
  1908. DATA "","","","","","","","","","","",""
  1909. DATA "GAME INFO"
  1910. DATA ""
  1911. DATA "This programm was intended as a tutorial"
  1912. DATA "for beginners who want to learn"
  1913. DATA "programming in Qbasic, demonstrating"
  1914. DATA "some of its capabillities for making"
  1915. DATA "sound and graphics."
  1916. DATA "It uses PLAY and SOUND for music and"
  1917. DATA "most of the Graphic functions,"
  1918. DATA "exspecially the DRAW Command for Sprites"
  1919. DATA "(which lets you rotate and scale)."
  1920. DATA "Even if some of the letters look like"
  1921. DATA "vectors, but they are all DRAW-Sprites"
  1922. DATA ""
  1923. DATA "The inspiration and ideas i lend
  1924. DATA "(took, stole) from following games:"
  1925. DATA "Mooncresta arcade game (1983)"
  1926. DATA "Galaga 88 arcade"
  1927. DATA "Space Pilot I-II (C64)"
  1928. DATA "(They belong to my all-time favorite
  1929. DATA "shoot-em-ups)"
  1930. DATA ""
  1931. DATA "In the beginning i just wanted to make"
  1932. DATA "a simple shooter (what it still is) but"
  1933. DATA "then those old shooting games came to"
  1934. DATA "mind, exspecially Mooncresta (obviously"
  1935. DATA "you can see where i got the title),"
  1936. DATA "which i played as a kid totally"
  1937. DATA "fascinated me."
  1938. DATA "Those games had great graphics and
  1939. DATA "sound (for this time) and where FUN"
  1940. DATA "to play."
  1941. DATA "So i also wanted to put in something of"
  1942. DATA "these games, and as the programm grew"
  1943. DATA "bigger and bigger, i decided to make a"
  1944. DATA "complete game of it, and hereïs whats"
  1945. DATA "the result.
  1946. DATA "(hope you like this piece of ïcrapï)"
  1947. DATA "",""
  1948. DATA "Mooncr.99 made by Daniel Kupfer
  1949. DATA "in Nov.1999"
  1950. DATA "Mail me if U like"
  1951. DATA "EMail dk1000000@aol.com"
  1952. DATA "   or dku1000000@cs.com"
  1953. DATA "","","",""
  1954. DATA "Machine Requirements:"
  1955. DATA "",""
  1956. DATA "Qbasic:   Pentium 200"
  1957. DATA "Compiled: 486-66 / Pentium 66"
  1958. DATA ""
  1959. DATA "As its Qbasic you need decent computer"
  1960. DATA "power to run at full speed (35 frames)"
  1961. DATA "It works just fine on my P-II 233"
  1962. DATA "Iïve never tried to compile this"
  1963. DATA "with Quick Basic"
  1964. DATA "ïcause i donït own Quick Basic, but if"
  1965. DATA "it works, i guess its gonna be 5 times"
  1966. DATA "faster or so (however it never runs"
  1967. DATA "more than 35 frames)"
  1968. DATA "",""
  1969. DATA "Enjoy !"
  1970. DATA "If you liked it, ask for upcoming"
  1971. DATA "mooncr.2000"
  1972. DATA ""
  1973. DATA "SEE YA!"
  1974. DATA "","",""
  1975. DATA "PRESS ESC"
  1976. DATA "XXX"
  1977.  

PS: I was not talking about the code on forum. But inside the sample package which comes along with qb64.
Title: Re: Robot Invaders
Post by: SierraKen on July 23, 2019, 04:31:30 pm
Neat Ashish, but I will look at that in a few minutes, been too busy today with Version 2.
Title: Re: Robot Invaders
Post by: SierraKen on July 23, 2019, 04:35:25 pm
Here is Version 2 everyone! There's 5 different colored robots and they all fly at different patterns. After that there's the Boss Robot that looks different and also flies differently. I also made them shoot a tiny bit faster than the level before it. If you get past the Boss Robot, it goes back to the beginning, but the levels still increase in the _TITLE as well as the points. I hope you all like it. It's getting harder to program in so much heat from the weather. I used 6 of the 12 math equations that I posted yesterday to make them follow those patterns. In this one I also put many descriptions of the code to make it easier to learn from.

Note: I just renamed this game to Tech Invaders because of another game for sale on Amazon called Robot Invaders. I don't want any conflict with them, even though mine is free and completely different.

(Note Again: A better version of this game is on page 2 of this forum with a little enhancement.)

Code: QB64: [Select]
  1. 'This version has 5 different colored robots with a Boss Robot after that.
  2. 'Each robot flies a different pattern.
  3. 'Game made on July 22, 2019
  4. 'By Ken G.
  5. 'Freeware
  6. 'I have put some descriptions in the code below to make it easier to learn from.
  7. begin:
  8. _TITLE "Tech Invaders"
  9. SCREEN _NEWIMAGE(800, 600, 32)
  10. PRINT "                                 T E C H      I N V A D E R S"
  11. PRINT "                                        by Ken G."
  12. PRINT "                       Use left and right arrow keys to move back and forth."
  13. PRINT "                            Use up or down arrow keys to stop moving."
  14. PRINT "                                    Use space bar to fire."
  15. PRINT "                                      Esc to end anytime."
  16. INPUT "                                   Press Enter to start."; start$
  17. lives = 5
  18. points = 0
  19. ushoot = 0
  20. shooting = 0
  21. level = 1
  22. level2 = 1
  23. start = 0
  24. s = 0
  25. xt = 400: yt = 550
  26.  
  27. 'Draw your shooter.
  28. LINE (xt, yt)-(xt + 20, yt + 20), _RGB32(128, 139, 255), BF
  29. LINE (xt + 10, yt)-(xt + 10, yt - 10), _RGB32(128, 139, 255)
  30.  
  31.  
  32. 'This is the start of the main loop.
  33. go:
  34. 'Choose a random place for the enemy.
  35. xx = INT(RND * 200) + 100
  36. yy = INT(RND * 100) + 40
  37.  
  38. 'Each level has its own loop so it can set a different equation and speed of the enemy.
  39.  
  40. IF level = 1 THEN
  41.     cl = 128: c2 = 127: c3 = 255
  42.     one:
  43.     'sec is not time, it's related to the coordinate of the enemy and speed it goes related to the loop speed.
  44.     sec = sec + .01
  45.     s = (60 - sec) * 6 + 180
  46.     x = INT(SIN(s / 180 * 3.141592) * 180) + 325
  47.     y = INT(COS(s / 180 * 3.141592) * 180) + 225
  48.  
  49.     'GOSUB to drawing draws the enemy robot.
  50.     GOSUB drawing:
  51.     IF sec > 180 THEN
  52.         sec = 0
  53.         GOTO onedone:
  54.     END IF
  55.  
  56.     'GOSUB's go to keyboard control and enemy shooting.
  57.     GOSUB keyboard:
  58.     GOSUB shoot:
  59.     GOSUB youshoot2:
  60.     GOTO one:
  61.     onedone:
  62.  
  63. 'This level uses the spiral equation so it's a bit different than the others.
  64. IF level = 2 THEN
  65.     c1 = 127: c2 = 216: c3 = 127
  66.     FOR d = 160 TO 0 STEP -.125
  67.         _LIMIT 1000
  68.         s = s + .2
  69.         x = COS(s * 3.141592 / 180) * d
  70.         y = SIN(s * 3.151492 / 180) * d
  71.         GOSUB drawing:
  72.         GOSUB keyboard:
  73.         GOSUB shoot:
  74.         GOSUB youshoot2:
  75.     NEXT d
  76.     FOR d = 0 TO 160 STEP .125
  77.         _LIMIT 1000
  78.         s = s - .2
  79.         x = COS(s * 3.141592 / 180) * d
  80.         y = SIN(s * 3.151492 / 180) * d
  81.         GOSUB drawing:
  82.         GOSUB keyboard:
  83.         GOSUB shoot:
  84.         GOSUB youshoot2:
  85.     NEXT d
  86.  
  87. IF level = 3 THEN
  88.     c1 = 255: c2 = 0: c3 = 0
  89.     three:
  90.     sec = sec + .01
  91.     s = (60 - sec) * 6 + 180
  92.     x = INT(SIN(s / 90 * 3.141592) * 180) + 325
  93.     y = INT(COS(s / 180 * 3.141592) * 180) + 225
  94.     GOSUB drawing:
  95.     IF sec > 60 THEN
  96.         sec = 0
  97.         GOTO threedone:
  98.     END IF
  99.     GOSUB keyboard:
  100.     GOSUB shoot:
  101.     GOSUB youshoot2:
  102.     GOTO three:
  103.     threedone:
  104.  
  105. IF level = 4 THEN
  106.     c1 = 255: c2 = 255: c3 = 127
  107.     four:
  108.     sec = sec + .01
  109.     s = (60 - sec) * 6 + 180
  110.     x = INT(SIN(s / 180 * 3.141592) * 180) + 325
  111.     y = INT(COS(s / 90 * 3.141592) * 180) + 225
  112.     GOSUB drawing:
  113.     IF sec > 60 THEN
  114.         sec = 0
  115.         GOTO fourdone:
  116.     END IF
  117.     GOSUB keyboard:
  118.     GOSUB shoot:
  119.     GOSUB youshoot2:
  120.     GOTO four:
  121.     fourdone:
  122. IF level = 5 THEN
  123.     c1 = 133: c2 = 28: c3 = 255
  124.     five:
  125.     sec = sec + .01
  126.     s = (60 - sec) * 6 + 180
  127.     x = INT(SIN(s / 135 * 3.141592) * 180) + 325
  128.     y = INT(COS(s / 33.75 * 3.141592) * 180) + 225
  129.     GOSUB drawing:
  130.     IF sec > 60 THEN
  131.         sec = 0
  132.         GOTO fivedone:
  133.     END IF
  134.     GOSUB keyboard:
  135.     GOSUB shoot:
  136.     GOSUB youshoot2:
  137.     GOTO five:
  138.     fivedone:
  139.  
  140. IF level = 6 THEN
  141.     c1 = 255: c2 = 0: c3 = 0
  142.     six:
  143.     sec = sec + .02
  144.     s = (60 - sec) * 6 + 180
  145.     x = INT(SIN(s / 45 * 3.141592) * 180) + 325
  146.     y = INT(COS(s / 360 * 3.141592) * 180) + 225
  147.     GOSUB drawing2:
  148.     IF sec > 120 THEN
  149.         sec = 0
  150.         GOTO sixdone:
  151.     END IF
  152.     GOSUB keyboard:
  153.     GOSUB shoot:
  154.     GOSUB youshoot2:
  155.     GOTO six:
  156.     sixdone:
  157.  
  158. IF level = 7 THEN level = 1
  159.  
  160. GOTO go:
  161. 'GOTO goes back to the start of the main loop.
  162.  
  163. 'Draws the enemy tank and erases it for animation.
  164. drawing:
  165. x2 = x + xx: y2 = y + yy
  166. LINE (x2, y2)-(x2 - 10, y2 - 10), _RGB32(c1, c2, c3)
  167. LINE (x2 + 20, y2)-(x2 + 30, y2 - 10), _RGB32(c1, c2, c3)
  168. LINE (x2, y2)-(x2 + 20, y2 + 20), _RGB32(c1, c2, c3), BF
  169. LINE (x2 + 5, y2 + 5)-(x2 + 8, y2 + 8), _RGB32(0, 0, 0), BF
  170. LINE (x2 + 12, y2 + 5)-(x2 + 15, y2 + 8), _RGB32(0, 0, 0), BF
  171. LINE (x2 + 5, y2 + 13)-(x2 + 15, y2 + 16), _RGB32(0, 0, 0), BF
  172. _DELAY .004
  173. LINE (x2, y2)-(x2 + 20, y2 + 20), _RGB32(0, 0, 0), BF
  174. LINE (x2, y2)-(x2 - 10, y2 - 10), _RGB32(0, 0, 0)
  175. LINE (x2 + 20, y2)-(x2 + 30, y2 - 10), _RGB32(0, 0, 0)
  176.  
  177. 'Draws the Boss Robot.
  178. drawing2:
  179. x2 = x + xx: y2 = y + yy
  180. CIRCLE (x2, y2), 20, _RGB32(c1, c2, c3)
  181. LINE (x2 - 10, y2 - 10)-(x2 - 5, y2 - 5), _RGB32(c1, c2, c3), BF
  182. LINE (x2 + 10, y2 - 10)-(x2 + 14, y2 - 5), _RGB32(c1, c2, c3), BF
  183. LINE (x2 - 10, y2 + 10)-(x2 + 14, y2 + 15), _RGB32(c1, c2, c3), BF
  184. _DELAY .004
  185. CIRCLE (x2, y2), 20, _RGB32(0, 0, 0)
  186. LINE (x2 - 10, y2 - 10)-(x2 - 5, y2 - 5), _RGB32(0, 0, 0), BF
  187. LINE (x2 + 10, y2 - 10)-(x2 + 15, y2 - 5), _RGB32(0, 0, 0), BF
  188. LINE (x2 - 10, y2 + 10)-(x2 + 15, y2 + 15), _RGB32(0, 0, 0), BF
  189.  
  190.  
  191. 'Keyboard control for your movement and shooting.
  192. keyboard:
  193. _LIMIT 1000
  194. a$ = INKEY$
  195. IF a$ = CHR$(27) THEN END
  196. IF a$ = CHR$(0) + CHR$(77) THEN r = 1: l = 0
  197. IF r = 1 THEN
  198.     LINE (xt, yt)-(xt + 20, yt + 20), _RGB32(0, 0, 0), BF
  199.     LINE (xt + 10, yt)-(xt + 10, yt - 10), _RGB32(0, 0, 0)
  200.     xt = xt + 1
  201.     IF xt > 780 THEN xt = 780
  202.     LINE (xt, yt)-(xt + 20, yt + 20), _RGB32(128, 139, 255), BF
  203.     LINE (xt + 10, yt)-(xt + 10, yt - 10), _RGB32(128, 139, 255)
  204. IF a$ = CHR$(0) + CHR$(75) THEN l = 1: r = 0
  205. IF l = 1 THEN
  206.     LINE (xt, yt)-(xt + 20, yt + 20), _RGB32(0, 0, 0), BF
  207.     LINE (xt + 10, yt)-(xt + 10, yt - 10), _RGB32(0, 0, 0)
  208.     xt = xt - 1
  209.     IF xt < 0 THEN xt = 0
  210.     LINE (xt, yt)-(xt + 20, yt + 20), _RGB32(128, 139, 255), BF
  211.     LINE (xt + 10, yt)-(xt + 10, yt - 10), _RGB32(128, 139, 255)
  212. IF a$ = CHR$(0) + CHR$(72) OR a$ = CHR$(0) + CHR$(80) THEN
  213.     r = 0: l = 0
  214.  
  215. IF a$ = " " THEN GOSUB youshoot:
  216.  
  217. 'The start of your shot.
  218. youshoot:
  219. _LIMIT 1000
  220. IF ushoot = 0 THEN
  221.     sx2 = xt + 10
  222.     sy2 = yt - 11
  223.     ushoot = 1
  224.     SOUND 400, .5
  225.  
  226. 'The drawing and movement of your shot and if it reaches the enemy.
  227. youshoot2:
  228. _LIMIT 1000
  229. IF ushoot = 1 THEN
  230.     CIRCLE (sx2, sy2), 5, _RGB32(0, 0, 0)
  231.     sy2 = sy2 - 3
  232.     IF sy2 < 0 THEN ushoot = 0: RETURN
  233.     CIRCLE (sx2, sy2), 5, _RGB32(255, 0, 0)
  234.     IF sx2 > x2 - 1 AND sx2 < x2 + 21 AND sy2 > y2 - 1 AND sy2 < y2 + 21 THEN
  235.         CIRCLE (sx2, sy2), 3, _RGB32(0, 0, 0)
  236.         SOUND 200, 1
  237.         SOUND 100, 1
  238.         FOR explosion = 1 TO 30
  239.             CIRCLE (x2 + 10, y2 + 10), explosion, _RGB32(255, 0, 0)
  240.             _DELAY .02
  241.             CIRCLE (x2 + 10, y2 + 10), explosion, _RGB32(0, 0, 0)
  242.         NEXT explosion
  243.         LINE (x2 - 21, y2 - 21)-(x2 + 41, y2 + 41), _RGB32(0, 0, 0), BF
  244.         points = points + 100
  245.         IF level = 6 THEN points = points + 400
  246.         IF points / 500 = INT(points / 500) THEN level = level + 1: level2 = level2 + 1
  247.         lives$ = STR$(lives)
  248.         points$ = STR$(points)
  249.         level$ = STR$(level2)
  250.         _TITLE "Tech Invaders      Lives: " + lives$ + "     Level: " + level$ + "      Score: " + points$
  251.         _DELAY .25
  252.         ushoot = 0
  253.         GOTO go:
  254.     END IF
  255.  
  256. 'The enemy's shot and if it reaches you.
  257. shoot:
  258. _LIMIT 1000
  259. IF shooting = 0 THEN
  260.     IF level = 1 THEN shh = 9980
  261.     IF level = 2 THEN shh = 9978
  262.     IF level = 3 THEN shh = 9976
  263.     IF level = 4 THEN shh = 9974
  264.     IF level = 5 THEN shh = 9972
  265.     IF level = 6 THEN shh = 9940
  266.     sh = INT(RND * 10000) + 1
  267.     IF sh < shh THEN RETURN
  268.     sx = x2 + 10
  269.     sy = y2 + 10
  270.     shooting = 1
  271.     SOUND 300, .5
  272. IF shooting = 1 THEN
  273.     CIRCLE (sx, sy), 5, _RGB32(0, 0, 0)
  274.     sy = sy + 3
  275.     IF sy > 620 THEN shooting = 0: RETURN
  276.     CIRCLE (sx, sy), 5, _RGB32(255, 0, 0)
  277.     IF sx > xt - 1 AND sx < xt + 21 AND sy > yt - 1 AND sy < yt + 21 THEN
  278.         CIRCLE (sx, sy), 5, _RGB32(0, 0, 0)
  279.         SOUND 200, 1
  280.         SOUND 100, 1
  281.         FOR explosion2 = 1 TO 30
  282.             CIRCLE (xt + 10, yt + 10), explosion2, _RGB32(255, 0, 0)
  283.             _DELAY .02
  284.             CIRCLE (xt + 10, yt + 10), explosion2, _RGB32(0, 0, 0)
  285.         NEXT explosion2
  286.         lives = lives - 1
  287.         lives$ = STR$(lives)
  288.         points$ = STR$(points)
  289.         level$ = STR$(level2)
  290.         _TITLE "Tech Invaders      Lives: " + lives$ + "     Level: " + level$ + "      Score: " + points$
  291.         _DELAY 1
  292.         LINE (xt - 22, yt - 42)-(xt + 42, yt + 42), _RGB32(0, 0, 0), BF
  293.         IF lives = 0 THEN
  294.             LOCATE 20, 40: PRINT "G A M E   O V E R"
  295.             LOCATE 22, 40: PRINT "Score: "; points
  296.             LOCATE 23, 40: PRINT "Level: "; level2
  297.             LOCATE 24, 40: INPUT "Play Again (Yes/No)", ag$
  298.             IF ag$ = "Y" OR ag$ = "y" OR ag$ = "YES" OR ag$ = "yes" OR ag$ = "Yes" OR ag$ = "YEs" OR ag$ = "yES" OR ag$ = "yeS" THEN GOTO begin:
  299.             END
  300.         END IF
  301.         shooting = 0
  302.         RETURN
  303.     END IF
  304.  
Title: Re: Robot Invaders
Post by: SierraKen on July 23, 2019, 04:51:56 pm
LOL Ashish, looks very professional for computers back then. Of course I've never been a professional programmer so I'm taking one step at a time with my hobby. :) I'm glad you and the others like what I've made. :)
Title: Re: Robot Invaders
Post by: bplus on July 23, 2019, 05:41:39 pm
Hi Ken,

I think the speeds on this are a little better, I can hit the enemy while moving.

I am wondering if the shooter x, y and the enemy x, y are always integer, such that when compare x's of each for hit you are comparing integer to integer and not integer to single, ie if shot x is 3 and enemy is 3.05 it would be a miss.

I can't read your code is the shooter moving every 5 spaces still or every 1?

Are you doing collisions by exact x = x of shooter and enemy or a radius around x, seems like some shots I make should be hitting...

Also when enemy clobbers my shooter with shot or ship, it disappears from screen.
Title: Re: Robot Invaders
Post by: bplus on July 23, 2019, 07:15:56 pm
Ah I found the changes of shooter: +/- 1, OK but you are in default single for undeclared variables but these are changing only by integer amounts... should be OK?

 I see the enemy position is converted to integers (good!) except in level 2? That must of been when I noticed shots weren't working so well.

Title: Re: Robot Invaders
Post by: SierraKen on July 23, 2019, 08:08:41 pm
That's interesting B+ because once in awhile I will not be able to hit the enemy as well. Singles or Integers shouldn't matter because I give a < and > gap to be able to hit the enemy. Here is the code I use, although maybe it needs some adjusting. sx2 and sy2 are the coords for your shot and x2 and y2 are the coords to the enemy.
Code: QB64: [Select]
  1. IF sx2 > x2 - 1 AND sx2 < x2 + 21 AND sy2 > y2 - 1 AND sy2 < y2 + 21 THEN
  2.  

Thanks for your comments, I will look more into this real soon. Most likely it just needs a couple more coordinates for the gap because the human eye sometimes is slower than the speed of animation, where you think it hit but the computer thinks it didn't.
Title: Re: Robot Invaders
Post by: bplus on July 23, 2019, 09:37:11 pm
That's interesting B+ because once in awhile I will not be able to hit the enemy as well. Singles or Integers shouldn't matter because I give a < and > gap to be able to hit the enemy. Here is the code I use, although maybe it needs some adjusting. sx2 and sy2 are the coords for your shot and x2 and y2 are the coords to the enemy.
Code: QB64: [Select]
  1. IF sx2 > x2 - 1 AND sx2 < x2 + 21 AND sy2 > y2 - 1 AND sy2 < y2 + 21 THEN
  2.  

Thanks for your comments, I will look more into this real soon. Most likely it just needs a couple more coordinates for the gap because the human eye sometimes is slower than the speed of animation, where you think it hit but the computer thinks it didn't.

Ah so there is a range, thanks for pointing it out. I guess I had expectations from Alien Invaders but this is a different approach, we have to anticipate where the shot is going to go and where the invader ship will be, good, thanks again!


Title: Re: Robot Invaders
Post by: SierraKen on July 23, 2019, 09:55:38 pm
It did need a larger gap, thanks B+! I widened it much more so now I think just about any hint of it seeming to hit, will hit. Thanks for the comments.

I also changed the looks of the robots a little bit and also the Boss. Plus I removed a couple of _DELAY's so now it runs a little faster and smoother.  Oh also, after the Boss, they shoot a little bit faster and stays on that speed for the rest of the game. I enjoy playing it more now myself, I hope you all do too.... and you can laugh at what the robots look like now. :))

(Note: This version does not make a Top Ten Scores list, the next code on this forum page does.)

Code: QB64: [Select]
  1. 'This version has 5 different colored robots with a Boss Robot after that.
  2. 'Each robot flies a different pattern.
  3. 'Game made on July 22, 2019
  4. 'By Ken G.
  5. 'Freeware
  6. 'I have put some descriptions in the code below to make it easier to learn from.
  7. begin:
  8. _TITLE "Tech Invaders"
  9. SCREEN _NEWIMAGE(800, 600, 32)
  10. PRINT "                                 T E C H      I N V A D E R S"
  11. PRINT "                                        by Ken G."
  12. PRINT "                       Use left and right arrow keys to move back and forth."
  13. PRINT "                            Use up or down arrow keys to stop moving."
  14. PRINT "                                    Use space bar to fire."
  15. PRINT "                                      Esc to end anytime."
  16. INPUT "                                   Press Enter to start."; start$
  17. lives = 5
  18. points = 0
  19. ushoot = 0
  20. shooting = 0
  21. level = 1
  22. level2 = 1
  23. start = 0
  24. s = 0
  25. xt = 400: yt = 550
  26.  
  27. 'Draw your shooter.
  28. LINE (xt, yt)-(xt + 20, yt + 20), _RGB32(128, 139, 255), BF
  29. LINE (xt + 10, yt)-(xt + 10, yt - 10), _RGB32(128, 139, 255)
  30.  
  31.  
  32. 'This is the start of the main loop.
  33. go:
  34. 'Choose a random place for the enemy.
  35. xx = INT(RND * 200) + 100
  36. yy = INT(RND * 100) + 40
  37.  
  38. 'Each level has its own loop so it can set a different equation and speed of the enemy.
  39.  
  40. IF level = 1 THEN
  41.     cl = 128: c2 = 127: c3 = 255
  42.     one:
  43.     'sec is not time, it's related to the coordinate of the enemy and speed it goes related to the loop speed.
  44.     sec = sec + .01
  45.     s = (60 - sec) * 6 + 180
  46.     x = INT(SIN(s / 180 * 3.141592) * 180) + 325
  47.     y = INT(COS(s / 180 * 3.141592) * 180) + 225
  48.  
  49.     'GOSUB to drawing draws the enemy robot.
  50.     GOSUB drawing:
  51.     IF sec > 180 THEN
  52.         sec = 0
  53.         GOTO onedone:
  54.     END IF
  55.  
  56.     'GOSUB's go to keyboard control and enemy shooting.
  57.     GOSUB keyboard:
  58.     GOSUB shoot:
  59.     GOSUB youshoot2:
  60.     GOTO one:
  61.     onedone:
  62.  
  63. 'This level uses the spiral equation so it's a bit different than the others.
  64. IF level = 2 THEN
  65.     c1 = 127: c2 = 216: c3 = 127
  66.     FOR d = 160 TO 0 STEP -.125
  67.         _LIMIT 1000
  68.         s = s + .2
  69.         x = COS(s * 3.141592 / 180) * d
  70.         y = SIN(s * 3.151492 / 180) * d
  71.         GOSUB drawing:
  72.         GOSUB keyboard:
  73.         GOSUB shoot:
  74.         GOSUB youshoot2:
  75.     NEXT d
  76.     FOR d = 0 TO 160 STEP .125
  77.         _LIMIT 1000
  78.         s = s - .2
  79.         x = COS(s * 3.141592 / 180) * d
  80.         y = SIN(s * 3.151492 / 180) * d
  81.         GOSUB drawing:
  82.         GOSUB keyboard:
  83.         GOSUB shoot:
  84.         GOSUB youshoot2:
  85.     NEXT d
  86.  
  87. IF level = 3 THEN
  88.     c1 = 255: c2 = 0: c3 = 0
  89.     three:
  90.     sec = sec + .01
  91.     s = (60 - sec) * 6 + 180
  92.     x = INT(SIN(s / 90 * 3.141592) * 180) + 325
  93.     y = INT(COS(s / 180 * 3.141592) * 180) + 225
  94.     GOSUB drawing:
  95.     IF sec > 60 THEN
  96.         sec = 0
  97.         GOTO threedone:
  98.     END IF
  99.     GOSUB keyboard:
  100.     GOSUB shoot:
  101.     GOSUB youshoot2:
  102.     GOTO three:
  103.     threedone:
  104.  
  105. IF level = 4 THEN
  106.     c1 = 255: c2 = 255: c3 = 127
  107.     four:
  108.     sec = sec + .01
  109.     s = (60 - sec) * 6 + 180
  110.     x = INT(SIN(s / 180 * 3.141592) * 180) + 325
  111.     y = INT(COS(s / 90 * 3.141592) * 180) + 225
  112.     GOSUB drawing:
  113.     IF sec > 60 THEN
  114.         sec = 0
  115.         GOTO fourdone:
  116.     END IF
  117.     GOSUB keyboard:
  118.     GOSUB shoot:
  119.     GOSUB youshoot2:
  120.     GOTO four:
  121.     fourdone:
  122. IF level = 5 THEN
  123.     c1 = 133: c2 = 28: c3 = 255
  124.     five:
  125.     sec = sec + .01
  126.     s = (60 - sec) * 6 + 180
  127.     x = INT(SIN(s / 135 * 3.141592) * 180) + 325
  128.     y = INT(COS(s / 33.75 * 3.141592) * 180) + 225
  129.     GOSUB drawing:
  130.     IF sec > 60 THEN
  131.         sec = 0
  132.         GOTO fivedone:
  133.     END IF
  134.     GOSUB keyboard:
  135.     GOSUB shoot:
  136.     GOSUB youshoot2:
  137.     GOTO five:
  138.     fivedone:
  139.  
  140. IF level = 6 THEN
  141.     c1 = 255: c2 = 0: c3 = 0
  142.     six:
  143.     sec = sec + .02
  144.     s = (60 - sec) * 6 + 180
  145.     x = INT(SIN(s / 45 * 3.141592) * 180) + 325
  146.     y = INT(COS(s / 360 * 3.141592) * 180) + 225
  147.     GOSUB drawing2:
  148.     IF sec > 120 THEN
  149.         sec = 0
  150.         GOTO sixdone:
  151.     END IF
  152.     GOSUB keyboard:
  153.     GOSUB shoot:
  154.     GOSUB youshoot2:
  155.     GOTO six:
  156.     sixdone:
  157.  
  158. IF level = 7 THEN level = 1
  159.  
  160. GOTO go:
  161. 'GOTO goes back to the start of the main loop.
  162.  
  163. 'Draws the enemy tank and erases it for animation.
  164. drawing:
  165. x2 = x + xx: y2 = y + yy
  166. LINE (x2, y2)-(x2 - 10, y2 - 10), _RGB32(c1, c2, c3)
  167. LINE (x2 + 20, y2)-(x2 + 30, y2 - 10), _RGB32(c1, c2, c3)
  168. CIRCLE (x2 - 15, y2 - 15), 5, _RGB32(c1, c2, c3)
  169. CIRCLE (x2 + 35, y2 - 15), 5, _RGB32(c1, c2, c3)
  170. LINE (x2, y2)-(x2 + 20, y2 + 20), _RGB32(c1, c2, c3), BF
  171. LINE (x2 + 5, y2 + 5)-(x2 + 8, y2 + 8), _RGB32(0, 0, 0), BF
  172. LINE (x2 + 12, y2 + 5)-(x2 + 15, y2 + 8), _RGB32(0, 0, 0), BF
  173. LINE (x2 + 5, y2 + 13)-(x2 + 15, y2 + 16), _RGB32(0, 0, 0), BF
  174. _DELAY .004
  175. LINE (x2, y2)-(x2 + 20, y2 + 20), _RGB32(0, 0, 0), BF
  176. LINE (x2, y2)-(x2 - 10, y2 - 10), _RGB32(0, 0, 0)
  177. LINE (x2 + 20, y2)-(x2 + 30, y2 - 10), _RGB32(0, 0, 0)
  178. CIRCLE (x2 - 15, y2 - 15), 5, _RGB32(0, 0, 0)
  179. CIRCLE (x2 + 35, y2 - 15), 5, _RGB32(0, 0, 0)
  180.  
  181.  
  182. 'Draws the Boss Robot.
  183. drawing2:
  184. x2 = x + xx: y2 = y + yy
  185. CIRCLE (x2, y2), 10, _RGB32(c1, c2, c3)
  186. LINE (x2 - 5, y2 - 5)-(x2 - 3, y2 - 2), _RGB32(c1, c2, c3), BF
  187. LINE (x2 + 6, y2 - 5)-(x2 + 8, y2 - 2), _RGB32(c1, c2, c3), BF
  188. LINE (x2 - 4, y2 + 7)-(x2 + 4, y2 + 8), _RGB32(c1, c2, c3), BF
  189. LINE (x2, y2 - 10)-(x2, y2 - 20), _RGB32(c1, c2, c3)
  190. CIRCLE (x2, y2 - 24), 4, _RGB32(c1, c2, c3)
  191. LINE (x2, y2 - 20)-(x2 - 10, y2 - 30), _RGB32(c1, c2, c3)
  192. LINE (x2, y2 - 20)-(x2 + 10, y2 - 30), _RGB32(c1, c2, c3)
  193. _DELAY .004
  194. CIRCLE (x2, y2), 10, _RGB32(0, 0, 0)
  195. LINE (x2 - 5, y2 - 5)-(x2 - 3, y2 - 2), _RGB32(0, 0, 0), BF
  196. LINE (x2 + 6, y2 - 5)-(x2 + 8, y2 - 2), _RGB32(0, 0, 0), BF
  197. LINE (x2 - 7, y2 + 7)-(x2 + 8, y2 + 8), _RGB32(0, 0, 0), BF
  198. LINE (x2, y2 - 10)-(x2, y2 - 20), _RGB32(0, 0, 0)
  199. CIRCLE (x2, y2 - 24), 4, _RGB32(0, 0, 0)
  200. LINE (x2, y2 - 20)-(x2 - 10, y2 - 30), _RGB32(0, 0, 0)
  201. LINE (x2, y2 - 20)-(x2 + 10, y2 - 30), _RGB32(0, 0, 0)
  202.  
  203. 'Keyboard control for your movement and shooting.
  204. keyboard:
  205. _LIMIT 1000
  206. a$ = INKEY$
  207. IF a$ = CHR$(27) THEN END
  208. IF a$ = CHR$(0) + CHR$(77) THEN r = 1: l = 0
  209. IF r = 1 THEN
  210.     LINE (xt, yt)-(xt + 20, yt + 20), _RGB32(0, 0, 0), BF
  211.     LINE (xt + 10, yt)-(xt + 10, yt - 10), _RGB32(0, 0, 0)
  212.     xt = xt + 1
  213.     IF xt > 780 THEN xt = 780
  214.     LINE (xt, yt)-(xt + 20, yt + 20), _RGB32(128, 139, 255), BF
  215.     LINE (xt + 10, yt)-(xt + 10, yt - 10), _RGB32(128, 139, 255)
  216. IF a$ = CHR$(0) + CHR$(75) THEN l = 1: r = 0
  217. IF l = 1 THEN
  218.     LINE (xt, yt)-(xt + 20, yt + 20), _RGB32(0, 0, 0), BF
  219.     LINE (xt + 10, yt)-(xt + 10, yt - 10), _RGB32(0, 0, 0)
  220.     xt = xt - 1
  221.     IF xt < 0 THEN xt = 0
  222.     LINE (xt, yt)-(xt + 20, yt + 20), _RGB32(128, 139, 255), BF
  223.     LINE (xt + 10, yt)-(xt + 10, yt - 10), _RGB32(128, 139, 255)
  224. IF a$ = CHR$(0) + CHR$(72) OR a$ = CHR$(0) + CHR$(80) THEN
  225.     r = 0: l = 0
  226.  
  227. IF a$ = " " THEN GOSUB youshoot:
  228.  
  229. 'The start of your shot.
  230. youshoot:
  231. _LIMIT 1000
  232. IF ushoot = 0 THEN
  233.     sx2 = xt + 10
  234.     sy2 = yt - 11
  235.     ushoot = 1
  236.     SOUND 400, .5
  237.  
  238. 'The drawing and movement of your shot and if it reaches the enemy.
  239. youshoot2:
  240. _LIMIT 1000
  241. IF ushoot = 1 THEN
  242.     CIRCLE (sx2, sy2), 5, _RGB32(0, 0, 0)
  243.     sy2 = sy2 - 3
  244.     IF sy2 < 0 THEN ushoot = 0: RETURN
  245.     CIRCLE (sx2, sy2), 5, _RGB32(255, 0, 0)
  246.     IF sx2 > x2 - 21 AND sx2 < x2 + 41 AND sy2 > y2 - 11 AND sy2 < y2 + 21 THEN
  247.         CIRCLE (sx2, sy2), 5, _RGB32(0, 0, 0)
  248.         SOUND 200, 1
  249.         SOUND 100, 1
  250.         FOR explosion = 1 TO 30
  251.             CIRCLE (x2 + 10, y2 + 10), explosion, _RGB32(255, 0, 0)
  252.             _DELAY .02
  253.             CIRCLE (x2 + 10, y2 + 10), explosion, _RGB32(0, 0, 0)
  254.         NEXT explosion
  255.         LINE (x2 - 21, y2 - 21)-(x2 + 41, y2 + 41), _RGB32(0, 0, 0), BF
  256.         points = points + 100
  257.         IF points / 500 = INT(points / 500) THEN level = level + 1: level2 = level2 + 1
  258.         lives$ = STR$(lives)
  259.         points$ = STR$(points)
  260.         level$ = STR$(level2)
  261.         _TITLE "Tech Invaders      Lives: " + lives$ + "     Level: " + level$ + "      Score: " + points$
  262.         ushoot = 0
  263.         GOTO go:
  264.     END IF
  265.  
  266. 'The enemy's shot and if it reaches you.
  267. shoot:
  268. _LIMIT 1000
  269. IF shooting = 0 THEN
  270.     IF level2 = 1 THEN shh = 9970
  271.     IF level2 = 2 THEN shh = 9968
  272.     IF level2 = 3 THEN shh = 9966
  273.     IF level2 = 4 THEN shh = 9964
  274.     IF level2 = 5 THEN shh = 9962
  275.     IF level2 = 6 THEN shh = 9940
  276.     IF level2 > 6 THEN shh = 9930
  277.     sh = INT(RND * 10000) + 1
  278.     IF sh < shh THEN RETURN
  279.     sx = x2 + 10
  280.     sy = y2 + 10
  281.     shooting = 1
  282.     SOUND 300, .5
  283. IF shooting = 1 THEN
  284.     CIRCLE (sx, sy), 5, _RGB32(0, 0, 0)
  285.     sy = sy + 3
  286.     IF sy > 620 THEN shooting = 0: RETURN
  287.     CIRCLE (sx, sy), 5, _RGB32(255, 0, 0)
  288.     IF sx > xt - 1 AND sx < xt + 21 AND sy > yt - 1 AND sy < yt + 21 THEN
  289.         CIRCLE (sx, sy), 5, _RGB32(0, 0, 0)
  290.         SOUND 200, 1
  291.         SOUND 100, 1
  292.         FOR explosion2 = 1 TO 30
  293.             CIRCLE (xt + 10, yt + 10), explosion2, _RGB32(255, 0, 0)
  294.             _DELAY .02
  295.             CIRCLE (xt + 10, yt + 10), explosion2, _RGB32(0, 0, 0)
  296.         NEXT explosion2
  297.         lives = lives - 1
  298.         lives$ = STR$(lives)
  299.         points$ = STR$(points)
  300.         level$ = STR$(level2)
  301.         _TITLE "Tech Invaders      Lives: " + lives$ + "     Level: " + level$ + "      Score: " + points$
  302.         LINE (xt - 22, yt - 42)-(xt + 42, yt + 42), _RGB32(0, 0, 0), BF
  303.         IF lives = 0 THEN
  304.             LOCATE 20, 40: PRINT "G A M E   O V E R"
  305.             LOCATE 22, 40: PRINT "Score: "; points
  306.             LOCATE 23, 40: PRINT "Level: "; level2
  307.             LOCATE 24, 40: INPUT "Play Again (Yes/No)", ag$
  308.             IF ag$ = "Y" OR ag$ = "y" OR ag$ = "YES" OR ag$ = "yes" OR ag$ = "Yes" OR ag$ = "YEs" OR ag$ = "yES" OR ag$ = "yeS" THEN GOTO begin:
  309.             END
  310.         END IF
  311.         shooting = 0
  312.         RETURN
  313.     END IF
  314.  
  315.  
  316.  

Title: Re: Robot Invaders
Post by: bplus on July 23, 2019, 10:31:11 pm
Love it! sure beats ping pong!
Title: Re: Robot Invaders
Post by: SierraKen on July 24, 2019, 12:07:34 am
LOL! Thanks!

Tonight I added a Top Ten Scores sheet to it, using the Race Car one we made a few days ago. So if you run this, it will automatically make a file called TopTenTech.txt and it will put it in the same directory as the program you run this in. I added a few new names and a couple of the old ones and of course adjusted the scores to this game. Have fun!

(Note: I changed the looks of the Boss Robot to look more like a robot on the code after this on the forum page. )

Code: QB64: [Select]
  1. 'This version has 5 different colored robots with a Boss Robot after that.
  2. 'Each robot flies a different pattern.
  3. 'Game made on July 22, 2019
  4. 'By Ken G.
  5. 'Freeware
  6. 'I have put some descriptions in the code below to make it easier to learn from.
  7. begin:
  8. DIM name$(50), nm$(50), score(50), sccc(50)
  9. _TITLE "Tech Invaders"
  10. SCREEN _NEWIMAGE(800, 600, 32)
  11. PRINT "                                 T E C H      I N V A D E R S"
  12. PRINT "                                        by Ken G."
  13. PRINT "                       Use left and right arrow keys to move back and forth."
  14. PRINT "                            Use up or down arrow keys to stop moving."
  15. PRINT "                                    Use space bar to fire."
  16. PRINT "                                      Esc to end anytime."
  17. INPUT "                                   Press Enter to start.", start$
  18. lives = 5
  19. points = 0
  20. ushoot = 0
  21. shooting = 0
  22. level = 1
  23. level2 = 1
  24. start = 0
  25. s = 0
  26. xt = 400: yt = 550
  27.  
  28. 'Draw your shooter.
  29. LINE (xt, yt)-(xt + 20, yt + 20), _RGB32(128, 139, 255), BF
  30. LINE (xt + 10, yt)-(xt + 10, yt - 10), _RGB32(128, 139, 255)
  31.  
  32.  
  33. 'This is the start of the main loop.
  34. go:
  35. 'Choose a random place for the enemy.
  36. xx = INT(RND * 200) + 100
  37. yy = INT(RND * 100) + 40
  38.  
  39. 'Each level has its own loop so it can set a different equation and speed of the enemy.
  40.  
  41. IF level = 1 THEN
  42.     cl = 128: c2 = 127: c3 = 255
  43.     one:
  44.     'sec is not time, it's related to the coordinate of the enemy and speed it goes related to the loop speed.
  45.     sec = sec + .01
  46.     s = (60 - sec) * 6 + 180
  47.     x = INT(SIN(s / 180 * 3.141592) * 180) + 325
  48.     y = INT(COS(s / 180 * 3.141592) * 180) + 225
  49.  
  50.     'GOSUB to drawing draws the enemy robot.
  51.     GOSUB drawing:
  52.     IF sec > 180 THEN
  53.         sec = 0
  54.         GOTO onedone:
  55.     END IF
  56.  
  57.     'GOSUB's go to keyboard control and enemy shooting.
  58.     GOSUB keyboard:
  59.     GOSUB shoot:
  60.     GOSUB youshoot2:
  61.     GOTO one:
  62.     onedone:
  63.  
  64. 'This level uses the spiral equation so it's a bit different than the others.
  65. IF level = 2 THEN
  66.     c1 = 127: c2 = 216: c3 = 127
  67.     FOR d = 160 TO 0 STEP -.125
  68.         _LIMIT 1000
  69.         s = s + .2
  70.         x = COS(s * 3.141592 / 180) * d
  71.         y = SIN(s * 3.151492 / 180) * d
  72.         GOSUB drawing:
  73.         GOSUB keyboard:
  74.         GOSUB shoot:
  75.         GOSUB youshoot2:
  76.     NEXT d
  77.     FOR d = 0 TO 160 STEP .125
  78.         _LIMIT 1000
  79.         s = s - .2
  80.         x = COS(s * 3.141592 / 180) * d
  81.         y = SIN(s * 3.151492 / 180) * d
  82.         GOSUB drawing:
  83.         GOSUB keyboard:
  84.         GOSUB shoot:
  85.         GOSUB youshoot2:
  86.     NEXT d
  87.  
  88. IF level = 3 THEN
  89.     c1 = 255: c2 = 0: c3 = 0
  90.     three:
  91.     sec = sec + .01
  92.     s = (60 - sec) * 6 + 180
  93.     x = INT(SIN(s / 90 * 3.141592) * 180) + 325
  94.     y = INT(COS(s / 180 * 3.141592) * 180) + 225
  95.     GOSUB drawing:
  96.     IF sec > 60 THEN
  97.         sec = 0
  98.         GOTO threedone:
  99.     END IF
  100.     GOSUB keyboard:
  101.     GOSUB shoot:
  102.     GOSUB youshoot2:
  103.     GOTO three:
  104.     threedone:
  105.  
  106. IF level = 4 THEN
  107.     c1 = 255: c2 = 255: c3 = 127
  108.     four:
  109.     sec = sec + .01
  110.     s = (60 - sec) * 6 + 180
  111.     x = INT(SIN(s / 180 * 3.141592) * 180) + 325
  112.     y = INT(COS(s / 90 * 3.141592) * 180) + 225
  113.     GOSUB drawing:
  114.     IF sec > 60 THEN
  115.         sec = 0
  116.         GOTO fourdone:
  117.     END IF
  118.     GOSUB keyboard:
  119.     GOSUB shoot:
  120.     GOSUB youshoot2:
  121.     GOTO four:
  122.     fourdone:
  123. IF level = 5 THEN
  124.     c1 = 133: c2 = 28: c3 = 255
  125.     five:
  126.     sec = sec + .01
  127.     s = (60 - sec) * 6 + 180
  128.     x = INT(SIN(s / 135 * 3.141592) * 180) + 325
  129.     y = INT(COS(s / 33.75 * 3.141592) * 180) + 225
  130.     GOSUB drawing:
  131.     IF sec > 60 THEN
  132.         sec = 0
  133.         GOTO fivedone:
  134.     END IF
  135.     GOSUB keyboard:
  136.     GOSUB shoot:
  137.     GOSUB youshoot2:
  138.     GOTO five:
  139.     fivedone:
  140.  
  141. IF level = 6 THEN
  142.     c1 = 255: c2 = 0: c3 = 0
  143.     six:
  144.     sec = sec + .02
  145.     s = (60 - sec) * 6 + 180
  146.     x = INT(SIN(s / 45 * 3.141592) * 180) + 325
  147.     y = INT(COS(s / 360 * 3.141592) * 180) + 225
  148.     GOSUB drawing2:
  149.     IF sec > 120 THEN
  150.         sec = 0
  151.         GOTO sixdone:
  152.     END IF
  153.     GOSUB keyboard:
  154.     GOSUB shoot:
  155.     GOSUB youshoot2:
  156.     GOTO six:
  157.     sixdone:
  158.  
  159. IF level = 7 THEN level = 1
  160.  
  161. GOTO go:
  162. 'GOTO goes back to the start of the main loop.
  163.  
  164. 'Draws the enemy tank and erases it for animation.
  165. drawing:
  166. x2 = x + xx: y2 = y + yy
  167. LINE (x2, y2)-(x2 - 10, y2 - 10), _RGB32(c1, c2, c3)
  168. LINE (x2 + 20, y2)-(x2 + 30, y2 - 10), _RGB32(c1, c2, c3)
  169. CIRCLE (x2 - 15, y2 - 15), 5, _RGB32(c1, c2, c3)
  170. CIRCLE (x2 + 35, y2 - 15), 5, _RGB32(c1, c2, c3)
  171. LINE (x2, y2)-(x2 + 20, y2 + 20), _RGB32(c1, c2, c3), BF
  172. LINE (x2 + 5, y2 + 5)-(x2 + 8, y2 + 8), _RGB32(0, 0, 0), BF
  173. LINE (x2 + 12, y2 + 5)-(x2 + 15, y2 + 8), _RGB32(0, 0, 0), BF
  174. LINE (x2 + 5, y2 + 13)-(x2 + 15, y2 + 16), _RGB32(0, 0, 0), BF
  175. _DELAY .004
  176. LINE (x2, y2)-(x2 + 20, y2 + 20), _RGB32(0, 0, 0), BF
  177. LINE (x2, y2)-(x2 - 10, y2 - 10), _RGB32(0, 0, 0)
  178. LINE (x2 + 20, y2)-(x2 + 30, y2 - 10), _RGB32(0, 0, 0)
  179. CIRCLE (x2 - 15, y2 - 15), 5, _RGB32(0, 0, 0)
  180. CIRCLE (x2 + 35, y2 - 15), 5, _RGB32(0, 0, 0)
  181.  
  182.  
  183. 'Draws the Boss Robot.
  184. drawing2:
  185. x2 = x + xx: y2 = y + yy
  186. CIRCLE (x2, y2), 10, _RGB32(c1, c2, c3)
  187. LINE (x2 - 5, y2 - 5)-(x2 - 3, y2 - 2), _RGB32(c1, c2, c3), BF
  188. LINE (x2 + 6, y2 - 5)-(x2 + 8, y2 - 2), _RGB32(c1, c2, c3), BF
  189. LINE (x2 - 4, y2 + 7)-(x2 + 4, y2 + 8), _RGB32(c1, c2, c3), BF
  190. LINE (x2, y2 - 10)-(x2, y2 - 20), _RGB32(c1, c2, c3)
  191. CIRCLE (x2, y2 - 24), 4, _RGB32(c1, c2, c3)
  192. LINE (x2, y2 - 20)-(x2 - 10, y2 - 30), _RGB32(c1, c2, c3)
  193. LINE (x2, y2 - 20)-(x2 + 10, y2 - 30), _RGB32(c1, c2, c3)
  194. _DELAY .004
  195. CIRCLE (x2, y2), 10, _RGB32(0, 0, 0)
  196. LINE (x2 - 5, y2 - 5)-(x2 - 3, y2 - 2), _RGB32(0, 0, 0), BF
  197. LINE (x2 + 6, y2 - 5)-(x2 + 8, y2 - 2), _RGB32(0, 0, 0), BF
  198. LINE (x2 - 7, y2 + 7)-(x2 + 8, y2 + 8), _RGB32(0, 0, 0), BF
  199. LINE (x2, y2 - 10)-(x2, y2 - 20), _RGB32(0, 0, 0)
  200. CIRCLE (x2, y2 - 24), 4, _RGB32(0, 0, 0)
  201. LINE (x2, y2 - 20)-(x2 - 10, y2 - 30), _RGB32(0, 0, 0)
  202. LINE (x2, y2 - 20)-(x2 + 10, y2 - 30), _RGB32(0, 0, 0)
  203.  
  204. 'Keyboard control for your movement and shooting.
  205. keyboard:
  206. _LIMIT 1000
  207. a$ = INKEY$
  208. IF a$ = CHR$(27) THEN END
  209. IF a$ = CHR$(0) + CHR$(77) THEN r = 1: l = 0
  210. IF r = 1 THEN
  211.     LINE (xt, yt)-(xt + 20, yt + 20), _RGB32(0, 0, 0), BF
  212.     LINE (xt + 10, yt)-(xt + 10, yt - 10), _RGB32(0, 0, 0)
  213.     xt = xt + 1
  214.     IF xt > 780 THEN xt = 780
  215.     LINE (xt, yt)-(xt + 20, yt + 20), _RGB32(128, 139, 255), BF
  216.     LINE (xt + 10, yt)-(xt + 10, yt - 10), _RGB32(128, 139, 255)
  217. IF a$ = CHR$(0) + CHR$(75) THEN l = 1: r = 0
  218. IF l = 1 THEN
  219.     LINE (xt, yt)-(xt + 20, yt + 20), _RGB32(0, 0, 0), BF
  220.     LINE (xt + 10, yt)-(xt + 10, yt - 10), _RGB32(0, 0, 0)
  221.     xt = xt - 1
  222.     IF xt < 0 THEN xt = 0
  223.     LINE (xt, yt)-(xt + 20, yt + 20), _RGB32(128, 139, 255), BF
  224.     LINE (xt + 10, yt)-(xt + 10, yt - 10), _RGB32(128, 139, 255)
  225. IF a$ = CHR$(0) + CHR$(72) OR a$ = CHR$(0) + CHR$(80) THEN
  226.     r = 0: l = 0
  227.  
  228. IF a$ = " " THEN GOSUB youshoot:
  229.  
  230. 'The start of your shot.
  231. youshoot:
  232. _LIMIT 1000
  233. IF ushoot = 0 THEN
  234.     sx2 = xt + 10
  235.     sy2 = yt - 11
  236.     ushoot = 1
  237.     SOUND 400, .5
  238.  
  239. 'The drawing and movement of your shot and if it reaches the enemy.
  240. youshoot2:
  241. _LIMIT 1000
  242. IF ushoot = 1 THEN
  243.     CIRCLE (sx2, sy2), 5, _RGB32(0, 0, 0)
  244.     sy2 = sy2 - 3
  245.     IF sy2 < 0 THEN ushoot = 0: RETURN
  246.     CIRCLE (sx2, sy2), 5, _RGB32(255, 0, 0)
  247.     IF sx2 > x2 - 21 AND sx2 < x2 + 41 AND sy2 > y2 - 11 AND sy2 < y2 + 21 THEN
  248.         CIRCLE (sx2, sy2), 5, _RGB32(0, 0, 0)
  249.         SOUND 200, 1
  250.         SOUND 100, 1
  251.         FOR explosion = 1 TO 30
  252.             CIRCLE (x2 + 10, y2 + 10), explosion, _RGB32(255, 0, 0)
  253.             _DELAY .02
  254.             CIRCLE (x2 + 10, y2 + 10), explosion, _RGB32(0, 0, 0)
  255.         NEXT explosion
  256.         LINE (x2 - 21, y2 - 21)-(x2 + 41, y2 + 41), _RGB32(0, 0, 0), BF
  257.         points = points + 100
  258.         IF points / 500 = INT(points / 500) THEN level = level + 1: level2 = level2 + 1
  259.         lives$ = STR$(lives)
  260.         points$ = STR$(points)
  261.         level$ = STR$(level2)
  262.         _TITLE "Tech Invaders      Lives: " + lives$ + "     Level: " + level$ + "      Score: " + points$
  263.         ushoot = 0
  264.         GOTO go:
  265.     END IF
  266.  
  267. 'The enemy's shot and if it reaches you.
  268. shoot:
  269. _LIMIT 1000
  270. IF shooting = 0 THEN
  271.     IF level2 = 1 THEN shh = 9970
  272.     IF level2 = 2 THEN shh = 9968
  273.     IF level2 = 3 THEN shh = 9966
  274.     IF level2 = 4 THEN shh = 9964
  275.     IF level2 = 5 THEN shh = 9962
  276.     IF level2 = 6 THEN shh = 9940
  277.     IF level2 > 6 THEN shh = 9930
  278.     sh = INT(RND * 10000) + 1
  279.     IF sh < shh THEN RETURN
  280.     sx = x2 + 10
  281.     sy = y2 + 10
  282.     shooting = 1
  283.     SOUND 300, .5
  284. IF shooting = 1 THEN
  285.     CIRCLE (sx, sy), 5, _RGB32(0, 0, 0)
  286.     sy = sy + 3
  287.     IF sy > 620 THEN shooting = 0: RETURN
  288.     CIRCLE (sx, sy), 5, _RGB32(255, 0, 0)
  289.     IF sx > xt - 1 AND sx < xt + 21 AND sy > yt - 1 AND sy < yt + 21 THEN
  290.         CIRCLE (sx, sy), 5, _RGB32(0, 0, 0)
  291.         SOUND 200, 1
  292.         SOUND 100, 1
  293.         FOR explosion2 = 1 TO 30
  294.             CIRCLE (xt + 10, yt + 10), explosion2, _RGB32(255, 0, 0)
  295.             _DELAY .02
  296.             CIRCLE (xt + 10, yt + 10), explosion2, _RGB32(0, 0, 0)
  297.         NEXT explosion2
  298.         lives = lives - 1
  299.         lives$ = STR$(lives)
  300.         points$ = STR$(points)
  301.         level$ = STR$(level2)
  302.         _TITLE "Tech Invaders      Lives: " + lives$ + "     Level: " + level$ + "      Score: " + points$
  303.         LINE (xt - 22, yt - 42)-(xt + 42, yt + 42), _RGB32(0, 0, 0), BF
  304.         IF lives = 0 THEN
  305.             LOCATE 20, 40: PRINT "G A M E   O V E R"
  306.             LOCATE 22, 40: PRINT "Score: "; points
  307.             LOCATE 23, 40: PRINT "Level: "; level2
  308.             LOCATE 25, 40: INPUT "Press Enter to go to Top Ten Scores.", tt$
  309.  
  310.             'Top Ten Scores
  311.             scc = points
  312.             IF _FILEEXISTS("toptentech.txt") THEN
  313.             ELSE
  314.                 OPEN "toptentech.txt" FOR OUTPUT AS #1
  315.                 RESTORE originaltopten
  316.                 DO
  317.                     READ toptenname$, toptenscore!
  318.                     IF toptenname$ = "EOF" THEN EXIT DO
  319.                     PRINT #1, toptenname$
  320.                     PRINT #1, toptenscore!
  321.                 LOOP
  322.                 CLOSE #1
  323.             END IF
  324.  
  325.             OPEN "toptentech.txt" FOR INPUT AS #1
  326.             FOR n = 1 TO 10
  327.                 INPUT #1, name$(n)
  328.                 INPUT #1, score(n)
  329.                 IF scc > score(n) AND sct = 0 THEN
  330.                     nn = n
  331.                     PRINT "You have made the Top Ten!"
  332.                     typename:
  333.                     INPUT "Type your name here (25 letters and spaces maximum.):", nm$(nn)
  334.                     IF LEN(nm$(nn)) > 25 THEN
  335.                         PRINT "Name too long, try again."
  336.                         GOTO typename:
  337.                     END IF
  338.                     sccc(nn) = scc
  339.                     sct = 1
  340.                 END IF
  341.                 IF n = 10 AND sct = 0 THEN CLOSE #1: GOTO nex7:
  342.             NEXT n
  343.             CLOSE #1
  344.             nex5:
  345.             CLOSE #1
  346.             OPEN "toptentech.txt" FOR OUTPUT AS #1
  347.             FOR n = 1 TO nn
  348.                 IF n <> nn THEN PRINT #1, name$(n): PRINT #1, score(n)
  349.                 IF n = nn THEN
  350.                     PRINT #1, nm$(n)
  351.                     PRINT #1, sccc(n)
  352.                 END IF
  353.             NEXT n
  354.             nex6:
  355.             FOR n = nn TO 10
  356.                 PRINT #1, name$(n): PRINT #1, score(n)
  357.             NEXT n
  358.  
  359.             CLOSE #1
  360.             nex7:
  361.             CLS
  362.             PRINT: PRINT: PRINT
  363.             PRINT "                                 T O P    T E N "
  364.             PRINT: PRINT: PRINT
  365.             OPEN "toptentech.txt" FOR INPUT AS #1
  366.             FOR n = 1 TO 10
  367.                 IF EOF(1) THEN GOTO nex8:
  368.                 INPUT #1, name$(n)
  369.                 INPUT #1, score(n)
  370.                 PRINT "             "; n; ". "; name$(n); score(n)
  371.             NEXT n
  372.             nex8:
  373.             CLOSE #1
  374.             FOR n = 1 TO 10
  375.                 nm$(n) = ""
  376.                 score(n) = 0
  377.                 name$(n) = ""
  378.                 sccc(n) = 0
  379.             NEXT n
  380.             nn = 0
  381.             n = 0
  382.             sct = 0
  383.             scc = 0
  384.             LOCATE 23, 1
  385.             INPUT "Would you like to play again? (Yes/No)", ag$
  386.             IF ag$ = "y" OR ag$ = "Y" OR ag$ = "YES" OR ag$ = "yes" OR ag$ = "Yes" OR ag$ = "yES" OR ag$ = "yeS" OR ag$ = "YEs" THEN GOTO begin:
  387.             END
  388.         END IF
  389.         shooting = 0
  390.         RETURN
  391.     END IF
  392.  
  393. originaltopten:
  394. DATA Space Ace,7000
  395. DATA Suzy Swift,6000
  396. DATA Speedy Spencer,5000
  397. DATA Super Sam,4000
  398. DATA Battery Bob,3000
  399. DATA Karen Kryptonite,2750
  400. DATA Quick Ken,2500
  401. DATA Tiger Tessa,2250
  402. DATA Arcade Joe,2000
  403. DATA How Do U Play,1750
  404.  
Title: Re: Robot Invaders
Post by: SierraKen on July 24, 2019, 01:09:04 am
Lastly (I hope), I decided to change the looks of the Boss Robot to make him look more like a robot. Here is the code again, sorry for so many of them.

(Note: Woops, I have a slight color variable problem on one line on this, will post the fix after this posting.)

Code: QB64: [Select]
  1. 'This version has 5 different colored robots with a Boss Robot after that.
  2. 'Each robot flies a different pattern.
  3. 'Game made on July 22, 2019
  4. 'By Ken G.
  5. 'Freeware
  6. 'I have put some descriptions in the code below to make it easier to learn from.
  7. begin:
  8. DIM name$(50), nm$(50), score(50), sccc(50)
  9. _TITLE "Tech Invaders"
  10. SCREEN _NEWIMAGE(800, 600, 32)
  11. PRINT "                                 T E C H      I N V A D E R S"
  12. PRINT "                                        by Ken G."
  13. PRINT "                       Use left and right arrow keys to move back and forth."
  14. PRINT "                            Use up or down arrow keys to stop moving."
  15. PRINT "                                    Use space bar to fire."
  16. PRINT "                                      Esc to end anytime."
  17. INPUT "                                   Press Enter to start.", start$
  18. lives = 5
  19. points = 0
  20. ushoot = 0
  21. shooting = 0
  22. level = 1
  23. level2 = 1
  24. start = 0
  25. s = 0
  26. xt = 400: yt = 550
  27.  
  28. 'Draw your shooter.
  29. LINE (xt, yt)-(xt + 20, yt + 20), _RGB32(128, 139, 255), BF
  30. LINE (xt + 10, yt)-(xt + 10, yt - 10), _RGB32(128, 139, 255)
  31.  
  32.  
  33. 'This is the start of the main loop.
  34. go:
  35. 'Choose a random place for the enemy.
  36. xx = INT(RND * 200) + 100
  37. yy = INT(RND * 100) + 40
  38.  
  39. 'Each level has its own loop so it can set a different equation and speed of the enemy.
  40.  
  41. IF level = 1 THEN
  42.     cl = 128: c2 = 127: c3 = 255
  43.     one:
  44.     'sec is not time, it's related to the coordinate of the enemy and speed it goes related to the loop speed.
  45.     sec = sec + .01
  46.     s = (60 - sec) * 6 + 180
  47.     x = INT(SIN(s / 180 * 3.141592) * 180) + 325
  48.     y = INT(COS(s / 180 * 3.141592) * 180) + 225
  49.  
  50.     'GOSUB to drawing draws the enemy robot.
  51.     GOSUB drawing:
  52.     IF sec > 180 THEN
  53.         sec = 0
  54.         GOTO onedone:
  55.     END IF
  56.  
  57.     'GOSUB's go to keyboard control and enemy shooting.
  58.     GOSUB keyboard:
  59.     GOSUB shoot:
  60.     GOSUB youshoot2:
  61.     GOTO one:
  62.     onedone:
  63.  
  64. 'This level uses the spiral equation so it's a bit different than the others.
  65. IF level = 2 THEN
  66.     c1 = 127: c2 = 216: c3 = 127
  67.     FOR d = 160 TO 0 STEP -.125
  68.         _LIMIT 1000
  69.         s = s + .2
  70.         x = COS(s * 3.141592 / 180) * d
  71.         y = SIN(s * 3.151492 / 180) * d
  72.         GOSUB drawing:
  73.         GOSUB keyboard:
  74.         GOSUB shoot:
  75.         GOSUB youshoot2:
  76.     NEXT d
  77.     FOR d = 0 TO 160 STEP .125
  78.         _LIMIT 1000
  79.         s = s - .2
  80.         x = COS(s * 3.141592 / 180) * d
  81.         y = SIN(s * 3.151492 / 180) * d
  82.         GOSUB drawing:
  83.         GOSUB keyboard:
  84.         GOSUB shoot:
  85.         GOSUB youshoot2:
  86.     NEXT d
  87.  
  88. IF level = 3 THEN
  89.     c1 = 255: c2 = 0: c3 = 0
  90.     three:
  91.     sec = sec + .01
  92.     s = (60 - sec) * 6 + 180
  93.     x = INT(SIN(s / 90 * 3.141592) * 180) + 325
  94.     y = INT(COS(s / 180 * 3.141592) * 180) + 225
  95.     GOSUB drawing:
  96.     IF sec > 60 THEN
  97.         sec = 0
  98.         GOTO threedone:
  99.     END IF
  100.     GOSUB keyboard:
  101.     GOSUB shoot:
  102.     GOSUB youshoot2:
  103.     GOTO three:
  104.     threedone:
  105.  
  106. IF level = 4 THEN
  107.     c1 = 255: c2 = 255: c3 = 127
  108.     four:
  109.     sec = sec + .01
  110.     s = (60 - sec) * 6 + 180
  111.     x = INT(SIN(s / 180 * 3.141592) * 180) + 325
  112.     y = INT(COS(s / 90 * 3.141592) * 180) + 225
  113.     GOSUB drawing:
  114.     IF sec > 60 THEN
  115.         sec = 0
  116.         GOTO fourdone:
  117.     END IF
  118.     GOSUB keyboard:
  119.     GOSUB shoot:
  120.     GOSUB youshoot2:
  121.     GOTO four:
  122.     fourdone:
  123. IF level = 5 THEN
  124.     c1 = 133: c2 = 28: c3 = 255
  125.     five:
  126.     sec = sec + .01
  127.     s = (60 - sec) * 6 + 180
  128.     x = INT(SIN(s / 135 * 3.141592) * 180) + 325
  129.     y = INT(COS(s / 33.75 * 3.141592) * 180) + 225
  130.     GOSUB drawing:
  131.     IF sec > 60 THEN
  132.         sec = 0
  133.         GOTO fivedone:
  134.     END IF
  135.     GOSUB keyboard:
  136.     GOSUB shoot:
  137.     GOSUB youshoot2:
  138.     GOTO five:
  139.     fivedone:
  140.  
  141. IF level = 6 THEN
  142.     c1 = 255: c2 = 0: c3 = 0
  143.     six:
  144.     sec = sec + .02
  145.     s = (60 - sec) * 6 + 180
  146.     x = INT(SIN(s / 45 * 3.141592) * 180) + 325
  147.     y = INT(COS(s / 360 * 3.141592) * 180) + 225
  148.     GOSUB drawing2:
  149.     IF sec > 120 THEN
  150.         sec = 0
  151.         GOTO sixdone:
  152.     END IF
  153.     GOSUB keyboard:
  154.     GOSUB shoot:
  155.     GOSUB youshoot2:
  156.     GOTO six:
  157.     sixdone:
  158.  
  159. IF level = 7 THEN level = 1
  160.  
  161. GOTO go:
  162. 'GOTO goes back to the start of the main loop.
  163.  
  164. 'Draws the enemy tank and erases it for animation.
  165. drawing:
  166. x2 = x + xx: y2 = y + yy
  167. LINE (x2, y2)-(x2 - 10, y2 - 10), _RGB32(c1, c2, c3)
  168. LINE (x2 + 20, y2)-(x2 + 30, y2 - 10), _RGB32(c1, c2, c3)
  169. CIRCLE (x2 - 15, y2 - 15), 5, _RGB32(c1, c2, c3)
  170. CIRCLE (x2 + 35, y2 - 15), 5, _RGB32(c1, c2, c3)
  171. LINE (x2, y2)-(x2 + 20, y2 + 20), _RGB32(c1, c2, c3), BF
  172. LINE (x2 + 5, y2 + 5)-(x2 + 8, y2 + 8), _RGB32(0, 0, 0), BF
  173. LINE (x2 + 12, y2 + 5)-(x2 + 15, y2 + 8), _RGB32(0, 0, 0), BF
  174. LINE (x2 + 5, y2 + 13)-(x2 + 15, y2 + 16), _RGB32(0, 0, 0), BF
  175. _DELAY .004
  176. LINE (x2, y2)-(x2 + 20, y2 + 20), _RGB32(0, 0, 0), BF
  177. LINE (x2, y2)-(x2 - 10, y2 - 10), _RGB32(0, 0, 0)
  178. LINE (x2 + 20, y2)-(x2 + 30, y2 - 10), _RGB32(0, 0, 0)
  179. CIRCLE (x2 - 15, y2 - 15), 5, _RGB32(0, 0, 0)
  180. CIRCLE (x2 + 35, y2 - 15), 5, _RGB32(0, 0, 0)
  181.  
  182.  
  183. 'Draws the Boss Robot.
  184. drawing2:
  185. x2 = x + xx: y2 = y + yy
  186. LINE (x2 - 10, y2 - 10)-(x2 + 10, y2 + 10), _RGB32(c1, c2, c3), BF
  187. LINE (x2 - 4, y2 - 5)-(x2 - 2, y2 - 2), _RGB32(0, 0, 0), BF
  188. LINE (x2 + 6, y2 - 5)-(x2 + 8, y2 - 2), _RGB32(0, 0, 0), BF
  189. LINE (x2 - 4, y2 + 7)-(x2 + 4, y2 + 8), _RGB32(0, 0, 0), BF
  190. LINE (x2, y2 - 10)-(x2, y2 - 20), _RGB32(c1, c2, c3)
  191. CIRCLE (x2, y2 - 24), 4, _RGB32(c1, c2, c3)
  192. LINE (x2, y2 - 20)-(x2 - 10, y2 - 30), _RGB32(c1, c2, c3)
  193. LINE (x2, y2 - 20)-(x2 + 10, y2 - 30), _RGB32(c1, c2, c3)
  194. _DELAY .004
  195. LINE (x2 - 10, y2 - 10)-(x2 + 10, y2 + 10), _RGB32(0, 0, 0), BF
  196. LINE (x2, y2 - 10)-(x2, y2 - 20), _RGB32(0, 0, 0)
  197. CIRCLE (x2, y2 - 24), 4, _RGB32(0, 0, 0)
  198. LINE (x2, y2 - 20)-(x2 - 10, y2 - 30), _RGB32(0, 0, 0)
  199. LINE (x2, y2 - 20)-(x2 + 10, y2 - 30), _RGB32(0, 0, 0)
  200.  
  201. 'Keyboard control for your movement and shooting.
  202. keyboard:
  203. _LIMIT 1000
  204. a$ = INKEY$
  205. IF a$ = CHR$(27) THEN END
  206. IF a$ = CHR$(0) + CHR$(77) THEN r = 1: l = 0
  207. IF r = 1 THEN
  208.     LINE (xt, yt)-(xt + 20, yt + 20), _RGB32(0, 0, 0), BF
  209.     LINE (xt + 10, yt)-(xt + 10, yt - 10), _RGB32(0, 0, 0)
  210.     xt = xt + 1
  211.     IF xt > 780 THEN xt = 780
  212.     LINE (xt, yt)-(xt + 20, yt + 20), _RGB32(128, 139, 255), BF
  213.     LINE (xt + 10, yt)-(xt + 10, yt - 10), _RGB32(128, 139, 255)
  214. IF a$ = CHR$(0) + CHR$(75) THEN l = 1: r = 0
  215. IF l = 1 THEN
  216.     LINE (xt, yt)-(xt + 20, yt + 20), _RGB32(0, 0, 0), BF
  217.     LINE (xt + 10, yt)-(xt + 10, yt - 10), _RGB32(0, 0, 0)
  218.     xt = xt - 1
  219.     IF xt < 0 THEN xt = 0
  220.     LINE (xt, yt)-(xt + 20, yt + 20), _RGB32(128, 139, 255), BF
  221.     LINE (xt + 10, yt)-(xt + 10, yt - 10), _RGB32(128, 139, 255)
  222. IF a$ = CHR$(0) + CHR$(72) OR a$ = CHR$(0) + CHR$(80) THEN
  223.     r = 0: l = 0
  224.  
  225. IF a$ = " " THEN GOSUB youshoot:
  226.  
  227. 'The start of your shot.
  228. youshoot:
  229. _LIMIT 1000
  230. IF ushoot = 0 THEN
  231.     sx2 = xt + 10
  232.     sy2 = yt - 11
  233.     ushoot = 1
  234.     SOUND 400, .5
  235.  
  236. 'The drawing and movement of your shot and if it reaches the enemy.
  237. youshoot2:
  238. _LIMIT 1000
  239. IF ushoot = 1 THEN
  240.     CIRCLE (sx2, sy2), 5, _RGB32(0, 0, 0)
  241.     sy2 = sy2 - 3
  242.     IF sy2 < 0 THEN ushoot = 0: RETURN
  243.     CIRCLE (sx2, sy2), 5, _RGB32(255, 0, 0)
  244.     IF sx2 > x2 - 21 AND sx2 < x2 + 41 AND sy2 > y2 - 11 AND sy2 < y2 + 21 THEN
  245.         CIRCLE (sx2, sy2), 5, _RGB32(0, 0, 0)
  246.         SOUND 200, 1
  247.         SOUND 100, 1
  248.         FOR explosion = 1 TO 30
  249.             CIRCLE (x2 + 10, y2 + 10), explosion, _RGB32(255, 0, 0)
  250.             _DELAY .02
  251.             CIRCLE (x2 + 10, y2 + 10), explosion, _RGB32(0, 0, 0)
  252.         NEXT explosion
  253.         LINE (x2 - 21, y2 - 21)-(x2 + 41, y2 + 41), _RGB32(0, 0, 0), BF
  254.         points = points + 100
  255.         IF points / 500 = INT(points / 500) THEN level = level + 1: level2 = level2 + 1
  256.         lives$ = STR$(lives)
  257.         points$ = STR$(points)
  258.         level$ = STR$(level2)
  259.         _TITLE "Tech Invaders      Lives: " + lives$ + "     Level: " + level$ + "      Score: " + points$
  260.         ushoot = 0
  261.         GOTO go:
  262.     END IF
  263.  
  264. 'The enemy's shot and if it reaches you.
  265. shoot:
  266. _LIMIT 1000
  267. IF shooting = 0 THEN
  268.     IF level2 = 1 THEN shh = 9970
  269.     IF level2 = 2 THEN shh = 9968
  270.     IF level2 = 3 THEN shh = 9966
  271.     IF level2 = 4 THEN shh = 9964
  272.     IF level2 = 5 THEN shh = 9962
  273.     IF level2 = 6 THEN shh = 9940
  274.     IF level2 > 6 THEN shh = 9930
  275.     sh = INT(RND * 10000) + 1
  276.     IF sh < shh THEN RETURN
  277.     sx = x2 + 10
  278.     sy = y2 + 10
  279.     shooting = 1
  280.     SOUND 300, .5
  281. IF shooting = 1 THEN
  282.     CIRCLE (sx, sy), 5, _RGB32(0, 0, 0)
  283.     sy = sy + 3
  284.     IF sy > 620 THEN shooting = 0: RETURN
  285.     CIRCLE (sx, sy), 5, _RGB32(255, 0, 0)
  286.     IF sx > xt - 1 AND sx < xt + 21 AND sy > yt - 1 AND sy < yt + 21 THEN
  287.         CIRCLE (sx, sy), 5, _RGB32(0, 0, 0)
  288.         SOUND 200, 1
  289.         SOUND 100, 1
  290.         FOR explosion2 = 1 TO 30
  291.             CIRCLE (xt + 10, yt + 10), explosion2, _RGB32(255, 0, 0)
  292.             _DELAY .02
  293.             CIRCLE (xt + 10, yt + 10), explosion2, _RGB32(0, 0, 0)
  294.         NEXT explosion2
  295.         lives = lives - 1
  296.         lives$ = STR$(lives)
  297.         points$ = STR$(points)
  298.         level$ = STR$(level2)
  299.         _TITLE "Tech Invaders      Lives: " + lives$ + "     Level: " + level$ + "      Score: " + points$
  300.         LINE (xt - 22, yt - 42)-(xt + 42, yt + 42), _RGB32(0, 0, 0), BF
  301.         IF lives = 0 THEN
  302.             LOCATE 20, 40: PRINT "G A M E   O V E R"
  303.             LOCATE 22, 40: PRINT "Score: "; points
  304.             LOCATE 23, 40: PRINT "Level: "; level2
  305.             LOCATE 25, 40: INPUT "Press Enter to go to Top Ten Scores.", tt$
  306.  
  307.             'Top Ten Scores
  308.             scc = points
  309.             IF _FILEEXISTS("toptentech.txt") THEN
  310.             ELSE
  311.                 OPEN "toptentech.txt" FOR OUTPUT AS #1
  312.                 RESTORE originaltopten
  313.                 DO
  314.                     READ toptenname$, toptenscore!
  315.                     IF toptenname$ = "EOF" THEN EXIT DO
  316.                     PRINT #1, toptenname$
  317.                     PRINT #1, toptenscore!
  318.                 LOOP
  319.                 CLOSE #1
  320.             END IF
  321.  
  322.             OPEN "toptentech.txt" FOR INPUT AS #1
  323.             FOR n = 1 TO 10
  324.                 INPUT #1, name$(n)
  325.                 INPUT #1, score(n)
  326.                 IF scc > score(n) AND sct = 0 THEN
  327.                     nn = n
  328.                     PRINT "You have made the Top Ten!"
  329.                     typename:
  330.                     INPUT "Type your name here (25 letters and spaces maximum.):", nm$(nn)
  331.                     IF LEN(nm$(nn)) > 25 THEN
  332.                         PRINT "Name too long, try again."
  333.                         GOTO typename:
  334.                     END IF
  335.                     sccc(nn) = scc
  336.                     sct = 1
  337.                 END IF
  338.                 IF n = 10 AND sct = 0 THEN CLOSE #1: GOTO nex7:
  339.             NEXT n
  340.             CLOSE #1
  341.             nex5:
  342.             CLOSE #1
  343.             OPEN "toptentech.txt" FOR OUTPUT AS #1
  344.             FOR n = 1 TO nn
  345.                 IF n <> nn THEN PRINT #1, name$(n): PRINT #1, score(n)
  346.                 IF n = nn THEN
  347.                     PRINT #1, nm$(n)
  348.                     PRINT #1, sccc(n)
  349.                 END IF
  350.             NEXT n
  351.             nex6:
  352.             FOR n = nn TO 10
  353.                 PRINT #1, name$(n): PRINT #1, score(n)
  354.             NEXT n
  355.  
  356.             CLOSE #1
  357.             nex7:
  358.             CLS
  359.             PRINT: PRINT: PRINT
  360.             PRINT "                                 T O P    T E N "
  361.             PRINT: PRINT: PRINT
  362.             OPEN "toptentech.txt" FOR INPUT AS #1
  363.             FOR n = 1 TO 10
  364.                 IF EOF(1) THEN GOTO nex8:
  365.                 INPUT #1, name$(n)
  366.                 INPUT #1, score(n)
  367.                 PRINT "             "; n; ". "; name$(n); score(n)
  368.             NEXT n
  369.             nex8:
  370.             CLOSE #1
  371.             FOR n = 1 TO 10
  372.                 nm$(n) = ""
  373.                 score(n) = 0
  374.                 name$(n) = ""
  375.                 sccc(n) = 0
  376.             NEXT n
  377.             nn = 0
  378.             n = 0
  379.             sct = 0
  380.             scc = 0
  381.             LOCATE 23, 1
  382.             INPUT "Would you like to play again? (Yes/No)", ag$
  383.             IF ag$ = "y" OR ag$ = "Y" OR ag$ = "YES" OR ag$ = "yes" OR ag$ = "Yes" OR ag$ = "yES" OR ag$ = "yeS" OR ag$ = "YEs" THEN GOTO begin:
  384.             END
  385.         END IF
  386.         shooting = 0
  387.         RETURN
  388.     END IF
  389.  
  390. originaltopten:
  391. DATA Space Ace,7000
  392. DATA Suzy Swift,6000
  393. DATA Speedy Spencer,5000
  394. DATA Super Sam,4000
  395. DATA Battery Bob,3000
  396. DATA Karen Kryptonite,2750
  397. DATA Quick Ken,2500
  398. DATA Tiger Tessa,2250
  399. DATA Arcade Joe,2000
  400. DATA How Do U Play,1750
  401.  
Title: Re: Robot Invaders
Post by: SierraKen on July 24, 2019, 01:19:35 pm
Here is the one line color variable problem fix. After you take care of the Boss and it goes back to the first one, it was making the next robot pink instead of blue. lol I accidentally typed cl instead of c1. Here is the fix, I also added _SCREENMOVE _MIDDLE at the top.

(Note: A faster version with some more sound effects is below on the same forum page as this post.)

Code: QB64: [Select]
  1. 'This version has 5 different colored robots with a Boss Robot after that.
  2. 'Each robot flies a different pattern.
  3. 'Game made on July 22, 2019
  4. 'By Ken G.
  5. 'Freeware
  6. 'I have put some descriptions in the code below to make it easier to learn from.
  7. begin:
  8. DIM name$(50), nm$(50), score(50), sccc(50)
  9. _TITLE "Tech Invaders"
  10. SCREEN _NEWIMAGE(800, 600, 32)
  11. PRINT "                                 T E C H      I N V A D E R S"
  12. PRINT "                                        by Ken G."
  13. PRINT "                       Use left and right arrow keys to move back and forth."
  14. PRINT "                            Use up or down arrow keys to stop moving."
  15. PRINT "                                    Use space bar to fire."
  16. PRINT "                                      Esc to end anytime."
  17. INPUT "                                   Press Enter to start.", start$
  18. lives = 5
  19. points = 0
  20. ushoot = 0
  21. shooting = 0
  22. level = 1
  23. level2 = 1
  24. start = 0
  25. s = 0
  26. xt = 400: yt = 550
  27.  
  28. 'Draw your shooter.
  29. LINE (xt, yt)-(xt + 20, yt + 20), _RGB32(128, 139, 255), BF
  30. LINE (xt + 10, yt)-(xt + 10, yt - 10), _RGB32(128, 139, 255)
  31.  
  32.  
  33. 'This is the start of the main loop.
  34. go:
  35. 'Choose a random place for the enemy.
  36. xx = INT(RND * 200) + 100
  37. yy = INT(RND * 100) + 40
  38.  
  39. 'Each level has its own loop so it can set a different equation and speed of the enemy.
  40.  
  41. IF level = 1 THEN
  42.     c1 = 128: c2 = 127: c3 = 255
  43.     one:
  44.     'sec is not time, it's related to the coordinate of the enemy and speed it goes related to the loop speed.
  45.     sec = sec + .01
  46.     s = (60 - sec) * 6 + 180
  47.     x = INT(SIN(s / 180 * 3.141592) * 180) + 325
  48.     y = INT(COS(s / 180 * 3.141592) * 180) + 225
  49.  
  50.     'GOSUB to drawing draws the enemy robot.
  51.     GOSUB drawing:
  52.     IF sec > 180 THEN
  53.         sec = 0
  54.         GOTO onedone:
  55.     END IF
  56.  
  57.     'GOSUB's go to keyboard control and enemy shooting.
  58.     GOSUB keyboard:
  59.     GOSUB shoot:
  60.     GOSUB youshoot2:
  61.     GOTO one:
  62.     onedone:
  63.  
  64. 'This level uses the spiral equation so it's a bit different than the others.
  65. IF level = 2 THEN
  66.     c1 = 127: c2 = 216: c3 = 127
  67.     FOR d = 160 TO 0 STEP -.125
  68.         _LIMIT 1000
  69.         s = s + .2
  70.         x = COS(s * 3.141592 / 180) * d
  71.         y = SIN(s * 3.151492 / 180) * d
  72.         GOSUB drawing:
  73.         GOSUB keyboard:
  74.         GOSUB shoot:
  75.         GOSUB youshoot2:
  76.     NEXT d
  77.     FOR d = 0 TO 160 STEP .125
  78.         _LIMIT 1000
  79.         s = s - .2
  80.         x = COS(s * 3.141592 / 180) * d
  81.         y = SIN(s * 3.151492 / 180) * d
  82.         GOSUB drawing:
  83.         GOSUB keyboard:
  84.         GOSUB shoot:
  85.         GOSUB youshoot2:
  86.     NEXT d
  87.  
  88. IF level = 3 THEN
  89.     c1 = 255: c2 = 0: c3 = 0
  90.     three:
  91.     sec = sec + .01
  92.     s = (60 - sec) * 6 + 180
  93.     x = INT(SIN(s / 90 * 3.141592) * 180) + 325
  94.     y = INT(COS(s / 180 * 3.141592) * 180) + 225
  95.     GOSUB drawing:
  96.     IF sec > 60 THEN
  97.         sec = 0
  98.         GOTO threedone:
  99.     END IF
  100.     GOSUB keyboard:
  101.     GOSUB shoot:
  102.     GOSUB youshoot2:
  103.     GOTO three:
  104.     threedone:
  105.  
  106. IF level = 4 THEN
  107.     c1 = 255: c2 = 255: c3 = 127
  108.     four:
  109.     sec = sec + .01
  110.     s = (60 - sec) * 6 + 180
  111.     x = INT(SIN(s / 180 * 3.141592) * 180) + 325
  112.     y = INT(COS(s / 90 * 3.141592) * 180) + 225
  113.     GOSUB drawing:
  114.     IF sec > 60 THEN
  115.         sec = 0
  116.         GOTO fourdone:
  117.     END IF
  118.     GOSUB keyboard:
  119.     GOSUB shoot:
  120.     GOSUB youshoot2:
  121.     GOTO four:
  122.     fourdone:
  123. IF level = 5 THEN
  124.     c1 = 133: c2 = 28: c3 = 255
  125.     five:
  126.     sec = sec + .01
  127.     s = (60 - sec) * 6 + 180
  128.     x = INT(SIN(s / 135 * 3.141592) * 180) + 325
  129.     y = INT(COS(s / 33.75 * 3.141592) * 180) + 225
  130.     GOSUB drawing:
  131.     IF sec > 60 THEN
  132.         sec = 0
  133.         GOTO fivedone:
  134.     END IF
  135.     GOSUB keyboard:
  136.     GOSUB shoot:
  137.     GOSUB youshoot2:
  138.     GOTO five:
  139.     fivedone:
  140.  
  141. IF level = 6 THEN
  142.     c1 = 255: c2 = 0: c3 = 0
  143.     six:
  144.     sec = sec + .02
  145.     s = (60 - sec) * 6 + 180
  146.     x = INT(SIN(s / 45 * 3.141592) * 180) + 325
  147.     y = INT(COS(s / 360 * 3.141592) * 180) + 225
  148.     GOSUB drawing2:
  149.     IF sec > 120 THEN
  150.         sec = 0
  151.         GOTO sixdone:
  152.     END IF
  153.     GOSUB keyboard:
  154.     GOSUB shoot:
  155.     GOSUB youshoot2:
  156.     GOTO six:
  157.     sixdone:
  158.  
  159. IF level = 7 THEN level = 1
  160.  
  161. GOTO go:
  162. 'GOTO goes back to the start of the main loop.
  163.  
  164. 'Draws the enemy tank and erases it for animation.
  165. drawing:
  166. x2 = x + xx: y2 = y + yy
  167. LINE (x2, y2)-(x2 - 10, y2 - 10), _RGB32(c1, c2, c3)
  168. LINE (x2 + 20, y2)-(x2 + 30, y2 - 10), _RGB32(c1, c2, c3)
  169. CIRCLE (x2 - 15, y2 - 15), 5, _RGB32(c1, c2, c3)
  170. CIRCLE (x2 + 35, y2 - 15), 5, _RGB32(c1, c2, c3)
  171. LINE (x2, y2)-(x2 + 20, y2 + 20), _RGB32(c1, c2, c3), BF
  172. LINE (x2 + 5, y2 + 5)-(x2 + 8, y2 + 8), _RGB32(0, 0, 0), BF
  173. LINE (x2 + 12, y2 + 5)-(x2 + 15, y2 + 8), _RGB32(0, 0, 0), BF
  174. LINE (x2 + 5, y2 + 13)-(x2 + 15, y2 + 16), _RGB32(0, 0, 0), BF
  175. _DELAY .004
  176. LINE (x2, y2)-(x2 + 20, y2 + 20), _RGB32(0, 0, 0), BF
  177. LINE (x2, y2)-(x2 - 10, y2 - 10), _RGB32(0, 0, 0)
  178. LINE (x2 + 20, y2)-(x2 + 30, y2 - 10), _RGB32(0, 0, 0)
  179. CIRCLE (x2 - 15, y2 - 15), 5, _RGB32(0, 0, 0)
  180. CIRCLE (x2 + 35, y2 - 15), 5, _RGB32(0, 0, 0)
  181.  
  182.  
  183. 'Draws the Boss Robot.
  184. drawing2:
  185. x2 = x + xx: y2 = y + yy
  186. LINE (x2 - 10, y2 - 10)-(x2 + 10, y2 + 10), _RGB32(c1, c2, c3), BF
  187. LINE (x2 - 4, y2 - 5)-(x2 - 2, y2 - 2), _RGB32(0, 0, 0), BF
  188. LINE (x2 + 6, y2 - 5)-(x2 + 8, y2 - 2), _RGB32(0, 0, 0), BF
  189. LINE (x2 - 4, y2 + 7)-(x2 + 4, y2 + 8), _RGB32(0, 0, 0), BF
  190. LINE (x2, y2 - 10)-(x2, y2 - 20), _RGB32(c1, c2, c3)
  191. CIRCLE (x2, y2 - 24), 4, _RGB32(c1, c2, c3)
  192. LINE (x2, y2 - 20)-(x2 - 10, y2 - 30), _RGB32(c1, c2, c3)
  193. LINE (x2, y2 - 20)-(x2 + 10, y2 - 30), _RGB32(c1, c2, c3)
  194. _DELAY .004
  195. LINE (x2 - 10, y2 - 10)-(x2 + 10, y2 + 10), _RGB32(0, 0, 0), BF
  196. LINE (x2, y2 - 10)-(x2, y2 - 20), _RGB32(0, 0, 0)
  197. CIRCLE (x2, y2 - 24), 4, _RGB32(0, 0, 0)
  198. LINE (x2, y2 - 20)-(x2 - 10, y2 - 30), _RGB32(0, 0, 0)
  199. LINE (x2, y2 - 20)-(x2 + 10, y2 - 30), _RGB32(0, 0, 0)
  200.  
  201. 'Keyboard control for your movement and shooting.
  202. keyboard:
  203. _LIMIT 1000
  204. a$ = INKEY$
  205. IF a$ = CHR$(27) THEN END
  206. IF a$ = CHR$(0) + CHR$(77) THEN r = 1: l = 0
  207. IF r = 1 THEN
  208.     LINE (xt, yt)-(xt + 20, yt + 20), _RGB32(0, 0, 0), BF
  209.     LINE (xt + 10, yt)-(xt + 10, yt - 10), _RGB32(0, 0, 0)
  210.     xt = xt + 1
  211.     IF xt > 780 THEN xt = 780
  212.     LINE (xt, yt)-(xt + 20, yt + 20), _RGB32(128, 139, 255), BF
  213.     LINE (xt + 10, yt)-(xt + 10, yt - 10), _RGB32(128, 139, 255)
  214. IF a$ = CHR$(0) + CHR$(75) THEN l = 1: r = 0
  215. IF l = 1 THEN
  216.     LINE (xt, yt)-(xt + 20, yt + 20), _RGB32(0, 0, 0), BF
  217.     LINE (xt + 10, yt)-(xt + 10, yt - 10), _RGB32(0, 0, 0)
  218.     xt = xt - 1
  219.     IF xt < 0 THEN xt = 0
  220.     LINE (xt, yt)-(xt + 20, yt + 20), _RGB32(128, 139, 255), BF
  221.     LINE (xt + 10, yt)-(xt + 10, yt - 10), _RGB32(128, 139, 255)
  222. IF a$ = CHR$(0) + CHR$(72) OR a$ = CHR$(0) + CHR$(80) THEN
  223.     r = 0: l = 0
  224.  
  225. IF a$ = " " THEN GOSUB youshoot:
  226.  
  227. 'The start of your shot.
  228. youshoot:
  229. _LIMIT 1000
  230. IF ushoot = 0 THEN
  231.     sx2 = xt + 10
  232.     sy2 = yt - 11
  233.     ushoot = 1
  234.     SOUND 400, .5
  235.  
  236. 'The drawing and movement of your shot and if it reaches the enemy.
  237. youshoot2:
  238. _LIMIT 1000
  239. IF ushoot = 1 THEN
  240.     CIRCLE (sx2, sy2), 5, _RGB32(0, 0, 0)
  241.     sy2 = sy2 - 3
  242.     IF sy2 < 0 THEN ushoot = 0: RETURN
  243.     CIRCLE (sx2, sy2), 5, _RGB32(255, 0, 0)
  244.     IF sx2 > x2 - 21 AND sx2 < x2 + 41 AND sy2 > y2 - 11 AND sy2 < y2 + 21 THEN
  245.         CIRCLE (sx2, sy2), 5, _RGB32(0, 0, 0)
  246.         SOUND 200, 1
  247.         SOUND 100, 1
  248.         FOR explosion = 1 TO 30
  249.             CIRCLE (x2 + 10, y2 + 10), explosion, _RGB32(255, 0, 0)
  250.             _DELAY .02
  251.             CIRCLE (x2 + 10, y2 + 10), explosion, _RGB32(0, 0, 0)
  252.         NEXT explosion
  253.         LINE (x2 - 21, y2 - 21)-(x2 + 41, y2 + 41), _RGB32(0, 0, 0), BF
  254.         points = points + 100
  255.         IF points / 500 = INT(points / 500) THEN level = level + 1: level2 = level2 + 1
  256.         lives$ = STR$(lives)
  257.         points$ = STR$(points)
  258.         level$ = STR$(level2)
  259.         _TITLE "Tech Invaders      Lives: " + lives$ + "     Level: " + level$ + "      Score: " + points$
  260.         ushoot = 0
  261.         GOTO go:
  262.     END IF
  263.  
  264. 'The enemy's shot and if it reaches you.
  265. shoot:
  266. _LIMIT 1000
  267. IF shooting = 0 THEN
  268.     IF level2 = 1 THEN shh = 9970
  269.     IF level2 = 2 THEN shh = 9968
  270.     IF level2 = 3 THEN shh = 9966
  271.     IF level2 = 4 THEN shh = 9964
  272.     IF level2 = 5 THEN shh = 9962
  273.     IF level2 = 6 THEN shh = 9940
  274.     IF level2 > 6 THEN shh = 9930
  275.     sh = INT(RND * 10000) + 1
  276.     IF sh < shh THEN RETURN
  277.     sx = x2 + 10
  278.     sy = y2 + 10
  279.     shooting = 1
  280.     SOUND 300, .5
  281. IF shooting = 1 THEN
  282.     CIRCLE (sx, sy), 5, _RGB32(0, 0, 0)
  283.     sy = sy + 3
  284.     IF sy > 620 THEN shooting = 0: RETURN
  285.     CIRCLE (sx, sy), 5, _RGB32(255, 0, 0)
  286.     IF sx > xt - 1 AND sx < xt + 21 AND sy > yt - 1 AND sy < yt + 21 THEN
  287.         CIRCLE (sx, sy), 5, _RGB32(0, 0, 0)
  288.         SOUND 200, 1
  289.         SOUND 100, 1
  290.         FOR explosion2 = 1 TO 30
  291.             CIRCLE (xt + 10, yt + 10), explosion2, _RGB32(255, 0, 0)
  292.             _DELAY .02
  293.             CIRCLE (xt + 10, yt + 10), explosion2, _RGB32(0, 0, 0)
  294.         NEXT explosion2
  295.         lives = lives - 1
  296.         lives$ = STR$(lives)
  297.         points$ = STR$(points)
  298.         level$ = STR$(level2)
  299.         _TITLE "Tech Invaders      Lives: " + lives$ + "     Level: " + level$ + "      Score: " + points$
  300.         LINE (xt - 22, yt - 42)-(xt + 42, yt + 42), _RGB32(0, 0, 0), BF
  301.         IF lives = 0 THEN
  302.             LOCATE 20, 40: PRINT "G A M E   O V E R"
  303.             LOCATE 22, 40: PRINT "Score: "; points
  304.             LOCATE 23, 40: PRINT "Level: "; level2
  305.             LOCATE 25, 40: INPUT "Press Enter to go to Top Ten Scores.", tt$
  306.  
  307.             'Top Ten Scores
  308.             scc = points
  309.             IF _FILEEXISTS("toptentech.txt") THEN
  310.             ELSE
  311.                 OPEN "toptentech.txt" FOR OUTPUT AS #1
  312.                 RESTORE originaltopten
  313.                 DO
  314.                     READ toptenname$, toptenscore!
  315.                     IF toptenname$ = "EOF" THEN EXIT DO
  316.                     PRINT #1, toptenname$
  317.                     PRINT #1, toptenscore!
  318.                 LOOP
  319.                 CLOSE #1
  320.             END IF
  321.  
  322.             OPEN "toptentech.txt" FOR INPUT AS #1
  323.             FOR n = 1 TO 10
  324.                 INPUT #1, name$(n)
  325.                 INPUT #1, score(n)
  326.                 IF scc > score(n) AND sct = 0 THEN
  327.                     nn = n
  328.                     PRINT "You have made the Top Ten!"
  329.                     typename:
  330.                     INPUT "Type your name here (25 letters and spaces maximum.):", nm$(nn)
  331.                     IF LEN(nm$(nn)) > 25 THEN
  332.                         PRINT "Name too long, try again."
  333.                         GOTO typename:
  334.                     END IF
  335.                     sccc(nn) = scc
  336.                     sct = 1
  337.                 END IF
  338.                 IF n = 10 AND sct = 0 THEN CLOSE #1: GOTO nex7:
  339.             NEXT n
  340.             CLOSE #1
  341.             nex5:
  342.             CLOSE #1
  343.             OPEN "toptentech.txt" FOR OUTPUT AS #1
  344.             FOR n = 1 TO nn
  345.                 IF n <> nn THEN PRINT #1, name$(n): PRINT #1, score(n)
  346.                 IF n = nn THEN
  347.                     PRINT #1, nm$(n)
  348.                     PRINT #1, sccc(n)
  349.                 END IF
  350.             NEXT n
  351.             nex6:
  352.             FOR n = nn TO 10
  353.                 PRINT #1, name$(n): PRINT #1, score(n)
  354.             NEXT n
  355.  
  356.             CLOSE #1
  357.             nex7:
  358.             CLS
  359.             PRINT: PRINT: PRINT
  360.             PRINT "                                 T O P    T E N "
  361.             PRINT: PRINT: PRINT
  362.             OPEN "toptentech.txt" FOR INPUT AS #1
  363.             FOR n = 1 TO 10
  364.                 IF EOF(1) THEN GOTO nex8:
  365.                 INPUT #1, name$(n)
  366.                 INPUT #1, score(n)
  367.                 PRINT "             "; n; ". "; name$(n); score(n)
  368.             NEXT n
  369.             nex8:
  370.             CLOSE #1
  371.             FOR n = 1 TO 10
  372.                 nm$(n) = ""
  373.                 score(n) = 0
  374.                 name$(n) = ""
  375.                 sccc(n) = 0
  376.             NEXT n
  377.             nn = 0
  378.             n = 0
  379.             sct = 0
  380.             scc = 0
  381.             LOCATE 23, 1
  382.             INPUT "Would you like to play again? (Yes/No)", ag$
  383.             IF ag$ = "y" OR ag$ = "Y" OR ag$ = "YES" OR ag$ = "yes" OR ag$ = "Yes" OR ag$ = "yES" OR ag$ = "yeS" OR ag$ = "YEs" THEN GOTO begin:
  384.             END
  385.         END IF
  386.         shooting = 0
  387.         RETURN
  388.     END IF
  389.  
  390. originaltopten:
  391. DATA Space Ace,7000
  392. DATA Suzy Swift,6000
  393. DATA Speedy Spencer,5000
  394. DATA Super Sam,4000
  395. DATA Battery Bob,3000
  396. DATA Karen Kryptonite,2750
  397. DATA Quick Ken,2500
  398. DATA Tiger Tessa,2250
  399. DATA Arcade Joe,2000
  400. DATA How Do U Play,1750
  401.  
Title: Re: Robot Invaders
Post by: SierraKen on July 24, 2019, 06:44:18 pm
I made a video of myself playing this game, showing the code first, and put it on YouTube. If anyone is interested. It's a bit blurry but someone says that YouTube fixes the blurriness eventually, but we'll see. 


&feature=youtu.be
 (https://www.youtube.com/watch?v=c3t4OrAwcfo&feature=youtu.be)
Title: Re: Robot Invaders
Post by: SierraKen on July 25, 2019, 11:18:27 pm
Well, I decided to do some more experimenting lol, and you know when that happens I find something really cool usually lol.
For the first time I tried some SUB's and tried them in my Robot Invaders game. I first found out that if you use a FOR/NEXT loop in a SUB, you can play that SOUND effect while the main program is still running! That is, until that loop is over with, which is WAY cool. But I also found out that you can't make a forever loop for Sound in a SUB or it will stop your main program for some reason. So after messing with it a bit I just made a quick sound for when you start with a new guy in the game. I also made the enemy explosions a LOT faster with no _DELAY's anymore. Which makes the game even more fun because it moves much faster. So, here is the game again, I hope you all aren't tired of it yet. :) Thank you to the people in my Math Graphics thread for pushing me to learn more about SUB's, I feel like I just jumped ahead big time. :) Subs were like another language to me in the 90's, I feel so relieved now that I finally know a lot more now. Of course I will still keep learning more about them.

This will be the last one for this Version of the game. I'm working on Version 2 and I already got filled in bullets :))). I didn't need that circle fill-in code in the Toolbox of this forum, just loops of different sized circles every .25 size. :) I'll start a new thread for the next version because I want to add a lot of different things.


Code: QB64: [Select]
  1. 'This version has 5 different colored robots with a Boss Robot after that.
  2. 'Each robot flies a different pattern.
  3. 'Game made on July 22, 2019
  4. 'By Ken G.
  5. 'Freeware
  6. 'I have put some descriptions in the code below to make it easier to learn from.
  7. begin:
  8. DIM name$(50), nm$(50), score(50), sccc(50)
  9. _TITLE "Tech Invaders"
  10. SCREEN _NEWIMAGE(800, 600, 32)
  11. PRINT "                                 T E C H      I N V A D E R S"
  12. PRINT "                                        by Ken G."
  13. PRINT "                       Use left and right arrow keys to move back and forth."
  14. PRINT "                            Use up or down arrow keys to stop moving."
  15. PRINT "                                    Use space bar to fire."
  16. PRINT "                                      Esc to end anytime."
  17. INPUT "                                   Press Enter to start.", start$
  18. lives = 5
  19. points = 0
  20. ushoot = 0
  21. shooting = 0
  22. level = 1
  23. level2 = 1
  24. start = 0
  25. s = 0
  26. xt = 400: yt = 550
  27.  
  28. 'Draw your shooter.
  29. LINE (xt, yt)-(xt + 20, yt + 20), _RGB32(128, 139, 255), BF
  30. LINE (xt + 10, yt)-(xt + 10, yt - 10), _RGB32(128, 139, 255)
  31.  
  32. OPENINGSOUND
  33.  
  34. 'This is the start of the main loop.
  35. go:
  36. 'Choose a random place for the enemy.
  37. xx = INT(RND * 200) + 100
  38. yy = INT(RND * 100) + 40
  39.  
  40. 'Each level has its own loop so it can set a different equation and speed of the enemy.
  41.  
  42. IF level = 1 THEN
  43.     c1 = 128: c2 = 127: c3 = 255
  44.     one:
  45.     'sec is not time, it's related to the coordinate of the enemy and speed it goes related to the loop speed.
  46.     sec = sec + .01
  47.     s = (60 - sec) * 6 + 180
  48.     x = INT(SIN(s / 180 * 3.141592) * 180) + 325
  49.     y = INT(COS(s / 180 * 3.141592) * 180) + 225
  50.  
  51.     'GOSUB to drawing draws the enemy robot.
  52.     GOSUB drawing:
  53.     IF sec > 180 THEN
  54.         sec = 0
  55.         GOTO onedone:
  56.     END IF
  57.  
  58.     'GOSUB's go to keyboard control and enemy shooting.
  59.     GOSUB keyboard:
  60.     GOSUB shoot:
  61.     GOSUB youshoot2:
  62.     GOTO one:
  63.     onedone:
  64.  
  65. 'This level uses the spiral equation so it's a bit different than the others.
  66. IF level = 2 THEN
  67.     c1 = 127: c2 = 216: c3 = 127
  68.     FOR d = 160 TO 0 STEP -.125
  69.         _LIMIT 1000
  70.         s = s + .2
  71.         x = COS(s * 3.141592 / 180) * d
  72.         y = SIN(s * 3.151492 / 180) * d
  73.         GOSUB drawing:
  74.         GOSUB keyboard:
  75.         GOSUB shoot:
  76.         GOSUB youshoot2:
  77.     NEXT d
  78.     FOR d = 0 TO 160 STEP .125
  79.         _LIMIT 1000
  80.         s = s - .2
  81.         x = COS(s * 3.141592 / 180) * d
  82.         y = SIN(s * 3.151492 / 180) * d
  83.         GOSUB drawing:
  84.         GOSUB keyboard:
  85.         GOSUB shoot:
  86.         GOSUB youshoot2:
  87.     NEXT d
  88.  
  89. IF level = 3 THEN
  90.     c1 = 255: c2 = 0: c3 = 0
  91.     three:
  92.     sec = sec + .01
  93.     s = (60 - sec) * 6 + 180
  94.     x = INT(SIN(s / 90 * 3.141592) * 180) + 325
  95.     y = INT(COS(s / 180 * 3.141592) * 180) + 225
  96.     GOSUB drawing:
  97.     IF sec > 60 THEN
  98.         sec = 0
  99.         GOTO threedone:
  100.     END IF
  101.     GOSUB keyboard:
  102.     GOSUB shoot:
  103.     GOSUB youshoot2:
  104.     GOTO three:
  105.     threedone:
  106.  
  107. IF level = 4 THEN
  108.     c1 = 255: c2 = 255: c3 = 127
  109.     four:
  110.     sec = sec + .01
  111.     s = (60 - sec) * 6 + 180
  112.     x = INT(SIN(s / 180 * 3.141592) * 180) + 325
  113.     y = INT(COS(s / 90 * 3.141592) * 180) + 225
  114.     GOSUB drawing:
  115.     IF sec > 60 THEN
  116.         sec = 0
  117.         GOTO fourdone:
  118.     END IF
  119.     GOSUB keyboard:
  120.     GOSUB shoot:
  121.     GOSUB youshoot2:
  122.     GOTO four:
  123.     fourdone:
  124. IF level = 5 THEN
  125.     c1 = 133: c2 = 28: c3 = 255
  126.     five:
  127.     sec = sec + .01
  128.     s = (60 - sec) * 6 + 180
  129.     x = INT(SIN(s / 135 * 3.141592) * 180) + 325
  130.     y = INT(COS(s / 33.75 * 3.141592) * 180) + 225
  131.     GOSUB drawing:
  132.     IF sec > 60 THEN
  133.         sec = 0
  134.         GOTO fivedone:
  135.     END IF
  136.     GOSUB keyboard:
  137.     GOSUB shoot:
  138.     GOSUB youshoot2:
  139.     GOTO five:
  140.     fivedone:
  141.  
  142. IF level = 6 THEN
  143.     c1 = 255: c2 = 0: c3 = 0
  144.     six:
  145.     sec = sec + .02
  146.     s = (60 - sec) * 6 + 180
  147.     x = INT(SIN(s / 45 * 3.141592) * 180) + 325
  148.     y = INT(COS(s / 360 * 3.141592) * 180) + 225
  149.     GOSUB drawing2:
  150.     IF sec > 120 THEN
  151.         sec = 0
  152.         GOTO sixdone:
  153.     END IF
  154.     GOSUB keyboard:
  155.     GOSUB shoot:
  156.     GOSUB youshoot2:
  157.     GOTO six:
  158.     sixdone:
  159.  
  160. IF level = 7 THEN level = 1
  161.  
  162. GOTO go:
  163. 'GOTO goes back to the start of the main loop.
  164.  
  165. 'Draws the enemy tank and erases it for animation.
  166. drawing:
  167. x2 = x + xx: y2 = y + yy
  168. LINE (x2, y2)-(x2 - 10, y2 - 10), _RGB32(c1, c2, c3)
  169. LINE (x2 + 20, y2)-(x2 + 30, y2 - 10), _RGB32(c1, c2, c3)
  170. CIRCLE (x2 - 15, y2 - 15), 5, _RGB32(c1, c2, c3)
  171. CIRCLE (x2 + 35, y2 - 15), 5, _RGB32(c1, c2, c3)
  172. LINE (x2, y2)-(x2 + 20, y2 + 20), _RGB32(c1, c2, c3), BF
  173. LINE (x2 + 5, y2 + 5)-(x2 + 8, y2 + 8), _RGB32(0, 0, 0), BF
  174. LINE (x2 + 12, y2 + 5)-(x2 + 15, y2 + 8), _RGB32(0, 0, 0), BF
  175. LINE (x2 + 5, y2 + 13)-(x2 + 15, y2 + 16), _RGB32(0, 0, 0), BF
  176. _DELAY .004
  177. LINE (x2, y2)-(x2 + 20, y2 + 20), _RGB32(0, 0, 0), BF
  178. LINE (x2, y2)-(x2 - 10, y2 - 10), _RGB32(0, 0, 0)
  179. LINE (x2 + 20, y2)-(x2 + 30, y2 - 10), _RGB32(0, 0, 0)
  180. CIRCLE (x2 - 15, y2 - 15), 5, _RGB32(0, 0, 0)
  181. CIRCLE (x2 + 35, y2 - 15), 5, _RGB32(0, 0, 0)
  182.  
  183.  
  184. 'Draws the Boss Robot.
  185. drawing2:
  186. x2 = x + xx: y2 = y + yy
  187. LINE (x2 - 10, y2 - 10)-(x2 + 10, y2 + 10), _RGB32(c1, c2, c3), BF
  188. LINE (x2 - 4, y2 - 5)-(x2 - 2, y2 - 2), _RGB32(0, 0, 0), BF
  189. LINE (x2 + 6, y2 - 5)-(x2 + 8, y2 - 2), _RGB32(0, 0, 0), BF
  190. LINE (x2 - 4, y2 + 7)-(x2 + 4, y2 + 8), _RGB32(0, 0, 0), BF
  191. LINE (x2, y2 - 10)-(x2, y2 - 20), _RGB32(c1, c2, c3)
  192. CIRCLE (x2, y2 - 24), 4, _RGB32(c1, c2, c3)
  193. LINE (x2, y2 - 20)-(x2 - 10, y2 - 30), _RGB32(c1, c2, c3)
  194. LINE (x2, y2 - 20)-(x2 + 10, y2 - 30), _RGB32(c1, c2, c3)
  195. _DELAY .004
  196. LINE (x2 - 10, y2 - 10)-(x2 + 10, y2 + 10), _RGB32(0, 0, 0), BF
  197. LINE (x2, y2 - 10)-(x2, y2 - 20), _RGB32(0, 0, 0)
  198. CIRCLE (x2, y2 - 24), 4, _RGB32(0, 0, 0)
  199. LINE (x2, y2 - 20)-(x2 - 10, y2 - 30), _RGB32(0, 0, 0)
  200. LINE (x2, y2 - 20)-(x2 + 10, y2 - 30), _RGB32(0, 0, 0)
  201.  
  202. 'Keyboard control for your movement and shooting.
  203. keyboard:
  204. _LIMIT 1000
  205. a$ = INKEY$
  206. IF a$ = CHR$(27) THEN END
  207. IF a$ = CHR$(0) + CHR$(77) THEN r = 1: l = 0
  208. IF r = 1 THEN
  209.     LINE (xt, yt)-(xt + 20, yt + 20), _RGB32(0, 0, 0), BF
  210.     LINE (xt + 10, yt)-(xt + 10, yt - 10), _RGB32(0, 0, 0)
  211.     xt = xt + 1
  212.     IF xt > 780 THEN xt = 780
  213.     LINE (xt, yt)-(xt + 20, yt + 20), _RGB32(128, 139, 255), BF
  214.     LINE (xt + 10, yt)-(xt + 10, yt - 10), _RGB32(128, 139, 255)
  215. IF a$ = CHR$(0) + CHR$(75) THEN l = 1: r = 0
  216. IF l = 1 THEN
  217.     LINE (xt, yt)-(xt + 20, yt + 20), _RGB32(0, 0, 0), BF
  218.     LINE (xt + 10, yt)-(xt + 10, yt - 10), _RGB32(0, 0, 0)
  219.     xt = xt - 1
  220.     IF xt < 0 THEN xt = 0
  221.     LINE (xt, yt)-(xt + 20, yt + 20), _RGB32(128, 139, 255), BF
  222.     LINE (xt + 10, yt)-(xt + 10, yt - 10), _RGB32(128, 139, 255)
  223. IF a$ = CHR$(0) + CHR$(72) OR a$ = CHR$(0) + CHR$(80) THEN
  224.     r = 0: l = 0
  225.  
  226. IF a$ = " " THEN GOSUB youshoot:
  227.  
  228. 'The start of your shot.
  229. youshoot:
  230. _LIMIT 1000
  231. IF ushoot = 0 THEN
  232.     sx2 = xt + 10
  233.     sy2 = yt - 11
  234.     ushoot = 1
  235.     SOUND 400, .5
  236.  
  237. 'The drawing and movement of your shot and if it reaches the enemy.
  238. youshoot2:
  239. _LIMIT 1000
  240. IF ushoot = 1 THEN
  241.     CIRCLE (sx2, sy2), 5, _RGB32(0, 0, 0)
  242.     sy2 = sy2 - 3
  243.     IF sy2 < 0 THEN ushoot = 0: RETURN
  244.     CIRCLE (sx2, sy2), 5, _RGB32(255, 0, 0)
  245.     IF sx2 > x2 - 21 AND sx2 < x2 + 41 AND sy2 > y2 - 11 AND sy2 < y2 + 21 THEN
  246.         ENEMYEXPLOSION sx2, sy2, x2, y2
  247.         points = points + 100
  248.         IF points / 500 = INT(points / 500) THEN level = level + 1: level2 = level2 + 1
  249.         lives$ = STR$(lives)
  250.         points$ = STR$(points)
  251.         level$ = STR$(level2)
  252.         _TITLE "Tech Invaders      Lives: " + lives$ + "     Level: " + level$ + "      Score: " + points$
  253.         ushoot = 0
  254.         GOTO go:
  255.     END IF
  256.  
  257. 'The enemy's shot and if it reaches you.
  258. shoot:
  259. _LIMIT 1000
  260. IF shooting = 0 THEN
  261.     IF level2 = 1 THEN shh = 9970
  262.     IF level2 = 2 THEN shh = 9968
  263.     IF level2 = 3 THEN shh = 9966
  264.     IF level2 = 4 THEN shh = 9964
  265.     IF level2 = 5 THEN shh = 9962
  266.     IF level2 = 6 THEN shh = 9940
  267.     IF level2 > 6 THEN shh = 9930
  268.     sh = INT(RND * 10000) + 1
  269.     IF sh < shh THEN RETURN
  270.     sx = x2 + 10
  271.     sy = y2 + 10
  272.     shooting = 1
  273.     SOUND 300, .5
  274. IF shooting = 1 THEN
  275.     CIRCLE (sx, sy), 5, _RGB32(0, 0, 0)
  276.     sy = sy + 3
  277.     IF sy > 620 THEN shooting = 0: RETURN
  278.     CIRCLE (sx, sy), 5, _RGB32(255, 0, 0)
  279.     IF sx > xt - 1 AND sx < xt + 21 AND sy > yt - 1 AND sy < yt + 21 THEN
  280.         CIRCLE (sx, sy), 5, _RGB32(0, 0, 0)
  281.         SOUND 200, 1
  282.         SOUND 100, 1
  283.         FOR explosion2 = 1 TO 30
  284.             CIRCLE (xt + 10, yt + 10), explosion2, _RGB32(255, 0, 0)
  285.             _DELAY .02
  286.             CIRCLE (xt + 10, yt + 10), explosion2, _RGB32(0, 0, 0)
  287.         NEXT explosion2
  288.         lives = lives - 1
  289.         lives$ = STR$(lives)
  290.         points$ = STR$(points)
  291.         level$ = STR$(level2)
  292.         _TITLE "Tech Invaders      Lives: " + lives$ + "     Level: " + level$ + "      Score: " + points$
  293.         LINE (xt - 22, yt - 42)-(xt + 42, yt + 42), _RGB32(0, 0, 0), BF
  294.         IF lives = 0 THEN
  295.             LOCATE 20, 40: PRINT "G A M E   O V E R"
  296.             LOCATE 22, 40: PRINT "Score: "; points
  297.             LOCATE 23, 40: PRINT "Level: "; level2
  298.             LOCATE 25, 40: INPUT "Press Enter to go to Top Ten Scores.", tt$
  299.  
  300.             'Top Ten Scores
  301.             scc = points
  302.             IF _FILEEXISTS("toptentech.txt") THEN
  303.             ELSE
  304.                 OPEN "toptentech.txt" FOR OUTPUT AS #1
  305.                 RESTORE originaltopten
  306.                 DO
  307.                     READ toptenname$, toptenscore!
  308.                     IF toptenname$ = "EOF" THEN EXIT DO
  309.                     PRINT #1, toptenname$
  310.                     PRINT #1, toptenscore!
  311.                 LOOP
  312.                 CLOSE #1
  313.             END IF
  314.  
  315.             OPEN "toptentech.txt" FOR INPUT AS #1
  316.             FOR n = 1 TO 10
  317.                 INPUT #1, name$(n)
  318.                 INPUT #1, score(n)
  319.                 IF scc > score(n) AND sct = 0 THEN
  320.                     nn = n
  321.                     PRINT "You have made the Top Ten!"
  322.                     typename:
  323.                     INPUT "Type your name here (25 letters and spaces maximum.):", nm$(nn)
  324.                     IF LEN(nm$(nn)) > 25 THEN
  325.                         PRINT "Name too long, try again."
  326.                         GOTO typename:
  327.                     END IF
  328.                     sccc(nn) = scc
  329.                     sct = 1
  330.                 END IF
  331.                 IF n = 10 AND sct = 0 THEN CLOSE #1: GOTO nex7:
  332.             NEXT n
  333.             CLOSE #1
  334.             nex5:
  335.             CLOSE #1
  336.             OPEN "toptentech.txt" FOR OUTPUT AS #1
  337.             FOR n = 1 TO nn
  338.                 IF n <> nn THEN PRINT #1, name$(n): PRINT #1, score(n)
  339.                 IF n = nn THEN
  340.                     PRINT #1, nm$(n)
  341.                     PRINT #1, sccc(n)
  342.                 END IF
  343.             NEXT n
  344.             nex6:
  345.             FOR n = nn TO 10
  346.                 PRINT #1, name$(n): PRINT #1, score(n)
  347.             NEXT n
  348.  
  349.             CLOSE #1
  350.             nex7:
  351.             CLS
  352.             PRINT: PRINT: PRINT
  353.             PRINT "                                 T O P    T E N "
  354.             PRINT: PRINT: PRINT
  355.             OPEN "toptentech.txt" FOR INPUT AS #1
  356.             FOR n = 1 TO 10
  357.                 IF EOF(1) THEN GOTO nex8:
  358.                 INPUT #1, name$(n)
  359.                 INPUT #1, score(n)
  360.                 PRINT "             "; n; ". "; name$(n); score(n)
  361.             NEXT n
  362.             nex8:
  363.             CLOSE #1
  364.             FOR n = 1 TO 10
  365.                 nm$(n) = ""
  366.                 score(n) = 0
  367.                 name$(n) = ""
  368.                 sccc(n) = 0
  369.             NEXT n
  370.             nn = 0
  371.             n = 0
  372.             sct = 0
  373.             scc = 0
  374.             LOCATE 23, 1
  375.             INPUT "Would you like to play again? (Yes/No)", ag$
  376.             IF ag$ = "y" OR ag$ = "Y" OR ag$ = "YES" OR ag$ = "yes" OR ag$ = "Yes" OR ag$ = "yES" OR ag$ = "yeS" OR ag$ = "YEs" THEN GOTO begin:
  377.             END
  378.         END IF
  379.         shooting = 0
  380.         OPENINGSOUND
  381.         RETURN
  382.     END IF
  383.  
  384. originaltopten:
  385. DATA Space Ace,7000
  386. DATA Suzy Swift,6000
  387. DATA Speedy Spencer,5000
  388. DATA Super Sam,4000
  389. DATA Battery Bob,3000
  390. DATA Karen Kryptonite,2750
  391. DATA Quick Ken,2500
  392. DATA Tiger Tessa,2250
  393. DATA Arcade Joe,2000
  394. DATA How Do U Play,1750
  395.  
  396. SUB OPENINGSOUND
  397.     snd = 300
  398.     snd2 = 800
  399.     FOR t = 1 TO 50
  400.         IF snd > 800 THEN snd = 300
  401.         IF snd2 < 300 THEN snd2 = 800
  402.         snd = snd + 10
  403.         SOUND snd, .25
  404.     NEXT t
  405.  
  406. SUB ENEMYEXPLOSION (sx2, sy2, x2, y2)
  407.     SOUND 200, 1
  408.     SOUND 100, 1
  409.     CIRCLE (sx2, sy2), 5, _RGB32(0, 0, 0)
  410.     FOR explosion = 1 TO 30
  411.         CIRCLE (x2 + 10, y2 + 10), explosion, _RGB32(255, 0, 0)
  412.         _LIMIT 200
  413.         CIRCLE (x2 + 10, y2 + 10), explosion, _RGB32(0, 0, 0)
  414.     NEXT explosion
  415.     LINE (x2 - 21, y2 - 21)-(x2 + 41, y2 + 41), _RGB32(0, 0, 0), BF
  416.  
  417.  
Title: Re: Robot Invaders
Post by: OldMoses on July 26, 2019, 07:12:13 am
That was really cool. Trying to predict where the alien was going to move was a challenge.

On the code end of things, I think you'll find that SUBing out will work well where ever you use a GOTO or GOSUB.

SUBs and FUNCTIONs, when well designed, will become standard library routines that you can cut and paste into other code. That way it's not necessary to "reinvent the wheel". There are times that I just load a "template" of routines, then when I'm done, I just delete the ones I didn't use.
Title: Re: Robot Invaders
Post by: SierraKen on July 26, 2019, 12:49:04 pm
That's really cool, thanks OldMoses, I'll remember that.
Title: Re: Robot Invaders
Post by: Pete on July 27, 2019, 12:43:53 am
Well, I made it to level 7 in the first game. I liked the initial alien design the best.

Pete
Title: Re: Robot Invaders
Post by: pforpond on July 27, 2019, 02:35:11 am
I made it to the red ones that fly side to side... this is a fun game, quite addictive and I love the fast paced nature it seems to be taking and pattern learning involved. One thing I did notice is that sometimes the enemy seems to jolt from one place to another... I think it only happened twice, I don't know if it's intended or not :)

Would be great to see multiple enemies on screen at once :) Loving you game so far!
Title: Re: Robot Invaders
Post by: SierraKen on July 27, 2019, 12:37:00 pm
Thanks Pforpond. Yes, they are intended to disappear and appear somewhere else. It makes the game a bit harder and more random. :)
Title: Re: Robot Invaders
Post by: SierraKen on July 27, 2019, 12:37:53 pm
Cool Pete, thanks. Try out my Tech Invaders 2. It's a lot better than this one. :)