Author Topic: Shooter Start  (Read 3380 times)

0 Members and 1 Guest are viewing this topic.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Shooter Start
« on: March 30, 2019, 08:31:53 pm »
Code: QB64: [Select]
  1. CONST AliceBlue = &HFFF0F8FF~& ' _RGB32(240,248,255)
  2. CONST Almond = &HFFEFDECD~& '_RGB32(239,222,205)
  3. CONST AntiqueBrass = &HFFCD9575~& '_RGB32(205,149,117)
  4. CONST AntiqueWhite = &HFFFAEBD7~& ' _RGB32(250,235,215)
  5. CONST Apricot = &HFFFDD9B5~& '_RGB32(253,217,181)
  6. CONST Aqua = &HFF00FFFF~& ' _RGB32(0,255,255)
  7. CONST Aquamarine = &HFF7FFFD4~& ' _RGB32(127,255,212)
  8. CONST Asparagus = &HFF87A96B~& '_RGB32(135,169,107)
  9. CONST AtomicTangerine = &HFFFFA474~& '_RGB32(255,164,116)
  10. CONST Azure = &HFFF0FFFF~& ' _RGB32(240,255,255)
  11. CONST BananaMania = &HFFFAE7B5~& '_RGB32(250,231,181)
  12. CONST Beaver = &HFF9F8170~& '_RGB32(159,129,112)
  13. CONST Beige = &HFFF5F5DC~& ' _RGB32(245,245,220)
  14. CONST Bisque = &HFFFFE4C4~& ' _RGB32(255,228,196)
  15. CONST Bittersweet = &HFFFD7C6E~& '_RGB32(253,124,110)
  16. CONST Black = &HFF000000~& ' _RGB32(0,0,0)
  17. CONST BlanchedAlmond = &HFFFFEBCD~& ' _RGB32(255,235,205)
  18. CONST BlizzardBlue = &HFFACE5EE~& '_RGB32(172,229,238)
  19. CONST Blue = &HFF0000FF~& ' _RGB32(0,0,255)
  20. CONST BlueBell = &HFFA2A2D0~& '_RGB32(162,162,208)
  21. CONST BlueGray = &HFF6699CC~& '_RGB32(102,153,204)
  22. CONST BlueGreen = &HFF0D98BA~& '_RGB32(13,152,186)
  23. CONST BlueViolet = &HFF8A2BE2~& ' _RGB32(138,43,226)
  24. CONST Blush = &HFFDE5D83~& '_RGB32(222,93,131)
  25. CONST BrickRed = &HFFCB4154~& '_RGB32(203,65,84)
  26. CONST Brown = &HFFA52A2A~& ' _RGB32(165,42,42)
  27. CONST BurlyWood = &HFFDEB887~& ' _RGB32(222,184,135)
  28. CONST BurntOrange = &HFFFF7F49~& '_RGB32(255,127,73)
  29. CONST BurntSienna = &HFFEA7E5D~& '_RGB32(234,126,93)
  30. CONST CadetBlue = &HFF5F9EA0~& ' _RGB32(95,158,160)
  31. CONST Canary = &HFFFFFF99~& '_RGB32(255,255,153)
  32. CONST CaribbeanGreen = &HFF1CD3A2~& '_RGB32(28,211,162)
  33. CONST CarnationPink = &HFFFFAACC~& '_RGB32(255,170,204)
  34. CONST Cerise = &HFFDD4492~& '_RGB32(221,68,146)
  35. CONST Cerulean = &HFF1DACD6~& '_RGB32(29,172,214)
  36. CONST ChartReuse = &HFF7FFF00~& ' _RGB32(127,255,0)
  37. CONST Chestnut = &HFFBC5D58~& '_RGB32(188,93,88)
  38. CONST Chocolate = &HFFD2691E~& ' _RGB32(210,105,30)
  39. CONST Copper = &HFFDD9475~& '_RGB32(221,148,117)
  40. CONST Coral = &HFFFF7F50~& ' _RGB32(255,127,80)
  41. CONST Cornflower = &HFF9ACEEB~& '_RGB32(154,206,235)
  42. CONST CornflowerBlue = &HFF6495ED~& ' _RGB32(100,149,237)
  43. CONST Cornsilk = &HFFFFF8DC~& ' _RGB32(255,248,220)
  44. CONST CottonCandy = &HFFFFBCD9~& '_RGB32(255,188,217)
  45. CONST CrayolaAquamarine = &HFF78DBE2~& '_RGB32(120,219,226)
  46. CONST CrayolaBlue = &HFF1F75FE~& '_RGB32(31,117,254)
  47. CONST CrayolaBlueViolet = &HFF7366BD~& '_RGB32(115,102,189)
  48. CONST CrayolaBrown = &HFFB4674D~& '_RGB32(180,103,77)
  49. CONST CrayolaCadetBlue = &HFFB0B7C6~& '_RGB32(176,183,198)
  50. CONST CrayolaForestGreen = &HFF6DAE81~& '_RGB32(109,174,129)
  51. CONST CrayolaGold = &HFFE7C697~& '_RGB32(231,198,151)
  52. CONST CrayolaGoldenrod = &HFFFCD975~& '_RGB32(252,217,117)
  53. CONST CrayolaGray = &HFF95918C~& '_RGB32(149,145,140)
  54. CONST CrayolaGreen = &HFF1CAC78~& '_RGB32(28,172,120)
  55. CONST CrayolaGreenYellow = &HFFF0E891~& '_RGB32(240,232,145)
  56. CONST CrayolaIndigo = &HFF5D76CB~& '_RGB32(93,118,203)
  57. CONST CrayolaLavender = &HFFFCB4D5~& '_RGB32(252,180,213)
  58. CONST CrayolaMagenta = &HFFF664AF~& '_RGB32(246,100,175)
  59. CONST CrayolaMaroon = &HFFC8385A~& '_RGB32(200,56,90)
  60. CONST CrayolaMidnightBlue = &HFF1A4876~& '_RGB32(26,72,118)
  61. CONST CrayolaOrange = &HFFFF7538~& '_RGB32(255,117,56)
  62. CONST CrayolaOrangeRed = &HFFFF2B2B~& '_RGB32(255,43,43)
  63. CONST CrayolaOrchid = &HFFE6A8D7~& '_RGB32(230,168,215)
  64. CONST CrayolaPlum = &HFF8E4585~& '_RGB32(142,69,133)
  65. CONST CrayolaRed = &HFFEE204D~& '_RGB32(238,32,77)
  66. CONST CrayolaSalmon = &HFFFF9BAA~& '_RGB32(255,155,170)
  67. CONST CrayolaSeaGreen = &HFF9FE2BF~& '_RGB32(159,226,191)
  68. CONST CrayolaSilver = &HFFCDC5C2~& '_RGB32(205,197,194)
  69. CONST CrayolaSkyBlue = &HFF80DAEB~& '_RGB32(128,218,235)
  70. CONST CrayolaSpringGreen = &HFFECEABE~& '_RGB32(236,234,190)
  71. CONST CrayolaTann = &HFFFAA76C~& '_RGB32(250,167,108)
  72. CONST CrayolaThistle = &HFFEBC7DF~& '_RGB32(235,199,223)
  73. CONST CrayolaViolet = &HFF926EAE~& '_RGB32(146,110,174)
  74. CONST CrayolaYellow = &HFFFCE883~& '_RGB32(252,232,131)
  75. CONST CrayolaYellowGreen = &HFFC5E384~& '_RGB32(197,227,132)
  76. CONST Crimson = &HFFDC143C~& ' _RGB32(220,20,60)
  77. CONST Cyan = &HFF00FFFF~& ' _RGB32(0,255,255)
  78. CONST Dandelion = &HFFFDDB6D~& '_RGB32(253,219,109)
  79. CONST DarkBlue = &HFF00008B~& ' _RGB32(0,0,139)
  80. CONST DarkCyan = &HFF008B8B~& ' _RGB32(0,139,139)
  81. CONST DarkGoldenRod = &HFFB8860B~& ' _RGB32(184,134,11)
  82. CONST DarkGray = &HFFA9A9A9~& ' _RGB32(169,169,169)
  83. CONST DarkGreen = &HFF006400~& ' _RGB32(0,100,0)
  84. CONST DarkKhaki = &HFFBDB76B~& ' _RGB32(189,183,107)
  85. CONST DarkMagenta = &HFF8B008B~& ' _RGB32(139,0,139)
  86. CONST DarkOliveGreen = &HFF556B2F~& ' _RGB32(85,107,47)
  87. CONST DarkOrange = &HFFFF8C00~& ' _RGB32(255,140,0)
  88. CONST DarkOrchid = &HFF9932CC~& ' _RGB32(153,50,204)
  89. CONST DarkRed = &HFF8B0000~& ' _RGB32(139,0,0)
  90. CONST DarkSalmon = &HFFE9967A~& ' _RGB32(233,150,122)
  91. CONST DarkSeaGreen = &HFF8FBC8F~& ' _RGB32(143,188,143)
  92. CONST DarkSlateBlue = &HFF483D8B~& ' _RGB32(72,61,139)
  93. CONST DarkSlateGray = &HFF2F4F4F~& ' _RGB32(47,79,79)
  94. CONST DarkTurquoise = &HFF00CED1~& ' _RGB32(0,206,209)
  95. CONST DarkViolet = &HFF9400D3~& ' _RGB32(148,0,211)
  96. CONST DeepPink = &HFFFF1493~& ' _RGB32(255,20,147)
  97. CONST DeepSkyBlue = &HFF00BFFF~& ' _RGB32(0,191,255)
  98. CONST Denim = &HFF2B6CC4~& '_RGB32(43,108,196)
  99. CONST DesertSand = &HFFEFCDB8~& '_RGB32(239,205,184)
  100. CONST DimGray = &HFF696969~& ' _RGB32(105,105,105)
  101. CONST DodgerBlue = &HFF1E90FF~& ' _RGB32(30,144,255)
  102. CONST Eggplant = &HFF6E5160~& '_RGB32(110,81,96)
  103. CONST ElectricLime = &HFFCEFF1D~& '_RGB32(206,255,29)
  104. CONST Fern = &HFF71BC78~& '_RGB32(113,188,120)
  105. CONST FireBrick = &HFFB22222~& ' _RGB32(178,34,34)
  106. CONST Floralwhite = &HFFFFFAF0~& ' _RGB32(255,250,240)
  107. CONST ForestGreen = &HFF228B22~& ' _RGB32(34,139,34)
  108. CONST Fuchsia = &HFFC364C5~& '_RGB32(195,100,197)
  109. CONST FuzzyWuzzy = &HFFCC6666~& '_RGB32(204,102,102)
  110. CONST Gainsboro = &HFFDCDCDC~& ' _RGB32(220,220,220)
  111. CONST GhostWhite = &HFFF8F8FF~& ' _RGB32(248,248,255)
  112. CONST Gold = &HFFFFD700~& ' _RGB32(255,215,0)
  113. CONST GoldenRod = &HFFDAA520~& ' _RGB32(218,165,32)
  114. CONST GrannySmithApple = &HFFA8E4A0~& '_RGB32(168,228,160)
  115. CONST Gray = &HFF808080~& ' _RGB32(128,128,128)
  116. CONST Green = &HFF008000~& ' _RGB32(0,128,0)
  117. CONST GreenBlue = &HFF1164B4~& '_RGB32(17,100,180)
  118. CONST GreenYellow = &HFFADFF2F~& ' _RGB32(173,255,47)
  119. CONST HoneyDew = &HFFF0FFF0~& ' _RGB32(240,255,240)
  120. CONST HotMagenta = &HFFFF1DCE~& '_RGB32(255,29,206)
  121. CONST HotPink = &HFFFF69B4~& ' _RGB32(255,105,180)
  122. CONST Inchworm = &HFFB2EC5D~& '_RGB32(178,236,93)
  123. CONST IndianRed = &HFFCD5C5C~& ' _RGB32(205,92,92)
  124. CONST Indigo = &HFF4B0082~& ' _RGB32(75,0,130)
  125. CONST Ivory = &HFFFFFFF0~& ' _RGB32(255,255,240)
  126. CONST JazzberryJam = &HFFCA3767~& '_RGB32(202,55,103)
  127. CONST JungleGreen = &HFF3BB08F~& '_RGB32(59,176,143)
  128. CONST Khaki = &HFFF0E68C~& ' _RGB32(240,230,140)
  129. CONST LaserLemon = &HFFFEFE22~& '_RGB32(254,254,34)
  130. CONST Lavender = &HFFE6E6FA~& ' _RGB32(230,230,250)
  131. CONST LavenderBlush = &HFFFFF0F5~& ' _RGB32(255,240,245)
  132. CONST LawnGreen = &HFF7CFC00~& ' _RGB32(124,252,0)
  133. CONST LemonChiffon = &HFFFFFACD~& ' _RGB32(255,250,205)
  134. CONST LemonYellow = &HFFFFF44F~& '_RGB32(255,244,79)
  135. CONST LightBlue = &HFFADD8E6~& ' _RGB32(173,216,230)
  136. CONST LightCoral = &HFFF08080~& ' _RGB32(240,128,128)
  137. CONST LightCyan = &HFFE0FFFF~& ' _RGB32(224,255,255)
  138. CONST LightGoldenRodYellow = &HFFFAFAD2~& ' _RGB32(250,250,210)
  139. CONST LightGray = &HFFD3D3D3~& ' _RGB32(211,211,211)
  140. CONST LightGreen = &HFF90EE90~& ' _RGB32(144,238,144)
  141. CONST LightPink = &HFFFFB6C1~& ' _RGB32(255,182,193)
  142. CONST LightSalmon = &HFFFFA07A~& ' _RGB32(255,160,122)
  143. CONST LightSeaGreen = &HFF20B2AA~& ' _RGB32(32,178,170)
  144. CONST LightSkyBlue = &HFF87CEFA~& ' _RGB32(135,206,250)
  145. CONST LightSlateGray = &HFF778899~& ' _RGB32(119,136,153)
  146. CONST LightSteelBlue = &HFFB0C4DE~& ' _RGB32(176,196,222)
  147. CONST LightYellow = &HFFFFFFE0~& ' _RGB32(255,255,224)
  148. CONST Lime = &HFF00FF00~& ' _RGB32(0,255,0)
  149. CONST LimeGreen = &HFF32CD32~& ' _RGB32(50,205,50)
  150. CONST Linen = &HFFFAF0E6~& ' _RGB32(250,240,230)
  151. CONST MacaroniAndCheese = &HFFFFBD88~& '_RGB32(255,189,136)
  152. CONST Magenta = &HFFFF00FF~& ' _RGB32(255,0,255)
  153. CONST MagicMint = &HFFAAF0D1~& '_RGB32(170,240,209)
  154. CONST Mahogany = &HFFCD4A4C~& '_RGB32(205,74,76)
  155. CONST Maize = &HFFEDD19C~& '_RGB32(237,209,156)
  156. CONST Manatee = &HFF979AAA~& '_RGB32(151,154,170)
  157. CONST MangoTango = &HFFFF8243~& '_RGB32(255,130,67)
  158. CONST Maroon = &HFF800000~& ' _RGB32(128,0,0)
  159. CONST Mauvelous = &HFFEF98AA~& '_RGB32(239,152,170)
  160. CONST MediumAquamarine = &HFF66CDAA~& ' _RGB32(102,205,170)
  161. CONST MediumBlue = &HFF0000CD~& ' _RGB32(0,0,205)
  162. CONST MediumOrchid = &HFFBA55D3~& ' _RGB32(186,85,211)
  163. CONST MediumPurple = &HFF9370DB~& ' _RGB32(147,112,219)
  164. CONST MediumSeaGreen = &HFF3CB371~& ' _RGB32(60,179,113)
  165. CONST MediumSlateBlue = &HFF7B68EE~& ' _RGB32(123,104,238)
  166. CONST MediumSpringGreen = &HFF00FA9A~& ' _RGB32(0,250,154)
  167. CONST MediumTurquoise = &HFF48D1CC~& ' _RGB32(72,209,204)
  168. CONST MediumVioletRed = &HFFC71585~& ' _RGB32(199,21,133)
  169. CONST Melon = &HFFFDBCB4~& '_RGB32(253,188,180)
  170. CONST MidnightBlue = &HFF191970~& ' _RGB32(25,25,112)
  171. CONST MintCream = &HFFF5FFFA~& ' _RGB32(245,255,250)
  172. CONST MistyRose = &HFFFFE4E1~& ' _RGB32(255,228,225)
  173. CONST Moccasin = &HFFFFE4B5~& ' _RGB32(255,228,181)
  174. CONST MountainMeadow = &HFF30BA8F~& '_RGB32(48,186,143)
  175. CONST Mulberry = &HFFC54B8C~& '_RGB32(197,75,140)
  176. CONST NavajoWhite = &HFFFFDEAD~& ' _RGB32(255,222,173)
  177. CONST Navy = &HFF000080~& ' _RGB32(0,0,128)
  178. CONST NavyBlue = &HFF1974D2~& '_RGB32(25,116,210)
  179. CONST NeonCarrot = &HFFFFA343~& '_RGB32(255,163,67)
  180. CONST OldLace = &HFFFDF5E6~& ' _RGB32(253,245,230)
  181. CONST Olive = &HFF808000~& ' _RGB32(128,128,0)
  182. CONST OliveDrab = &HFF6B8E23~& ' _RGB32(107,142,35)
  183. CONST OliveGreen = &HFFBAB86C~& '_RGB32(186,184,108)
  184. CONST Orange = &HFFFFA500~& ' _RGB32(255,165,0)
  185. CONST OrangeRed = &HFFFF4500~& ' _RGB32(255,69,0)
  186. CONST OrangeYellow = &HFFF8D568~& '_RGB32(248,213,104)
  187. CONST Orchid = &HFFDA70D6~& ' _RGB32(218,112,214)
  188. CONST OuterSpace = &HFF414A4C~& '_RGB32(65,74,76)
  189. CONST OutrageousOrange = &HFFFF6E4A~& '_RGB32(255,110,74)
  190. CONST PacificBlue = &HFF1CA9C9~& '_RGB32(28,169,201)
  191. CONST PaleGoldenRod = &HFFEEE8AA~& ' _RGB32(238,232,170)
  192. CONST PaleGreen = &HFF98FB98~& ' _RGB32(152,251,152)
  193. CONST PaleTurquoise = &HFFAFEEEE~& ' _RGB32(175,238,238)
  194. CONST PaleVioletRed = &HFFDB7093~& ' _RGB32(219,112,147)
  195. CONST PapayaWhip = &HFFFFEFD5~& ' _RGB32(255,239,213)
  196. CONST Peach = &HFFFFCFAB~& '_RGB32(255,207,171)
  197. CONST PeachPuff = &HFFFFDAB9~& ' _RGB32(255,218,185)
  198. CONST Periwinkle = &HFFC5D0E6~& '_RGB32(197,208,230)
  199. CONST Peru = &HFFCD853F~& ' _RGB32(205,133,63)
  200. CONST PiggyPink = &HFFFDDDE6~& '_RGB32(253,221,230)
  201. CONST PineGreen = &HFF158078~& '_RGB32(21,128,120)
  202. CONST Pink = &HFFFFC0CB~& ' _RGB32(255,192,203)
  203. CONST PinkFlamingo = &HFFFC74FD~& '_RGB32(252,116,253)
  204. CONST PinkSherbet = &HFFF78FA7~& '_RGB32(247,143,167)
  205. CONST Plum = &HFFDDA0DD~& ' _RGB32(221,160,221)
  206. CONST PowderBlue = &HFFB0E0E6~& ' _RGB32(176,224,230)
  207. CONST Purple = &HFF800080~& ' _RGB32(128,0,128)
  208. CONST PurpleHeart = &HFF7442C8~& '_RGB32(116,66,200)
  209. CONST PurpleMountainsMajesty = &HFF9D81BA~& '_RGB32(157,129,186)
  210. CONST PurplePizzazz = &HFFFE4EDA~& '_RGB32(254,78,218)
  211. CONST RadicalRed = &HFFFF496C~& '_RGB32(255,73,108)
  212. CONST RawSienna = &HFFD68A59~& '_RGB32(214,138,89)
  213. CONST RawUmber = &HFF714B23~& '_RGB32(113,75,35)
  214. CONST RazzleDazzleRose = &HFFFF48D0~& '_RGB32(255,72,208)
  215. CONST Razzmatazz = &HFFE3256B~& '_RGB32(227,37,107)
  216. CONST Red = &HFFFF0000~& ' _RGB32(255,0,0)
  217. CONST RedOrange = &HFFFF5349~& '_RGB32(255,83,73)
  218. CONST RedViolet = &HFFC0448F~& '_RGB32(192,68,143)
  219. CONST RobinsEggBlue = &HFF1FCECB~& '_RGB32(31,206,203)
  220. CONST RosyBrown = &HFFBC8F8F~& ' _RGB32(188,143,143)
  221. CONST RoyalBlue = &HFF4169E1~& ' _RGB32(65,105,225)
  222. CONST RoyalPurple = &HFF7851A9~& '_RGB32(120,81,169)
  223. CONST SaddleBrown = &HFF8B4513~& ' _RGB32(139,69,19)
  224. CONST Salmon = &HFFFA8072~& ' _RGB32(250,128,114)
  225. CONST SandyBrown = &HFFF4A460~& ' _RGB32(244,164,96)
  226. CONST Scarlet = &HFFFC2847~& '_RGB32(252,40,71)
  227. CONST ScreaminGreen = &HFF76FF7A~& '_RGB32(118,255,122)
  228. CONST SeaGreen = &HFF2E8B57~& ' _RGB32(46,139,87)
  229. CONST SeaShell = &HFFFFF5EE~& ' _RGB32(255,245,238)
  230. CONST Sepia = &HFFA5694F~& '_RGB32(165,105,79)
  231. CONST Shadow = &HFF8A795D~& '_RGB32(138,121,93)
  232. CONST Shamrock = &HFF45CEA2~& '_RGB32(69,206,162)
  233. CONST ShockingPink = &HFFFB7EFD~& '_RGB32(251,126,253)
  234. CONST Sienna = &HFFA0522D~& ' _RGB32(160,82,45)
  235. CONST Silver = &HFFC0C0C0~& ' _RGB32(192,192,192)
  236. CONST SkyBlue = &HFF87CEEB~& ' _RGB32(135,206,235)
  237. CONST SlateBlue = &HFF6A5ACD~& ' _RGB32(106,90,205)
  238. CONST SlateGray = &HFF708090~& ' _RGB32(112,128,144)
  239. CONST Snow = &HFFFFFAFA~& ' _RGB32(255,250,250)
  240. CONST SpringGreen = &HFF00FF7F~& ' _RGB32(0,255,127)
  241. CONST SteelBlue = &HFF4682B4~& ' _RGB32(70,130,180)
  242. CONST Sunglow = &HFFFFCF48~& '_RGB32(255,207,72)
  243. CONST SunsetOrange = &HFFFD5E53~& '_RGB32(253,94,83)
  244. CONST Tann = &HFFD2B48C~& ' _RGB32(210,180,140)
  245. CONST Teal = &HFF008080~& ' _RGB32(0,128,128)
  246. CONST TealBlue = &HFF18A7B5~& '_RGB32(24,167,181)
  247. CONST Thistle = &HFFD8BFD8~& ' _RGB32(216,191,216)
  248. CONST TickleMePink = &HFFFC89AC~& '_RGB32(252,137,172)
  249. CONST Timberwolf = &HFFDBD7D2~& '_RGB32(219,215,210)
  250. CONST Tomato = &HFFFF6347~& ' _RGB32(255,99,71)
  251. CONST TropicalRainForest = &HFF17806D~& '_RGB32(23,128,109)
  252. CONST Tumbleweed = &HFFDEAA88~& '_RGB32(222,170,136)
  253. CONST Turquoise = &HFF40E0D0~& ' _RGB32(64,224,208)
  254. CONST TurquoiseBlue = &HFF77DDE7~& '_RGB32(119,221,231)
  255. CONST UnmellowYellow = &HFFFFFF66~& '_RGB32(255,255,102)
  256. CONST Violet = &HFFEE82EE~& ' _RGB32(238,130,238)
  257. CONST VioletBlue = &HFF324AB2~& '_RGB32(50,74,178)
  258. CONST VioletRed = &HFFF75394~& '_RGB32(247,83,148)
  259. CONST VividTangerine = &HFFFFA089~& '_RGB32(255,160,137)
  260. CONST VividViolet = &HFF8F509D~& '_RGB32(143,80,157)
  261. CONST Wheat = &HFFF5DEB3~& ' _RGB32(245,222,179)
  262. CONST White = &HFFFFFFFF~& ' _RGB32(255,255,255)
  263. CONST Whitesmoke = &HFFF5F5F5~& ' _RGB32(245,245,245)
  264. CONST WildBlueYonder = &HFFA2ADD0~& '_RGB32(162,173,208)
  265. CONST WildStrawberry = &HFFFF43A4~& '_RGB32(255,67,164)
  266. CONST WildWatermelon = &HFFFC6C85~& '_RGB32(252,108,133)
  267. CONST Wisteria = &HFFCDA4DE~& '_RGB32(205,164,222)
  268. CONST Yellow = &HFFFFFF00~& ' _RGB32(255,255,0)
  269. CONST YellowGreen = &HFF9ACD32~& ' _RGB32(154,205,50)
  270. CONST YellowOrange = &HFFFFAE42~& '_RGB32(255,174,66)
  271.  
  272.  
  273. DEFLNG A-Z
  274. WS = _NEWIMAGE(640, 480, 32)
  275.  
  276. TYPE BulletInfo
  277.     valid AS INTEGER
  278.     x AS INTEGER
  279.     y AS INTEGER
  280.  
  281. DIM SHARED Bullet(100) AS BulletInfo
  282.  
  283. CLS , SkyBlue
  284. LINE (0, 479)-(639, 460), Brown, BF
  285. PCOPY 0, 1 'Save as the background
  286. x = 290
  287. ROF = 50
  288. Ammo = 1000
  289.  
  290.     PCOPY 1, 0
  291.     _LIMIT 180
  292.     IF _KEYDOWN(19200) THEN
  293.         x = x - 1
  294.     ELSEIF _KEYDOWN(19712) THEN
  295.         x = x + 1
  296.     END IF
  297.     IF x < 0 THEN x = 0
  298.     IF x > 570 THEN x = 570
  299.     IF _KEYDOWN(27) THEN GameOver = -1
  300.     IF _KEYDOWN(32) THEN Shoot x
  301.  
  302.     DrawPlayer x
  303.     DrawBullets
  304.     DrawStatus
  305.     _DISPLAY
  306. LOOP UNTIL GameOver
  307.  
  308.  
  309. SUB DrawStatus
  310.     _PRINTSTRING (10, 462), "AMMO:" + STR$(Ammo)
  311.     _PRINTSTRING (560, 462), TIME$
  312.  
  313. SUB DrawPlayer (x)
  314.     LINE (x + i, 445)-STEP(70, 15), Red, BF
  315.     LINE (x + 10, 425)-STEP(50, 20), Red, BF
  316.     LINE (x + 30, 415)-STEP(10, 10), Red, BF
  317.  
  318. SUB DrawBullets
  319.     FOR i = 1 TO 100
  320.         IF Bullet(i).valid THEN
  321.             Bullet(i).y = Bullet(i).y - 1
  322.             IF Bullet(i).y < 0 THEN Bullet(i).valid = 0: _CONTINUE
  323.             LINE (Bullet(i).x, Bullet(i).y)-STEP(3, 5), Red, BF
  324.         END IF
  325.     NEXT
  326.  
  327.  
  328. SUB Shoot (x)
  329.     STATIC Delay AS _FLOAT
  330.     IF ExtendedTimer > Delay + ROF / 1000 THEN 'only shoot once every Rate Of Fire
  331.         FOR i = 1 TO 100
  332.             IF Bullet(i).valid = 0 THEN
  333.                 Bullet(i).valid = -1
  334.                 Bullet(i).x = x + 33
  335.                 Bullet(i).y = 410
  336.                 Ammo = Ammo - 1
  337.                 Delay = ExtendedTimer
  338.                 EXIT SUB
  339.             END IF
  340.         NEXT
  341.     END IF
  342.  
  343.  
  344. FUNCTION ExtendedTimer##
  345.     d$ = DATE$
  346.     l = INSTR(d$, "-")
  347.     l1 = INSTR(l + 1, d$, "-")
  348.     m = VAL(LEFT$(d$, l))
  349.     d = VAL(MID$(d$, l + 1))
  350.     y = VAL(MID$(d$, l1 + 1)) - 1970
  351.     FOR i = 1 TO m
  352.         SELECT CASE i 'Add the number of days for each previous month passed
  353.             CASE 1: d = d 'January doestn't have any carry over days.
  354.             CASE 2, 4, 6, 8, 9, 11: d = d + 31
  355.             CASE 3: d = d + 28
  356.             CASE 5, 7, 10, 12: d = d + 30
  357.         END SELECT
  358.     NEXT
  359.     FOR i = 1 TO y
  360.         d = d + 365
  361.     NEXT
  362.     FOR i = 2 TO y STEP 4
  363.         IF m > 2 THEN d = d + 1 'add an extra day for leap year every 4 years, starting in 2016
  364.     NEXT
  365.     s~&& = d * 24 * 60 * 60 'Seconds are days * 24 hours * 60 minutes * 60 seconds
  366.     ExtendedTimer## = (s~&& + TIMER)
  367.  

I was playing around with making a simple little shooter type game earlier today, and when I got this far along, I thought I'd go ahead and share what I have here so people could use it as an easily expandable start for their own games. 

Toss some little invaders that move left and right across the screen and a collision detection routine, and you have a basic version of Space Invaders.  Toss in some airplanes which fly by the top of the screen and drop bombs, and you have a bomber game...   

Right now, we don't really do much except provide the bare bones to expand upon to build/grow a game, but I thought I'd share it so folks can build upon it/study it as it currently exists.   Enjoy.  ;)
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Shooter Start
« Reply #1 on: March 30, 2019, 11:29:05 pm »
Oh, you mean like this?

Code: QB64: [Select]
  1. DECLARE SUB instructions ()
  2. DECLARE SUB qbide ()
  3. DECLARE SUB mship (imothership)
  4. REM Adds multiple bullets (5) max.
  5. REM Adds firing delay and ship turns red while reloading.
  6. REM Adds aliens.
  7. REM Adds collision for bullets from base to aliens.
  8. REM Adds Mouse support.
  9. REM Adds alien motion.
  10. REM Adds 3 progressive levels.
  11. REM Adds aliens move all the way to both sides.
  12. REM Adds Aliens shoot back.
  13. REM Adds sub-routines.
  14. REM Adds counter.
  15. REM Adds alien bullets finish before moving on to next level.
  16. REM Adds mothership.
  17.  
  18. DECLARE SUB alienattack (ialiencolstat, ialiencol)
  19. DECLARE SUB alienmissile (iresults)
  20. DECLARE SUB checkcollision (ihitaliens, ialiencol, i4, i)
  21. DECLARE SUB mdriver (ex%, key$, tankx%)
  22. DECLARE SUB marchdown (ialiencol, ialiencolstat, imotion, iresults)
  23. DECLARE SUB movealiens (ialiencol, ialiencolstat, iresults)
  24. DECLARE SUB reprintaliens (ialiencol, ihitaliens, iresults, i4, i, imothership)
  25.  
  26. TYPE RegType
  27.     AX AS INTEGER
  28.     BX AS INTEGER
  29.     CX AS INTEGER
  30.     DX AS INTEGER
  31.     BP AS INTEGER
  32.     SI AS INTEGER
  33.     DI AS INTEGER
  34.     FLAGS AS INTEGER
  35.     DS AS INTEGER
  36.     ES AS INTEGER
  37.  
  38. DIM SHARED MOUSE$
  39. DIM SHARED Registers AS RegType
  40. DIM SHARED LB%, RB%, MB%, DX, CX
  41. DIM SHARED lmargin%, rmargin%, topmargin%, screenwidth%, level, ibk, ileadingrow
  42. DIM SHARED irow, icol, inextrnd, imaxalienmissiles, alienforce%, ileadingmax, imaxalienforce, ihits
  43.  
  44. imaxalienforce = 6
  45. imaxalienmissiles = 3
  46. lmargin% = 2
  47. rmargin% = 79
  48. topmargin% = 3
  49. ialiencolstat = 6
  50. iwin = 3
  51. screenwidth% = rmargin% - lmargin% + 1
  52. ibk = 1
  53.  
  54. DIM SHARED a(imaxalienforce) AS STRING * 68
  55.  
  56. SCREEN 0, 0, 0, 0
  57. COLOR 7, 1: CLS
  58.  
  59. REM Make aliens
  60. a1$ = "-<" + CHR$(237) + ">-  "
  61. a$ = a1$ + a1$ + a1$ + a1$ + a1$ + a1$ + a1$ + a1$ + a1$ + a1$
  62.  
  63. CALL qbide
  64. CALL instructions
  65.  
  66.     IF inextrnd = -1 THEN PCOPY 3, 0
  67.     tank$ = CHR$(218) + CHR$(127) + CHR$(191): icolor = 7
  68.     REDIM SHARED bullet%(5), bulletcol%(5), bulletdelay%(5), iltalien(imaxalienforce)
  69.     REDIM SHARED ia(imaxalienmissiles), iy(imaxalienmissiles), ix(imaxalienmissiles)
  70.     REDIM SHARED matrix(imaxalienforce) AS STRING * 10
  71.     alienforce% = imaxalienforce
  72.     level = .65
  73.     iround = iround + 1
  74.     level = level - iround / 15
  75.     inextrnd = -1
  76.     COLOR 7, ibk
  77.  
  78.     REM Set up aliens
  79.     ialiencol = ialiencolstat
  80.     LOCATE 2, ialiencol
  81.     FOR i = 1 TO imaxalienforce
  82.         IF i MOD 1 = 0 THEN PRINT
  83.         LOCATE , ialiencol
  84.         IF i = imaxalienforce THEN ileadingrow = CSRLIN: ileadingmax = ileadingrow
  85.         a(i) = a$
  86.         PRINT a(i)
  87.     NEXT
  88.  
  89.     REM Station
  90.     LOCATE 24, 40, 1, 7, 7
  91.     PRINT tank$;: LOCATE , POS(1) - 2: tanky% = CSRLIN: tankx% = POS(1) + 1
  92.     key$ = INKEY$: SLEEP 1
  93.     ex% = 1: CALL mdriver(ex%, key$, tankx%)
  94.     DO
  95.         z1 = TIMER
  96.         DO
  97.             IF topmargin% + ileadingmax - (imaxalienforce * 2) >= topmargin% + 2 THEN
  98.                 IF imothership <> 0 THEN CALL mship(imothership)
  99.             END IF
  100.             IF ABS(TIMER - z1aliens) > level THEN
  101.                 CALL movealiens(ialiencol, ialiencolstat, iresults)
  102.                 z1aliens = TIMER
  103.             END IF
  104.             IF iresults < 0 THEN EXIT DO
  105.             IF ABS(TIMER - z1ia) > .3 THEN CALL alienmissile(iresults): z1ia = TIMER
  106.             key$ = INKEY$
  107.             IF key$ = "" THEN ex% = 2: CALL mdriver(ex%, key$, tankx%)
  108.             SELECT CASE key$
  109.                 CASE CHR$(0) + "K"
  110.                     IF POS(1) > lmargin% + 1 THEN COLOR icolor, ibk: LOCATE , POS(1) - 2: PRINT tank$ + " ";: LOCATE , POS(1) - 3
  111.                     tanky% = CSRLIN: tankx% = POS(1)
  112.                     IF SCREEN(tanky%, tankx% - 2) = 25 OR SCREEN(tanky%, tankx% + 2) = 25 THEN result = -1: EXIT DO
  113.                 CASE CHR$(0) + "M"
  114.                     IF POS(1) < screenwidth% THEN COLOR icolor, ibk: LOCATE , POS(1) - 1: PRINT " " + tank$;: LOCATE , POS(1) - 2
  115.                     tanky% = CSRLIN: tankx% = POS(1)
  116.                     IF SCREEN(tanky%, tankx% - 2) = 25 OR SCREEN(tanky%, tankx% + 2) = 25 THEN result = -1: EXIT DO
  117.                 CASE CHR$(32)
  118.                     IF icolor = 7 THEN
  119.                         FOR i2 = 1 TO 5
  120.                             IF bullet%(i2) = 0 THEN
  121.                                 icolor = 12: COLOR icolor, ibk: GOSUB redraw
  122.                                 bullet%(i2) = -1: reload = TIMER: EXIT FOR
  123.                             END IF
  124.                         NEXT
  125.                     END IF
  126.                 CASE CHR$(27): SYSTEM
  127.             END SELECT
  128.  
  129.             IF ABS(z1 - reload) > .7 AND reload <> 0 THEN
  130.                 GOSUB redraw
  131.                 icolor = 7: reload = 0
  132.             END IF
  133.  
  134.             REM Fire
  135.             FOR i = 1 TO 5
  136.                 SELECT CASE bullet%(i)
  137.                     CASE -1: bullet%(i) = tanky% - 1: bulletcol%(i) = tankx%
  138.                     CASE IS > 0
  139.                         IF bulletdelay%(i) = -1 OR bullet%(i) = tanky% - 1 THEN
  140.                             CALL checkcollision(ihitaliens, ialiencol, i4, i)
  141.                             z2bullet = TIMER: bulletdelay%(i) = 0
  142.                             COLOR 7, ibk
  143.                             LOCATE bullet%(i), bulletcol%(i)
  144.                             IF bullet%(i) = topmargin% AND imothership <> 0 THEN
  145.                                 IF SCREEN(ABS(bullet%(i)), bulletcol%(i)) <> 32 THEN
  146.                                     SOUND 1000, .75
  147.                                     LOCATE topmargin%, lmargin%: PRINT SPACE$(screenwidth%);
  148.                                     imothership = 0
  149.                                 END IF
  150.                             END IF
  151.                             PRINT CHR$(24)
  152.                             IF CSRLIN <> 24 THEN LOCATE , bulletcol%(i): PRINT " ";
  153.                             IF ihitaliens <> 0 THEN CALL reprintaliens(ialiencol, ihitaliens, iresults, i4, i, imothership)
  154.                             LOCATE tanky%, tankx%
  155.                             IF bullet%(i) > topmargin% THEN
  156.                                 bullet%(i) = bullet%(i) - 1
  157.                             ELSE
  158.                                 GOSUB erasebullet
  159.                             END IF
  160.                         END IF
  161.                 END SELECT
  162.             NEXT
  163.  
  164.             REM Bullet timer delay
  165.             IF z2bullet <> 0 THEN
  166.                 IF z1 < z2bullet THEN z2bullet = z2bullet - 86400
  167.                 IF z1 - z2bullet >= .06 THEN
  168.                     FOR i2 = 1 TO 5
  169.                         IF bullet%(i2) <> 0 THEN bulletdelay%(i2) = -1
  170.                     NEXT i2
  171.                 END IF
  172.                 EXIT DO
  173.             END IF
  174.         LOOP
  175.         IF iresults < 0 THEN EXIT DO
  176.         IF alienforce% = 0 OR iresults = iwin THEN
  177.             FOR i = 1 TO imaxalienmissiles
  178.                 IF ia(i) <> 0 THEN EXIT FOR
  179.             NEXT
  180.             IF i > imaxalienmissiles THEN iwait = -1
  181.             IF iwait = -1 THEN
  182.                 EXIT DO
  183.             END IF
  184.         ELSE
  185.             iwait = 1
  186.         END IF
  187.     LOOP
  188.     ex% = -1: CALL mdriver(ex%, key$, tankx%)
  189.     key$ = INKEY$
  190.     SLEEP 2
  191.     IF iresults = iwin OR iresults < 0 THEN
  192.         REM end game
  193.         EXIT DO
  194.     END IF
  195.     inextrnd = -1
  196. SELECT CASE iresults
  197.     CASE IS < 0
  198.         COLOR 7, ibk
  199.         LOCATE tanky% - 1, lmargin%
  200.         PRINT SPACE$(screenwidth%);
  201.         LOCATE tanky%, lmargin%
  202.         PRINT SPACE$(screenwidth%);
  203.         key$ = INKEY$
  204.         SOUND 140, 2
  205.         SLEEP 2
  206. CALL qbide
  207. CALL instructions
  208.  
  209. erasebullet:
  210. LOCATE ABS(bullet%(i)), bulletcol%(i): PRINT " ";
  211. bullet%(i) = 0: bulletcol%(i) = 0: bulletdelay%(i) = 0
  212. LOCATE tanky%, tankx%
  213.  
  214. redraw:
  215. COLOR , ibk: LOCATE tanky%, tankx% - 1: PRINT tank$;: LOCATE tanky%, tankx%: COLOR 7, ibk
  216.  
  217. DATA "Well, I better get busy and finish the compiler..."
  218. DATA "Or... I'll just do some more work on this IDE, instead..."
  219. DATA ""
  220. DATA " Loading..."
  221. DATA "EOF"
  222. DATA "Game Over. Thanks for playing..."
  223. DATA ""
  224. DATA "Now finish the compiler!"
  225. DATA "EOF2"
  226.  
  227. SUB alienattack (ialiencolstat, ialiencol)
  228. z2alienfire = TIMER
  229.  
  230. i3 = INT(RND * 10)
  231. FOR i = 1 TO imaxalienmissiles
  232.     IF ia(i) = 0 THEN
  233.         FOR i2 = imaxalienforce TO 1 STEP -1
  234.             IF RTRIM$(a(i2)) <> "" THEN
  235.                 IF MID$(matrix(i2), i3 + 1, 1) <> "0" THEN
  236.                     i4 = INSTR(i3 * 7 + 1, a(i2), CHR$(237)) + ialiencol
  237.                     EXIT FOR
  238.                 END IF
  239.             END IF
  240.         NEXT i2
  241.         IF i4 <> 0 THEN
  242.             ia(i) = (ileadingmax - (imaxalienforce - i2) * 2) * 80 + i4
  243.             EXIT FOR
  244.         END IF
  245.     END IF
  246.  
  247.  
  248. SUB alienmissile (iresults)
  249. irow = CSRLIN: icol = POS(1)
  250. FOR i = 1 TO imaxalienmissiles
  251.     IF ia(i) <> 0 THEN
  252.         IF iy(i) = 0 THEN
  253.             iy(i) = ia(i) \ 80: ix(i) = ia(i) MOD 80
  254.             IF ix(i) = 0 THEN ix(i) = screenwidth%
  255.         END IF
  256.         LOCATE iy(i) + 1, ix(i)
  257.         COLOR 7, ibk
  258.         IF CSRLIN <= 24 THEN
  259.             IF CSRLIN = 24 THEN IF SCREEN(CSRLIN, ix(i)) <> 32 THEN iresults = -1
  260.             PRINT CHR$(25);
  261.         ELSE
  262.             ia(i) = 0
  263.             LOCATE iy(i), ix(i)
  264.             PRINT " ";: iy(i) = 0
  265.             ia(i) = 0
  266.             LOCATE irow, icol
  267.             EXIT SUB
  268.         END IF
  269.         LOCATE iy(i), ix(i): PRINT " ";
  270.         iy(i) = iy(i) + 1
  271.     END IF
  272. LOCATE irow, icol
  273.  
  274.  
  275. SUB checkcollision (ihitaliens, ialiencol, i4, i)
  276. ihitaliens = 0
  277. IF ileadingmax MOD 2 = bullet%(i) MOD 2 THEN
  278.     i4 = imaxalienforce - (ileadingmax - bullet%(i)) \ 2
  279.     IF bullet%(i) <= ileadingrow AND i4 > 0 AND i4 <= imaxalienforce THEN
  280.         IF RTRIM$(a(i4)) <> "" THEN
  281.             IF bulletcol%(i) >= iltalien(i4) AND bulletcol%(i) - ialiencol <= LEN(RTRIM$(a(i4))) THEN
  282.                 IF MID$(a(i4), bulletcol%(i) - ialiencol, 1) > CHR$(32) THEN
  283.                     ihitaliens = bulletcol%(i) - ialiencol + 1
  284.                     i3 = ihitaliens - 7 + 1: IF i3 < 1 THEN i3 = 1: REM count from the "<" symbol.
  285.                     i2 = INSTR(i3 + 1, a(i4), "<") - 1
  286.                     MID$(a(i4), i2, 7) = SPACE$(7)
  287.                     MID$(matrix(i4), (i2 + 1) \ 7 + 1, 1) = "0"
  288.                 END IF
  289.             END IF
  290.         END IF
  291.     END IF
  292.  
  293. FOR i2 = 1 TO imaxalienmissiles
  294.     IF ia(i2) <> 0 THEN
  295.         IF iy(i2) >= bullet%(i) AND ix(i2) = bulletcol%(i) THEN
  296.             ihitaliens = -i2
  297.             EXIT FOR
  298.         END IF
  299.     END IF
  300.  
  301.  
  302. SUB instructions
  303.  
  304. ''in$ = "EOF"
  305. IF in$ = "" THEN
  306.     key$ = INKEY$
  307.     LOCATE 3, 3, 1, 7, 7: COLOR 7, ibk
  308.     SLEEP 2
  309.     DO
  310.         READ in$
  311.         IF MID$(in$, 1, 3) = "EOF" THEN EXIT DO
  312.         FOR i = 1 TO LEN(in$)
  313.             SOUND 400, .1
  314.             LOCATE , 2 + i
  315.             PRINT MID$(in$, i, 1);
  316.             z = TIMER
  317.             DO
  318.                 IF ABS(z - TIMER) > .1 THEN EXIT DO
  319.             LOOP
  320.         NEXT
  321.         LOCATE , , 0, 7, 0
  322.         key$ = INKEY$
  323.         SLEEP 1
  324.         PRINT
  325.         LOCATE , 3
  326.     LOOP
  327.     key$ = INKEY$
  328.     SLEEP 1
  329.  
  330. IF in$ = "EOF" THEN
  331.     COLOR 7, 1
  332.     FOR i = 1 TO 5
  333.         LOCATE 2 + i, 2: PRINT SPACE$(78)
  334.     NEXT
  335.     FOR i = 3 TO 24
  336.         LOCATE i, 80: PRINT CHR$(179);
  337.     NEXT
  338.     LOCATE 21, 2: PRINT STRING$(78, " ");
  339.     LOCATE 22, 1: PRINT CHR$(179);
  340.     LOCATE 22, 80: PRINT CHR$(179);
  341.     LOCATE 22, 2: PRINT STRING$(78, " ");
  342.     COLOR 0, 3
  343.  
  344. COLOR 0, 3
  345. yy% = CSRLIN: xx% = POS(1)
  346. LOCATE 25, 76 - LEN(LTRIM$(STR$(ihits)))
  347. PRINT LTRIM$(STR$(ihits));
  348. LOCATE 25, 80 - LEN(LTRIM$(STR$(imaxalienforce - alienforce%)))
  349. PRINT "0";
  350. LOCATE yy%, xx%
  351.  
  352. PCOPY 0, 3: REM save skin
  353.  
  354.  
  355. SUB marchdown (ialiencol, ialiencolstat, imotion, iresults)
  356. COLOR 7, ibk
  357. ileadingrow = ileadingrow + 1
  358. ileadingmax = ileadingmax + 1
  359. COLOR 7, ibk
  360. FOR i = 1 TO imaxalienforce
  361.     IF RTRIM$(a(i)) <> "" THEN
  362.         ialiencol = ialiencolstat + imotion
  363.         LOCATE ileadingmax - (imaxalienforce * 2) + i * 2 - 1, lmargin%
  364.         PRINT STRING$(screenwidth%, " ")
  365.         LOCATE , ialiencol + INSTR(a(i), "-")
  366.         iltalien(i) = POS(1)
  367.         PRINT LTRIM$(RTRIM$(a(i)))
  368.     END IF
  369. LOCATE irow, icol
  370. level = level - .025
  371. IF ileadingrow = 22 THEN iresults = -2
  372.  
  373. SUB mdriver (ex%, key$, tankx%)
  374. STATIC MOUSEACT%
  375.  
  376. REM INITIATE MOUSE
  377. IF MOUSEACT% = 0 OR ex% = -1 THEN
  378.     Registers.AX = 0: GOSUB CALLI
  379.     MOUSEACT% = 1
  380.  
  381. IF ex% = 1 THEN
  382.     Registers.AX = 4: Registers.DX = 184: Registers.CX = 304
  383.     Registers.AX = 8: Registers.DX = 184: Registers.CX = 184
  384.     GOSUB CALLI
  385.     EXIT SUB
  386.  
  387. Registers.AX = 3: GOSUB CALLI
  388.  
  389. DX = Registers.DX
  390. CX = Registers.CX
  391. y% = DX \ 8 + 1: x% = CX \ 8 + 1
  392.  
  393. REM MOUSE BUTTONS
  394. LB% = Registers.BX AND 1
  395. RB% = (Registers.BX AND 2) \ 2
  396. MB% = (Registers.BX AND 4) \ 4
  397.  
  398. IF LB% <> 0 THEN
  399.     key$ = CHR$(32)
  400.     IF x% > tankx% THEN key$ = CHR$(0) + "M"
  401.     IF x% < tankx% THEN key$ = CHR$(0) + "K"
  402.  
  403. CALLI:
  404. CALL INTERRUPT(&H33, Registers, Registers)
  405.  
  406.  
  407. SUB movealiens (ialiencol, ialiencolstat, iresults)
  408. STATIC imotion, imarch, imotiondir
  409. IF inextrnd = -1 THEN inextrnd = 0: imotion = 0: imarch = 0: imotiondir = 0
  410. irow = CSRLIN: icol = POS(1)
  411. yy% = CSRLIN: xx% = POS(1)
  412. PCOPY 0, 1: SCREEN 0, 0, 1, 0: LOCATE yy%, xx%, 0, 7, 0
  413. IF imotiondir = 0 THEN imotion = imotion - 1 ELSE imotion = imotion + 1
  414. COLOR 7, ibk
  415.  
  416. FOR i = imaxalienforce TO 1 STEP -1
  417.     IF RTRIM$(a(i)) <> "" THEN
  418.         i2 = i2 + 2
  419.         SOUND 400, .03
  420.         ialiencol = ialiencolstat + imotion
  421.         LOCATE ileadingmax - (imaxalienforce - i) * 2, ialiencol + INSTR(a(i), "-")
  422.         IF POS(1) = lmargin% THEN imarch = 1
  423.         iltalien(i) = POS(1)
  424.         IF imotiondir = 0 THEN
  425.             PRINT LTRIM$(RTRIM$(a(i))); " "
  426.         ELSE
  427.             LOCATE , POS(1) - 1
  428.             PRINT " "; LTRIM$(RTRIM$(a(i)))
  429.         END IF
  430.         IF ialiencol + LEN(RTRIM$(a(i))) = screenwidth% THEN imarch = -1
  431.     END IF
  432.  
  433. IF imarch = 1 THEN imotiondir = 1: CALL marchdown(ialiencol, ialiencolstat, imotion, iresults)
  434. IF imarch = -1 THEN imotiondir = 0: CALL marchdown(ialiencol, ialiencolstat, imotion, iresults)
  435. IF imarch = 0 THEN
  436.     IF ABS(TIMER - z2alienfire) > firerate THEN
  437.         firerate = (INT(RND * 10) + 1) / 20
  438.         IF iwait = 0 THEN CALL alienattack(ialiencolstat, ialiencol)
  439.     END IF
  440.     imarch = 0
  441. PCOPY 1, 0: SCREEN 0, 0, 0, 0
  442. LOCATE irow, icol, 1, 7, 7
  443.  
  444. SUB mship (imothership)
  445. STATIC x%, mov%, z4, mothership$
  446.  
  447. yy% = CSRLIN: xx% = POS(1): COLOR 7, ibk
  448. IF imothership = -1 THEN
  449.     imothership = 1
  450.     x% = lmargin%
  451.     mothership$ = CHR$(254) + CHR$(254) + "O" + CHR$(254) + CHR$(254)
  452.     mov% = 1
  453.  
  454. IF ABS(TIMER - z4) > .05 THEN GOSUB mothership: z4 = TIMER: LOCATE yy%, xx%: EXIT SUB
  455. ''IF ABS(TIMER - z2) > .2 THEN GOSUB bullets: z2 = TIMER
  456. LOCATE yy%, xx%
  457.  
  458. mothership:
  459. IF x% + LEN(mothership$) = screenwidth% + lmargin% THEN mov% = -1 ELSE IF x% = lmargin% THEN mov% = 1
  460. x% = x% + mov%
  461. LOCATE topmargin%, x%
  462. PRINT mothership$;
  463. IF x% > 1 AND mov% = 1 THEN
  464.     LOCATE , POS(1) - LEN(mothership$) - 1: PRINT " ";
  465. IF mov% = -1 THEN PRINT " ";
  466.  
  467.  
  468. DEFINT A-H, J-Z
  469. SUB qbide
  470. PALETTE 2, 59
  471. COLOR 15, 1
  472.  
  473. COLOR 0, 7
  474. LOCATE 1, 1
  475. LOCATE 1, 1: PRINT "   File  Edit  View  Search  Run  Debug  Calls  Options                   Help"
  476.  
  477. COLOR 7, 1
  478.  
  479. LOCATE 2, 1: PRINT CHR$(218)
  480. LOCATE 2, 2: PRINT STRING$(78, CHR$(196))
  481. LOCATE 2, 80: PRINT CHR$(191)
  482.  
  483. LOCATE 2, 76: PRINT CHR$(180)
  484. LOCATE 2, 78: PRINT CHR$(195)
  485.  
  486. COLOR 1, 7
  487. LOCATE 2, 77: PRINT CHR$(24)
  488. LOCATE 2, 36: PRINT " Untitled "
  489.  
  490. COLOR 7, 1
  491. FOR Rows = 3 TO 24
  492.     LOCATE Rows, 1: PRINT CHR$(179);
  493.     LOCATE Rows, 80: PRINT CHR$(179);
  494. NEXT Rows
  495.  
  496. LOCATE 22, 1: PRINT CHR$(195)
  497. LOCATE 22, 80: PRINT CHR$(180)
  498. LOCATE 22, 2: PRINT STRING$(78, CHR$(196))
  499. LOCATE 22, 35
  500. PRINT " Immediate "
  501.  
  502. COLOR 0, 7
  503. LOCATE 21, 3: PRINT STRING$(76, CHR$(176))
  504. LOCATE 21, 2: PRINT CHR$(27)
  505. LOCATE 21, 3: PRINT CHR$(219)
  506. LOCATE 21, 79: PRINT CHR$(26)
  507. FOR Rows = 4 TO 19
  508.     LOCATE Rows, 80: PRINT CHR$(176)
  509. NEXT Rows
  510. LOCATE 3, 80: PRINT CHR$(24)
  511. LOCATE 4, 80: PRINT CHR$(219)
  512. LOCATE 20, 80: PRINT CHR$(25)
  513.  
  514. COLOR 0, 3: LOCATE 25, 1: PRINT " <Shift+F1=Help> <F6=Window> <F2=Subs> <F5=Run> <F8=Step> ";
  515. LOCATE 25, 59: PRINT SPACE$(4);
  516. COLOR 0, 3
  517. LOCATE 25, 63: PRINT CHR$(179);
  518. LOCATE 25, 64: PRINT SPACE$(6);
  519. LOCATE 25, 68: PRINT "C  00001:001 ";
  520.  
  521.  
  522. DEFSNG A-H, J-Z
  523. SUB reprintaliens (ialiencol, ihitaliens, iresults, i4, i, imothership)
  524. IF ihitaliens > 0 THEN
  525.     ihits = ihits + 1
  526.     IF (ihits + 15) MOD 20 = 0 AND imothership = 0 THEN imothership = -1
  527.     LOCATE bullet%(i), lmargin%: PRINT SPACE$(screenwidth%);
  528.     iltalien(i4) = POS(1)
  529.  
  530.     IF RTRIM$(a(i4)) = "" THEN
  531.         alienforce% = alienforce% - 1
  532.         IF alienforce% = 0 THEN iresults = iresults + 1
  533.         IF bullet%(i) = ileadingrow THEN ileadingrow = ileadingrow - 2
  534.     ELSE
  535.         LOCATE bullet%(i), ialiencol + INSTR(a(i4), "-"): PRINT LTRIM$(RTRIM$(a(i4)))
  536.     END IF
  537.     i2 = ABS(ihitaliens)
  538.     LOCATE iy(i2), ix(i2)
  539.     PRINT " ";: iy(i2) = 0
  540.     ia(i2) = 0
  541.     LOCATE irow, icol
  542.     SOUND 1000, .5
  543.  
  544. ihitaliens = 0
  545. bullet%(i) = -bullet%(i)
  546.  
  547. COLOR 0, 3
  548. yy% = CSRLIN: xx% = POS(1)
  549. LOCATE 25, 76 - LEN(LTRIM$(STR$(ihits)))
  550. PRINT LTRIM$(STR$(ihits));
  551. LOCATE 25, 80 - LEN(LTRIM$(STR$(imaxalienforce - alienforce%)))
  552. PRINT LTRIM$(STR$(imaxalienforce - alienforce%));
  553. LOCATE yy%, xx%
  554. COLOR 7, ibk
  555.  

Edit: Hey, I found the mother ship version! Mouse to move, left click to shoot.
« Last Edit: March 31, 2019, 02:12:19 am by Pete »
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline qb4ever

  • Newbie
  • Posts: 40
  • LOCATE 15,15: COLOR 14: PRINT "Hello World!"
    • View Profile
Re: Shooter Start
« Reply #2 on: March 31, 2019, 07:36:13 am »
Woow !

Oh, you mean like this?

Code: QB64: [Select]
  1. DECLARE SUB instructions ()
  2. DECLARE SUB qbide ()
  3. DECLARE SUB mship (imothership)
  4. REM Adds multiple bullets (5) max.
  5. REM Adds firing delay and ship turns red while reloading.
  6. REM Adds aliens.
  7. REM Adds collision for bullets from base to aliens.
  8. REM Adds Mouse support.
  9. REM Adds alien motion.
  10. REM Adds 3 progressive levels.
  11. REM Adds aliens move all the way to both sides.
  12. REM Adds Aliens shoot back.
  13. REM Adds sub-routines.
  14. REM Adds counter.
  15. REM Adds alien bullets finish before moving on to next level.
  16. REM Adds mothership.
  17.  
  18. DECLARE SUB alienattack (ialiencolstat, ialiencol)
  19. DECLARE SUB alienmissile (iresults)
  20. DECLARE SUB checkcollision (ihitaliens, ialiencol, i4, i)
  21. DECLARE SUB mdriver (ex%, key$, tankx%)
  22. DECLARE SUB marchdown (ialiencol, ialiencolstat, imotion, iresults)
  23. DECLARE SUB movealiens (ialiencol, ialiencolstat, iresults)
  24. DECLARE SUB reprintaliens (ialiencol, ihitaliens, iresults, i4, i, imothership)
  25.  
  26. TYPE RegType
  27.     AX AS INTEGER
  28.     BX AS INTEGER
  29.     CX AS INTEGER
  30.     DX AS INTEGER
  31.     BP AS INTEGER
  32.     SI AS INTEGER
  33.     DI AS INTEGER
  34.     FLAGS AS INTEGER
  35.     DS AS INTEGER
  36.     ES AS INTEGER
  37.  
  38. DIM SHARED MOUSE$
  39. DIM SHARED Registers AS RegType
  40. DIM SHARED LB%, RB%, MB%, DX, CX
  41. DIM SHARED lmargin%, rmargin%, topmargin%, screenwidth%, level, ibk, ileadingrow
  42. DIM SHARED irow, icol, inextrnd, imaxalienmissiles, alienforce%, ileadingmax, imaxalienforce, ihits
  43.  
  44. imaxalienforce = 6
  45. imaxalienmissiles = 3
  46. lmargin% = 2
  47. rmargin% = 79
  48. topmargin% = 3
  49. ialiencolstat = 6
  50. iwin = 3
  51. screenwidth% = rmargin% - lmargin% + 1
  52. ibk = 1
  53.  
  54. DIM SHARED a(imaxalienforce) AS STRING * 68
  55.  
  56. SCREEN 0, 0, 0, 0
  57. COLOR 7, 1: CLS
  58.  
  59. REM Make aliens
  60. a1$ = "-<" + CHR$(237) + ">-  "
  61. a$ = a1$ + a1$ + a1$ + a1$ + a1$ + a1$ + a1$ + a1$ + a1$ + a1$
  62.  
  63. CALL qbide
  64. CALL instructions
  65.  
  66.     IF inextrnd = -1 THEN PCOPY 3, 0
  67.     tank$ = CHR$(218) + CHR$(127) + CHR$(191): icolor = 7
  68.     REDIM SHARED bullet%(5), bulletcol%(5), bulletdelay%(5), iltalien(imaxalienforce)
  69.     REDIM SHARED ia(imaxalienmissiles), iy(imaxalienmissiles), ix(imaxalienmissiles)
  70.     REDIM SHARED matrix(imaxalienforce) AS STRING * 10
  71.     alienforce% = imaxalienforce
  72.     level = .65
  73.     iround = iround + 1
  74.     level = level - iround / 15
  75.     inextrnd = -1
  76.     COLOR 7, ibk
  77.  
  78.     REM Set up aliens
  79.     ialiencol = ialiencolstat
  80.     LOCATE 2, ialiencol
  81.     FOR i = 1 TO imaxalienforce
  82.         IF i MOD 1 = 0 THEN PRINT
  83.         LOCATE , ialiencol
  84.         IF i = imaxalienforce THEN ileadingrow = CSRLIN: ileadingmax = ileadingrow
  85.         a(i) = a$
  86.         PRINT a(i)
  87.     NEXT
  88.  
  89.     REM Station
  90.     LOCATE 24, 40, 1, 7, 7
  91.     PRINT tank$;: LOCATE , POS(1) - 2: tanky% = CSRLIN: tankx% = POS(1) + 1
  92.     key$ = INKEY$: SLEEP 1
  93.     ex% = 1: CALL mdriver(ex%, key$, tankx%)
  94.     DO
  95.         z1 = TIMER
  96.         DO
  97.             IF topmargin% + ileadingmax - (imaxalienforce * 2) >= topmargin% + 2 THEN
  98.                 IF imothership <> 0 THEN CALL mship(imothership)
  99.             END IF
  100.             IF ABS(TIMER - z1aliens) > level THEN
  101.                 CALL movealiens(ialiencol, ialiencolstat, iresults)
  102.                 z1aliens = TIMER
  103.             END IF
  104.             IF iresults < 0 THEN EXIT DO
  105.             IF ABS(TIMER - z1ia) > .3 THEN CALL alienmissile(iresults): z1ia = TIMER
  106.             key$ = INKEY$
  107.             IF key$ = "" THEN ex% = 2: CALL mdriver(ex%, key$, tankx%)
  108.             SELECT CASE key$
  109.                 CASE CHR$(0) + "K"
  110.                     IF POS(1) > lmargin% + 1 THEN COLOR icolor, ibk: LOCATE , POS(1) - 2: PRINT tank$ + " ";: LOCATE , POS(1) - 3
  111.                     tanky% = CSRLIN: tankx% = POS(1)
  112.                     IF SCREEN(tanky%, tankx% - 2) = 25 OR SCREEN(tanky%, tankx% + 2) = 25 THEN result = -1: EXIT DO
  113.                 CASE CHR$(0) + "M"
  114.                     IF POS(1) < screenwidth% THEN COLOR icolor, ibk: LOCATE , POS(1) - 1: PRINT " " + tank$;: LOCATE , POS(1) - 2
  115.                     tanky% = CSRLIN: tankx% = POS(1)
  116.                     IF SCREEN(tanky%, tankx% - 2) = 25 OR SCREEN(tanky%, tankx% + 2) = 25 THEN result = -1: EXIT DO
  117.                 CASE CHR$(32)
  118.                     IF icolor = 7 THEN
  119.                         FOR i2 = 1 TO 5
  120.                             IF bullet%(i2) = 0 THEN
  121.                                 icolor = 12: COLOR icolor, ibk: GOSUB redraw
  122.                                 bullet%(i2) = -1: reload = TIMER: EXIT FOR
  123.                             END IF
  124.                         NEXT
  125.                     END IF
  126.                 CASE CHR$(27): SYSTEM
  127.             END SELECT
  128.  
  129.             IF ABS(z1 - reload) > .7 AND reload <> 0 THEN
  130.                 GOSUB redraw
  131.                 icolor = 7: reload = 0
  132.             END IF
  133.  
  134.             REM Fire
  135.             FOR i = 1 TO 5
  136.                 SELECT CASE bullet%(i)
  137.                     CASE -1: bullet%(i) = tanky% - 1: bulletcol%(i) = tankx%
  138.                     CASE IS > 0
  139.                         IF bulletdelay%(i) = -1 OR bullet%(i) = tanky% - 1 THEN
  140.                             CALL checkcollision(ihitaliens, ialiencol, i4, i)
  141.                             z2bullet = TIMER: bulletdelay%(i) = 0
  142.                             COLOR 7, ibk
  143.                             LOCATE bullet%(i), bulletcol%(i)
  144.                             IF bullet%(i) = topmargin% AND imothership <> 0 THEN
  145.                                 IF SCREEN(ABS(bullet%(i)), bulletcol%(i)) <> 32 THEN
  146.                                     SOUND 1000, .75
  147.                                     LOCATE topmargin%, lmargin%: PRINT SPACE$(screenwidth%);
  148.                                     imothership = 0
  149.                                 END IF
  150.                             END IF
  151.                             PRINT CHR$(24)
  152.                             IF CSRLIN <> 24 THEN LOCATE , bulletcol%(i): PRINT " ";
  153.                             IF ihitaliens <> 0 THEN CALL reprintaliens(ialiencol, ihitaliens, iresults, i4, i, imothership)
  154.                             LOCATE tanky%, tankx%
  155.                             IF bullet%(i) > topmargin% THEN
  156.                                 bullet%(i) = bullet%(i) - 1
  157.                             ELSE
  158.                                 GOSUB erasebullet
  159.                             END IF
  160.                         END IF
  161.                 END SELECT
  162.             NEXT
  163.  
  164.             REM Bullet timer delay
  165.             IF z2bullet <> 0 THEN
  166.                 IF z1 < z2bullet THEN z2bullet = z2bullet - 86400
  167.                 IF z1 - z2bullet >= .06 THEN
  168.                     FOR i2 = 1 TO 5
  169.                         IF bullet%(i2) <> 0 THEN bulletdelay%(i2) = -1
  170.                     NEXT i2
  171.                 END IF
  172.                 EXIT DO
  173.             END IF
  174.         LOOP
  175.         IF iresults < 0 THEN EXIT DO
  176.         IF alienforce% = 0 OR iresults = iwin THEN
  177.             FOR i = 1 TO imaxalienmissiles
  178.                 IF ia(i) <> 0 THEN EXIT FOR
  179.             NEXT
  180.             IF i > imaxalienmissiles THEN iwait = -1
  181.             IF iwait = -1 THEN
  182.                 EXIT DO
  183.             END IF
  184.         ELSE
  185.             iwait = 1
  186.         END IF
  187.     LOOP
  188.     ex% = -1: CALL mdriver(ex%, key$, tankx%)
  189.     key$ = INKEY$
  190.     SLEEP 2
  191.     IF iresults = iwin OR iresults < 0 THEN
  192.         REM end game
  193.         EXIT DO
  194.     END IF
  195.     inextrnd = -1
  196. SELECT CASE iresults
  197.     CASE IS < 0
  198.         COLOR 7, ibk
  199.         LOCATE tanky% - 1, lmargin%
  200.         PRINT SPACE$(screenwidth%);
  201.         LOCATE tanky%, lmargin%
  202.         PRINT SPACE$(screenwidth%);
  203.         key$ = INKEY$
  204.         SOUND 140, 2
  205.         SLEEP 2
  206. CALL qbide
  207. CALL instructions
  208.  
  209. erasebullet:
  210. LOCATE ABS(bullet%(i)), bulletcol%(i): PRINT " ";
  211. bullet%(i) = 0: bulletcol%(i) = 0: bulletdelay%(i) = 0
  212. LOCATE tanky%, tankx%
  213.  
  214. redraw:
  215. COLOR , ibk: LOCATE tanky%, tankx% - 1: PRINT tank$;: LOCATE tanky%, tankx%: COLOR 7, ibk
  216.  
  217. DATA "Well, I better get busy and finish the compiler..."
  218. DATA "Or... I'll just do some more work on this IDE, instead..."
  219. DATA ""
  220. DATA " Loading..."
  221. DATA "EOF"
  222. DATA "Game Over. Thanks for playing..."
  223. DATA ""
  224. DATA "Now finish the compiler!"
  225. DATA "EOF2"
  226.  
  227. SUB alienattack (ialiencolstat, ialiencol)
  228. z2alienfire = TIMER
  229.  
  230. i3 = INT(RND * 10)
  231. FOR i = 1 TO imaxalienmissiles
  232.     IF ia(i) = 0 THEN
  233.         FOR i2 = imaxalienforce TO 1 STEP -1
  234.             IF RTRIM$(a(i2)) <> "" THEN
  235.                 IF MID$(matrix(i2), i3 + 1, 1) <> "0" THEN
  236.                     i4 = INSTR(i3 * 7 + 1, a(i2), CHR$(237)) + ialiencol
  237.                     EXIT FOR
  238.                 END IF
  239.             END IF
  240.         NEXT i2
  241.         IF i4 <> 0 THEN
  242.             ia(i) = (ileadingmax - (imaxalienforce - i2) * 2) * 80 + i4
  243.             EXIT FOR
  244.         END IF
  245.     END IF
  246.  
  247.  
  248. SUB alienmissile (iresults)
  249. irow = CSRLIN: icol = POS(1)
  250. FOR i = 1 TO imaxalienmissiles
  251.     IF ia(i) <> 0 THEN
  252.         IF iy(i) = 0 THEN
  253.             iy(i) = ia(i) \ 80: ix(i) = ia(i) MOD 80
  254.             IF ix(i) = 0 THEN ix(i) = screenwidth%
  255.         END IF
  256.         LOCATE iy(i) + 1, ix(i)
  257.         COLOR 7, ibk
  258.         IF CSRLIN <= 24 THEN
  259.             IF CSRLIN = 24 THEN IF SCREEN(CSRLIN, ix(i)) <> 32 THEN iresults = -1
  260.             PRINT CHR$(25);
  261.         ELSE
  262.             ia(i) = 0
  263.             LOCATE iy(i), ix(i)
  264.             PRINT " ";: iy(i) = 0
  265.             ia(i) = 0
  266.             LOCATE irow, icol
  267.             EXIT SUB
  268.         END IF
  269.         LOCATE iy(i), ix(i): PRINT " ";
  270.         iy(i) = iy(i) + 1
  271.     END IF
  272. LOCATE irow, icol
  273.  
  274.  
  275. SUB checkcollision (ihitaliens, ialiencol, i4, i)
  276. ihitaliens = 0
  277. IF ileadingmax MOD 2 = bullet%(i) MOD 2 THEN
  278.     i4 = imaxalienforce - (ileadingmax - bullet%(i)) \ 2
  279.     IF bullet%(i) <= ileadingrow AND i4 > 0 AND i4 <= imaxalienforce THEN
  280.         IF RTRIM$(a(i4)) <> "" THEN
  281.             IF bulletcol%(i) >= iltalien(i4) AND bulletcol%(i) - ialiencol <= LEN(RTRIM$(a(i4))) THEN
  282.                 IF MID$(a(i4), bulletcol%(i) - ialiencol, 1) > CHR$(32) THEN
  283.                     ihitaliens = bulletcol%(i) - ialiencol + 1
  284.                     i3 = ihitaliens - 7 + 1: IF i3 < 1 THEN i3 = 1: REM count from the "<" symbol.
  285.                     i2 = INSTR(i3 + 1, a(i4), "<") - 1
  286.                     MID$(a(i4), i2, 7) = SPACE$(7)
  287.                     MID$(matrix(i4), (i2 + 1) \ 7 + 1, 1) = "0"
  288.                 END IF
  289.             END IF
  290.         END IF
  291.     END IF
  292.  
  293. FOR i2 = 1 TO imaxalienmissiles
  294.     IF ia(i2) <> 0 THEN
  295.         IF iy(i2) >= bullet%(i) AND ix(i2) = bulletcol%(i) THEN
  296.             ihitaliens = -i2
  297.             EXIT FOR
  298.         END IF
  299.     END IF
  300.  
  301.  
  302. SUB instructions
  303.  
  304. ''in$ = "EOF"
  305. IF in$ = "" THEN
  306.     key$ = INKEY$
  307.     LOCATE 3, 3, 1, 7, 7: COLOR 7, ibk
  308.     SLEEP 2
  309.     DO
  310.         READ in$
  311.         IF MID$(in$, 1, 3) = "EOF" THEN EXIT DO
  312.         FOR i = 1 TO LEN(in$)
  313.             SOUND 400, .1
  314.             LOCATE , 2 + i
  315.             PRINT MID$(in$, i, 1);
  316.             z = TIMER
  317.             DO
  318.                 IF ABS(z - TIMER) > .1 THEN EXIT DO
  319.             LOOP
  320.         NEXT
  321.         LOCATE , , 0, 7, 0
  322.         key$ = INKEY$
  323.         SLEEP 1
  324.         PRINT
  325.         LOCATE , 3
  326.     LOOP
  327.     key$ = INKEY$
  328.     SLEEP 1
  329.  
  330. IF in$ = "EOF" THEN
  331.     COLOR 7, 1
  332.     FOR i = 1 TO 5
  333.         LOCATE 2 + i, 2: PRINT SPACE$(78)
  334.     NEXT
  335.     FOR i = 3 TO 24
  336.         LOCATE i, 80: PRINT CHR$(179);
  337.     NEXT
  338.     LOCATE 21, 2: PRINT STRING$(78, " ");
  339.     LOCATE 22, 1: PRINT CHR$(179);
  340.     LOCATE 22, 80: PRINT CHR$(179);
  341.     LOCATE 22, 2: PRINT STRING$(78, " ");
  342.     COLOR 0, 3
  343.  
  344. COLOR 0, 3
  345. yy% = CSRLIN: xx% = POS(1)
  346. LOCATE 25, 76 - LEN(LTRIM$(STR$(ihits)))
  347. PRINT LTRIM$(STR$(ihits));
  348. LOCATE 25, 80 - LEN(LTRIM$(STR$(imaxalienforce - alienforce%)))
  349. PRINT "0";
  350. LOCATE yy%, xx%
  351.  
  352. PCOPY 0, 3: REM save skin
  353.  
  354.  
  355. SUB marchdown (ialiencol, ialiencolstat, imotion, iresults)
  356. COLOR 7, ibk
  357. ileadingrow = ileadingrow + 1
  358. ileadingmax = ileadingmax + 1
  359. COLOR 7, ibk
  360. FOR i = 1 TO imaxalienforce
  361.     IF RTRIM$(a(i)) <> "" THEN
  362.         ialiencol = ialiencolstat + imotion
  363.         LOCATE ileadingmax - (imaxalienforce * 2) + i * 2 - 1, lmargin%
  364.         PRINT STRING$(screenwidth%, " ")
  365.         LOCATE , ialiencol + INSTR(a(i), "-")
  366.         iltalien(i) = POS(1)
  367.         PRINT LTRIM$(RTRIM$(a(i)))
  368.     END IF
  369. LOCATE irow, icol
  370. level = level - .025
  371. IF ileadingrow = 22 THEN iresults = -2
  372.  
  373. SUB mdriver (ex%, key$, tankx%)
  374. STATIC MOUSEACT%
  375.  
  376. REM INITIATE MOUSE
  377. IF MOUSEACT% = 0 OR ex% = -1 THEN
  378.     Registers.AX = 0: GOSUB CALLI
  379.     MOUSEACT% = 1
  380.  
  381. IF ex% = 1 THEN
  382.     Registers.AX = 4: Registers.DX = 184: Registers.CX = 304
  383.     Registers.AX = 8: Registers.DX = 184: Registers.CX = 184
  384.     GOSUB CALLI
  385.     EXIT SUB
  386.  
  387. Registers.AX = 3: GOSUB CALLI
  388.  
  389. DX = Registers.DX
  390. CX = Registers.CX
  391. y% = DX \ 8 + 1: x% = CX \ 8 + 1
  392.  
  393. REM MOUSE BUTTONS
  394. LB% = Registers.BX AND 1
  395. RB% = (Registers.BX AND 2) \ 2
  396. MB% = (Registers.BX AND 4) \ 4
  397.  
  398. IF LB% <> 0 THEN
  399.     key$ = CHR$(32)
  400.     IF x% > tankx% THEN key$ = CHR$(0) + "M"
  401.     IF x% < tankx% THEN key$ = CHR$(0) + "K"
  402.  
  403. CALLI:
  404. CALL INTERRUPT(&H33, Registers, Registers)
  405.  
  406.  
  407. SUB movealiens (ialiencol, ialiencolstat, iresults)
  408. STATIC imotion, imarch, imotiondir
  409. IF inextrnd = -1 THEN inextrnd = 0: imotion = 0: imarch = 0: imotiondir = 0
  410. irow = CSRLIN: icol = POS(1)
  411. yy% = CSRLIN: xx% = POS(1)
  412. PCOPY 0, 1: SCREEN 0, 0, 1, 0: LOCATE yy%, xx%, 0, 7, 0
  413. IF imotiondir = 0 THEN imotion = imotion - 1 ELSE imotion = imotion + 1
  414. COLOR 7, ibk
  415.  
  416. FOR i = imaxalienforce TO 1 STEP -1
  417.     IF RTRIM$(a(i)) <> "" THEN
  418.         i2 = i2 + 2
  419.         SOUND 400, .03
  420.         ialiencol = ialiencolstat + imotion
  421.         LOCATE ileadingmax - (imaxalienforce - i) * 2, ialiencol + INSTR(a(i), "-")
  422.         IF POS(1) = lmargin% THEN imarch = 1
  423.         iltalien(i) = POS(1)
  424.         IF imotiondir = 0 THEN
  425.             PRINT LTRIM$(RTRIM$(a(i))); " "
  426.         ELSE
  427.             LOCATE , POS(1) - 1
  428.             PRINT " "; LTRIM$(RTRIM$(a(i)))
  429.         END IF
  430.         IF ialiencol + LEN(RTRIM$(a(i))) = screenwidth% THEN imarch = -1
  431.     END IF
  432.  
  433. IF imarch = 1 THEN imotiondir = 1: CALL marchdown(ialiencol, ialiencolstat, imotion, iresults)
  434. IF imarch = -1 THEN imotiondir = 0: CALL marchdown(ialiencol, ialiencolstat, imotion, iresults)
  435. IF imarch = 0 THEN
  436.     IF ABS(TIMER - z2alienfire) > firerate THEN
  437.         firerate = (INT(RND * 10) + 1) / 20
  438.         IF iwait = 0 THEN CALL alienattack(ialiencolstat, ialiencol)
  439.     END IF
  440.     imarch = 0
  441. PCOPY 1, 0: SCREEN 0, 0, 0, 0
  442. LOCATE irow, icol, 1, 7, 7
  443.  
  444. SUB mship (imothership)
  445. STATIC x%, mov%, z4, mothership$
  446.  
  447. yy% = CSRLIN: xx% = POS(1): COLOR 7, ibk
  448. IF imothership = -1 THEN
  449.     imothership = 1
  450.     x% = lmargin%
  451.     mothership$ = CHR$(254) + CHR$(254) + "O" + CHR$(254) + CHR$(254)
  452.     mov% = 1
  453.  
  454. IF ABS(TIMER - z4) > .05 THEN GOSUB mothership: z4 = TIMER: LOCATE yy%, xx%: EXIT SUB
  455. ''IF ABS(TIMER - z2) > .2 THEN GOSUB bullets: z2 = TIMER
  456. LOCATE yy%, xx%
  457.  
  458. mothership:
  459. IF x% + LEN(mothership$) = screenwidth% + lmargin% THEN mov% = -1 ELSE IF x% = lmargin% THEN mov% = 1
  460. x% = x% + mov%
  461. LOCATE topmargin%, x%
  462. PRINT mothership$;
  463. IF x% > 1 AND mov% = 1 THEN
  464.     LOCATE , POS(1) - LEN(mothership$) - 1: PRINT " ";
  465. IF mov% = -1 THEN PRINT " ";
  466.  
  467.  
  468. DEFINT A-H, J-Z
  469. SUB qbide
  470. PALETTE 2, 59
  471. COLOR 15, 1
  472.  
  473. COLOR 0, 7
  474. LOCATE 1, 1
  475. LOCATE 1, 1: PRINT "   File  Edit  View  Search  Run  Debug  Calls  Options                   Help"
  476.  
  477. COLOR 7, 1
  478.  
  479. LOCATE 2, 1: PRINT CHR$(218)
  480. LOCATE 2, 2: PRINT STRING$(78, CHR$(196))
  481. LOCATE 2, 80: PRINT CHR$(191)
  482.  
  483. LOCATE 2, 76: PRINT CHR$(180)
  484. LOCATE 2, 78: PRINT CHR$(195)
  485.  
  486. COLOR 1, 7
  487. LOCATE 2, 77: PRINT CHR$(24)
  488. LOCATE 2, 36: PRINT " Untitled "
  489.  
  490. COLOR 7, 1
  491. FOR Rows = 3 TO 24
  492.     LOCATE Rows, 1: PRINT CHR$(179);
  493.     LOCATE Rows, 80: PRINT CHR$(179);
  494. NEXT Rows
  495.  
  496. LOCATE 22, 1: PRINT CHR$(195)
  497. LOCATE 22, 80: PRINT CHR$(180)
  498. LOCATE 22, 2: PRINT STRING$(78, CHR$(196))
  499. LOCATE 22, 35
  500. PRINT " Immediate "
  501.  
  502. COLOR 0, 7
  503. LOCATE 21, 3: PRINT STRING$(76, CHR$(176))
  504. LOCATE 21, 2: PRINT CHR$(27)
  505. LOCATE 21, 3: PRINT CHR$(219)
  506. LOCATE 21, 79: PRINT CHR$(26)
  507. FOR Rows = 4 TO 19
  508.     LOCATE Rows, 80: PRINT CHR$(176)
  509. NEXT Rows
  510. LOCATE 3, 80: PRINT CHR$(24)
  511. LOCATE 4, 80: PRINT CHR$(219)
  512. LOCATE 20, 80: PRINT CHR$(25)
  513.  
  514. COLOR 0, 3: LOCATE 25, 1: PRINT " <Shift+F1=Help> <F6=Window> <F2=Subs> <F5=Run> <F8=Step> ";
  515. LOCATE 25, 59: PRINT SPACE$(4);
  516. COLOR 0, 3
  517. LOCATE 25, 63: PRINT CHR$(179);
  518. LOCATE 25, 64: PRINT SPACE$(6);
  519. LOCATE 25, 68: PRINT "C  00001:001 ";
  520.  
  521.  
  522. DEFSNG A-H, J-Z
  523. SUB reprintaliens (ialiencol, ihitaliens, iresults, i4, i, imothership)
  524. IF ihitaliens > 0 THEN
  525.     ihits = ihits + 1
  526.     IF (ihits + 15) MOD 20 = 0 AND imothership = 0 THEN imothership = -1
  527.     LOCATE bullet%(i), lmargin%: PRINT SPACE$(screenwidth%);
  528.     iltalien(i4) = POS(1)
  529.  
  530.     IF RTRIM$(a(i4)) = "" THEN
  531.         alienforce% = alienforce% - 1
  532.         IF alienforce% = 0 THEN iresults = iresults + 1
  533.         IF bullet%(i) = ileadingrow THEN ileadingrow = ileadingrow - 2
  534.     ELSE
  535.         LOCATE bullet%(i), ialiencol + INSTR(a(i4), "-"): PRINT LTRIM$(RTRIM$(a(i4)))
  536.     END IF
  537.     i2 = ABS(ihitaliens)
  538.     LOCATE iy(i2), ix(i2)
  539.     PRINT " ";: iy(i2) = 0
  540.     ia(i2) = 0
  541.     LOCATE irow, icol
  542.     SOUND 1000, .5
  543.  
  544. ihitaliens = 0
  545. bullet%(i) = -bullet%(i)
  546.  
  547. COLOR 0, 3
  548. yy% = CSRLIN: xx% = POS(1)
  549. LOCATE 25, 76 - LEN(LTRIM$(STR$(ihits)))
  550. PRINT LTRIM$(STR$(ihits));
  551. LOCATE 25, 80 - LEN(LTRIM$(STR$(imaxalienforce - alienforce%)))
  552. PRINT LTRIM$(STR$(imaxalienforce - alienforce%));
  553. LOCATE yy%, xx%
  554. COLOR 7, ibk
  555.  

Edit: Hey, I found the mother ship version! Mouse to move, left click to shoot.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Shooter Start
« Reply #3 on: March 31, 2019, 10:51:35 am »
I don't know about you guys but I get tired of pounding buttons.

Here is a mouse action double barreled shooter:
Code: QB64: [Select]
  1. _TITLE "Mouse Action Shooter Left Button for CCW rotation, Right Button for CW roatation" 'B+ 2019-03-31
  2. 'from eRATication 5 by bplus 2018-08-06"
  3.  
  4. 'screen dimensions
  5. CONST ww = 1200
  6. CONST wh = 700
  7. CONST nBullets = 1000
  8. CONST bSpeed = 60
  9. CONST shooterRadius = 50
  10.  
  11. TYPE shooterType
  12.     x AS SINGLE
  13.     y AS SINGLE
  14.     a AS SINGLE
  15.  
  16. TYPE bulletType
  17.     x AS INTEGER
  18.     y AS INTEGER
  19.     dx AS INTEGER
  20.     dy AS INTEGER
  21.     live AS INTEGER
  22.  
  23. SCREEN _NEWIMAGE(ww, wh, 32)
  24. _SCREENMOVE 100, 20
  25.  
  26.  
  27. DIM SHARED GameOn, newRound, fire
  28.  
  29. DIM SHARED b(nBullets) AS bulletType
  30. DIM SHARED shooter AS shooterType
  31. shooter.x = ww / 2
  32. shooter.y = wh / 2
  33. shooter.a = 0
  34. lastx = ww / 2: lasty = wh / 2
  35. GameOn = 1
  36. WHILE GameOn
  37.     CLS
  38.  
  39.     shooter.x = _MOUSEX: shooter.y = _MOUSEY
  40.     IF ABS(lastx - shooter.x) > 3 AND ABS(lasty - shooter.y) > 3 THEN
  41.         shooter.a = _ATAN2(shooter.y - lasty, shooter.x - lastx)
  42.         lastx = shooter.x: lasty = shooter.y
  43.     END IF
  44.     IF _MOUSEBUTTON(1) THEN shooter.a = (shooter.a - _PI(1 / 72))
  45.     IF _MOUSEBUTTON(2) THEN shooter.a = (shooter.a + _PI(1 / 72))
  46.  
  47.     'lc loop count mod, controls how fast bullets come
  48.     lc = (lc + 1) MOD 4
  49.     IF lc = 0 THEN fire = 2 ELSE fire = 0
  50.     drawshooter
  51.     handleBullets
  52.     _DISPLAY
  53.     _LIMIT 30
  54.  
  55. SUB handleBullets ()
  56.     FOR i = 0 TO nBullets
  57.         IF b(i).live = 0 AND fire = 1 THEN 'have in active bullet index to use
  58.             b(i).x = shooter.x + (shooterRadius) * COS(shooter.a + _PI(7 / 8))
  59.             b(i).y = shooter.y + (shooterRadius) * SIN(shooter.a + _PI(7 / 8))
  60.             b(i).dx = bSpeed * COS(shooter.a)
  61.             b(i).dy = bSpeed * SIN(shooter.a)
  62.             b(i).live = 1
  63.             fire = 0
  64.         ELSEIF b(i).live = 0 AND fire = 2 THEN
  65.             b(i).x = shooter.x + (shooterRadius) * COS(shooter.a - _PI(7 / 8))
  66.             b(i).y = shooter.y + (shooterRadius) * SIN(shooter.a - _PI(7 / 8))
  67.             b(i).dx = bSpeed * COS(shooter.a)
  68.             b(i).dy = bSpeed * SIN(shooter.a)
  69.             b(i).live = 1
  70.             fire = 1
  71.         END IF
  72.         IF b(i).live = 1 THEN 'new location
  73.             b(i).x = b(i).x + b(i).dx
  74.             b(i).y = b(i).y + b(i).dy
  75.             IF b(i).x > 0 AND b(i).x < ww AND b(i).y > 0 AND b(i).y < wh THEN 'in bounds draw it
  76.                 'check for collision with ...
  77.                 'else draw bullet
  78.                 ba = _ATAN2(b(i).dy, b(i).dx): b = 15
  79.                 x1 = b(i).x + b * COS(ba)
  80.                 y1 = b(i).y + b * SIN(ba)
  81.                 x2 = b(i).x + b * COS(ba + _PI(5 / 6))
  82.                 y2 = b(i).y + b * SIN(ba + _PI(5 / 6))
  83.                 x3 = b(i).x + b * COS(ba + _PI(7 / 6))
  84.                 y3 = b(i).y + b * SIN(ba + _PI(7 / 6))
  85.                 fTri x1, y1, x2, y2, x3, y3, _RGB32(0, 0, 160)
  86.                 'fcirc b(i).x, b(i).y, 4, _RGB32(64, 0, 0)
  87.             ELSE
  88.                 b(i).live = 0
  89.             END IF
  90.         END IF
  91.     NEXT
  92.  
  93. SUB drawshooter ()
  94.     'just a wedge
  95.     x1 = shooter.x + shooterRadius * COS(shooter.a)
  96.     y1 = shooter.y + shooterRadius * SIN(shooter.a)
  97.     x2 = shooter.x + shooterRadius * COS(shooter.a + _PI(7 / 8))
  98.     y2 = shooter.y + shooterRadius * SIN(shooter.a + _PI(7 / 8))
  99.     x3 = shooter.x + shooterRadius * COS(shooter.a - _PI(7 / 8))
  100.     y3 = shooter.y + shooterRadius * SIN(shooter.a - _PI(7 / 8))
  101.     fTri x1, y1, x2, y2, x3, y3, _RGB32(155, 55, 0)
  102.     x2 = shooter.x + shooterRadius * COS(shooter.a + _PI(15 / 16))
  103.     y2 = shooter.y + shooterRadius * SIN(shooter.a + _PI(15 / 16))
  104.     x3 = shooter.x + shooterRadius * COS(shooter.a - _PI(15 / 16))
  105.     y3 = shooter.y + shooterRadius * SIN(shooter.a - _PI(15 / 16))
  106.     fTri x1, y1, x2, y2, x3, y3, _RGB32(255, 255, 255)
  107.  
  108. ' found at [abandoned, outdated and now likely malicious qb64 dot net website - don’t go there]:    http://www.[abandoned, outdated and now likely malicious qb64 dot net website - don’t go there]/forum/index.php?topic=14425.0
  109. SUB fTri (x1, y1, x2, y2, x3, y3, K AS _UNSIGNED LONG)
  110.     a& = _NEWIMAGE(1, 1, 32)
  111.     _DEST a&
  112.     PSET (0, 0), K
  113.     _DEST 0
  114.     _MAPTRIANGLE _SEAMLESS(0, 0)-(0, 0)-(0, 0), a& TO(x1, y1)-(x2, y2)-(x3, y3)
  115.     _FREEIMAGE a& '<<< this is important!
  116.  
« Last Edit: March 31, 2019, 10:55:18 am by bplus »

FellippeHeitor

  • Guest
Re: Shooter Start
« Reply #4 on: March 31, 2019, 11:21:58 am »
Oh, you mean like this?

Code: QB64: [Select]
  1. DECLARE SUB instructions ()
  2. DECLARE SUB qbide ()
  3. DECLARE SUB mship (imothership)
  4. REM Adds multiple bullets (5) max.
  5. REM Adds firing delay and ship turns red while reloading.
  6. REM Adds aliens.
  7. REM Adds collision for bullets from base to aliens.
  8. REM Adds Mouse support.
  9. REM Adds alien motion.
  10. REM Adds 3 progressive levels.
  11. REM Adds aliens move all the way to both sides.
  12. REM Adds Aliens shoot back.
  13. REM Adds sub-routines.
  14. REM Adds counter.
  15. REM Adds alien bullets finish before moving on to next level.
  16. REM Adds mothership.
  17.  
  18. DECLARE SUB alienattack (ialiencolstat, ialiencol)
  19. DECLARE SUB alienmissile (iresults)
  20. DECLARE SUB checkcollision (ihitaliens, ialiencol, i4, i)
  21. DECLARE SUB mdriver (ex%, key$, tankx%)
  22. DECLARE SUB marchdown (ialiencol, ialiencolstat, imotion, iresults)
  23. DECLARE SUB movealiens (ialiencol, ialiencolstat, iresults)
  24. DECLARE SUB reprintaliens (ialiencol, ihitaliens, iresults, i4, i, imothership)
  25.  
  26. TYPE RegType
  27.     AX AS INTEGER
  28.     BX AS INTEGER
  29.     CX AS INTEGER
  30.     DX AS INTEGER
  31.     BP AS INTEGER
  32.     SI AS INTEGER
  33.     DI AS INTEGER
  34.     FLAGS AS INTEGER
  35.     DS AS INTEGER
  36.     ES AS INTEGER
  37.  
  38. DIM SHARED MOUSE$
  39. DIM SHARED Registers AS RegType
  40. DIM SHARED LB%, RB%, MB%, DX, CX
  41. DIM SHARED lmargin%, rmargin%, topmargin%, screenwidth%, level, ibk, ileadingrow
  42. DIM SHARED irow, icol, inextrnd, imaxalienmissiles, alienforce%, ileadingmax, imaxalienforce, ihits
  43.  
  44. imaxalienforce = 6
  45. imaxalienmissiles = 3
  46. lmargin% = 2
  47. rmargin% = 79
  48. topmargin% = 3
  49. ialiencolstat = 6
  50. iwin = 3
  51. screenwidth% = rmargin% - lmargin% + 1
  52. ibk = 1
  53.  
  54. DIM SHARED a(imaxalienforce) AS STRING * 68
  55.  
  56. SCREEN 0, 0, 0, 0
  57. COLOR 7, 1: CLS
  58.  
  59. REM Make aliens
  60. a1$ = "-<" + CHR$(237) + ">-  "
  61. a$ = a1$ + a1$ + a1$ + a1$ + a1$ + a1$ + a1$ + a1$ + a1$ + a1$
  62.  
  63. CALL qbide
  64. CALL instructions
  65.  
  66.     IF inextrnd = -1 THEN PCOPY 3, 0
  67.     tank$ = CHR$(218) + CHR$(127) + CHR$(191): icolor = 7
  68.     REDIM SHARED bullet%(5), bulletcol%(5), bulletdelay%(5), iltalien(imaxalienforce)
  69.     REDIM SHARED ia(imaxalienmissiles), iy(imaxalienmissiles), ix(imaxalienmissiles)
  70.     REDIM SHARED matrix(imaxalienforce) AS STRING * 10
  71.     alienforce% = imaxalienforce
  72.     level = .65
  73.     iround = iround + 1
  74.     level = level - iround / 15
  75.     inextrnd = -1
  76.     COLOR 7, ibk
  77.  
  78.     REM Set up aliens
  79.     ialiencol = ialiencolstat
  80.     LOCATE 2, ialiencol
  81.     FOR i = 1 TO imaxalienforce
  82.         IF i MOD 1 = 0 THEN PRINT
  83.         LOCATE , ialiencol
  84.         IF i = imaxalienforce THEN ileadingrow = CSRLIN: ileadingmax = ileadingrow
  85.         a(i) = a$
  86.         PRINT a(i)
  87.     NEXT
  88.  
  89.     REM Station
  90.     LOCATE 24, 40, 1, 7, 7
  91.     PRINT tank$;: LOCATE , POS(1) - 2: tanky% = CSRLIN: tankx% = POS(1) + 1
  92.     key$ = INKEY$: SLEEP 1
  93.     ex% = 1: CALL mdriver(ex%, key$, tankx%)
  94.     DO
  95.         z1 = TIMER
  96.         DO
  97.             IF topmargin% + ileadingmax - (imaxalienforce * 2) >= topmargin% + 2 THEN
  98.                 IF imothership <> 0 THEN CALL mship(imothership)
  99.             END IF
  100.             IF ABS(TIMER - z1aliens) > level THEN
  101.                 CALL movealiens(ialiencol, ialiencolstat, iresults)
  102.                 z1aliens = TIMER
  103.             END IF
  104.             IF iresults < 0 THEN EXIT DO
  105.             IF ABS(TIMER - z1ia) > .3 THEN CALL alienmissile(iresults): z1ia = TIMER
  106.             key$ = INKEY$
  107.             IF key$ = "" THEN ex% = 2: CALL mdriver(ex%, key$, tankx%)
  108.             SELECT CASE key$
  109.                 CASE CHR$(0) + "K"
  110.                     IF POS(1) > lmargin% + 1 THEN COLOR icolor, ibk: LOCATE , POS(1) - 2: PRINT tank$ + " ";: LOCATE , POS(1) - 3
  111.                     tanky% = CSRLIN: tankx% = POS(1)
  112.                     IF SCREEN(tanky%, tankx% - 2) = 25 OR SCREEN(tanky%, tankx% + 2) = 25 THEN result = -1: EXIT DO
  113.                 CASE CHR$(0) + "M"
  114.                     IF POS(1) < screenwidth% THEN COLOR icolor, ibk: LOCATE , POS(1) - 1: PRINT " " + tank$;: LOCATE , POS(1) - 2
  115.                     tanky% = CSRLIN: tankx% = POS(1)
  116.                     IF SCREEN(tanky%, tankx% - 2) = 25 OR SCREEN(tanky%, tankx% + 2) = 25 THEN result = -1: EXIT DO
  117.                 CASE CHR$(32)
  118.                     IF icolor = 7 THEN
  119.                         FOR i2 = 1 TO 5
  120.                             IF bullet%(i2) = 0 THEN
  121.                                 icolor = 12: COLOR icolor, ibk: GOSUB redraw
  122.                                 bullet%(i2) = -1: reload = TIMER: EXIT FOR
  123.                             END IF
  124.                         NEXT
  125.                     END IF
  126.                 CASE CHR$(27): SYSTEM
  127.             END SELECT
  128.  
  129.             IF ABS(z1 - reload) > .7 AND reload <> 0 THEN
  130.                 GOSUB redraw
  131.                 icolor = 7: reload = 0
  132.             END IF
  133.  
  134.             REM Fire
  135.             FOR i = 1 TO 5
  136.                 SELECT CASE bullet%(i)
  137.                     CASE -1: bullet%(i) = tanky% - 1: bulletcol%(i) = tankx%
  138.                     CASE IS > 0
  139.                         IF bulletdelay%(i) = -1 OR bullet%(i) = tanky% - 1 THEN
  140.                             CALL checkcollision(ihitaliens, ialiencol, i4, i)
  141.                             z2bullet = TIMER: bulletdelay%(i) = 0
  142.                             COLOR 7, ibk
  143.                             LOCATE bullet%(i), bulletcol%(i)
  144.                             IF bullet%(i) = topmargin% AND imothership <> 0 THEN
  145.                                 IF SCREEN(ABS(bullet%(i)), bulletcol%(i)) <> 32 THEN
  146.                                     SOUND 1000, .75
  147.                                     LOCATE topmargin%, lmargin%: PRINT SPACE$(screenwidth%);
  148.                                     imothership = 0
  149.                                 END IF
  150.                             END IF
  151.                             PRINT CHR$(24)
  152.                             IF CSRLIN <> 24 THEN LOCATE , bulletcol%(i): PRINT " ";
  153.                             IF ihitaliens <> 0 THEN CALL reprintaliens(ialiencol, ihitaliens, iresults, i4, i, imothership)
  154.                             LOCATE tanky%, tankx%
  155.                             IF bullet%(i) > topmargin% THEN
  156.                                 bullet%(i) = bullet%(i) - 1
  157.                             ELSE
  158.                                 GOSUB erasebullet
  159.                             END IF
  160.                         END IF
  161.                 END SELECT
  162.             NEXT
  163.  
  164.             REM Bullet timer delay
  165.             IF z2bullet <> 0 THEN
  166.                 IF z1 < z2bullet THEN z2bullet = z2bullet - 86400
  167.                 IF z1 - z2bullet >= .06 THEN
  168.                     FOR i2 = 1 TO 5
  169.                         IF bullet%(i2) <> 0 THEN bulletdelay%(i2) = -1
  170.                     NEXT i2
  171.                 END IF
  172.                 EXIT DO
  173.             END IF
  174.         LOOP
  175.         IF iresults < 0 THEN EXIT DO
  176.         IF alienforce% = 0 OR iresults = iwin THEN
  177.             FOR i = 1 TO imaxalienmissiles
  178.                 IF ia(i) <> 0 THEN EXIT FOR
  179.             NEXT
  180.             IF i > imaxalienmissiles THEN iwait = -1
  181.             IF iwait = -1 THEN
  182.                 EXIT DO
  183.             END IF
  184.         ELSE
  185.             iwait = 1
  186.         END IF
  187.     LOOP
  188.     ex% = -1: CALL mdriver(ex%, key$, tankx%)
  189.     key$ = INKEY$
  190.     SLEEP 2
  191.     IF iresults = iwin OR iresults < 0 THEN
  192.         REM end game
  193.         EXIT DO
  194.     END IF
  195.     inextrnd = -1
  196. SELECT CASE iresults
  197.     CASE IS < 0
  198.         COLOR 7, ibk
  199.         LOCATE tanky% - 1, lmargin%
  200.         PRINT SPACE$(screenwidth%);
  201.         LOCATE tanky%, lmargin%
  202.         PRINT SPACE$(screenwidth%);
  203.         key$ = INKEY$
  204.         SOUND 140, 2
  205.         SLEEP 2
  206. CALL qbide
  207. CALL instructions
  208.  
  209. erasebullet:
  210. LOCATE ABS(bullet%(i)), bulletcol%(i): PRINT " ";
  211. bullet%(i) = 0: bulletcol%(i) = 0: bulletdelay%(i) = 0
  212. LOCATE tanky%, tankx%
  213.  
  214. redraw:
  215. COLOR , ibk: LOCATE tanky%, tankx% - 1: PRINT tank$;: LOCATE tanky%, tankx%: COLOR 7, ibk
  216.  
  217. DATA "Well, I better get busy and finish the compiler..."
  218. DATA "Or... I'll just do some more work on this IDE, instead..."
  219. DATA ""
  220. DATA " Loading..."
  221. DATA "EOF"
  222. DATA "Game Over. Thanks for playing..."
  223. DATA ""
  224. DATA "Now finish the compiler!"
  225. DATA "EOF2"
  226.  
  227. SUB alienattack (ialiencolstat, ialiencol)
  228. z2alienfire = TIMER
  229.  
  230. i3 = INT(RND * 10)
  231. FOR i = 1 TO imaxalienmissiles
  232.     IF ia(i) = 0 THEN
  233.         FOR i2 = imaxalienforce TO 1 STEP -1
  234.             IF RTRIM$(a(i2)) <> "" THEN
  235.                 IF MID$(matrix(i2), i3 + 1, 1) <> "0" THEN
  236.                     i4 = INSTR(i3 * 7 + 1, a(i2), CHR$(237)) + ialiencol
  237.                     EXIT FOR
  238.                 END IF
  239.             END IF
  240.         NEXT i2
  241.         IF i4 <> 0 THEN
  242.             ia(i) = (ileadingmax - (imaxalienforce - i2) * 2) * 80 + i4
  243.             EXIT FOR
  244.         END IF
  245.     END IF
  246.  
  247.  
  248. SUB alienmissile (iresults)
  249. irow = CSRLIN: icol = POS(1)
  250. FOR i = 1 TO imaxalienmissiles
  251.     IF ia(i) <> 0 THEN
  252.         IF iy(i) = 0 THEN
  253.             iy(i) = ia(i) \ 80: ix(i) = ia(i) MOD 80
  254.             IF ix(i) = 0 THEN ix(i) = screenwidth%
  255.         END IF
  256.         LOCATE iy(i) + 1, ix(i)
  257.         COLOR 7, ibk
  258.         IF CSRLIN <= 24 THEN
  259.             IF CSRLIN = 24 THEN IF SCREEN(CSRLIN, ix(i)) <> 32 THEN iresults = -1
  260.             PRINT CHR$(25);
  261.         ELSE
  262.             ia(i) = 0
  263.             LOCATE iy(i), ix(i)
  264.             PRINT " ";: iy(i) = 0
  265.             ia(i) = 0
  266.             LOCATE irow, icol
  267.             EXIT SUB
  268.         END IF
  269.         LOCATE iy(i), ix(i): PRINT " ";
  270.         iy(i) = iy(i) + 1
  271.     END IF
  272. LOCATE irow, icol
  273.  
  274.  
  275. SUB checkcollision (ihitaliens, ialiencol, i4, i)
  276. ihitaliens = 0
  277. IF ileadingmax MOD 2 = bullet%(i) MOD 2 THEN
  278.     i4 = imaxalienforce - (ileadingmax - bullet%(i)) \ 2
  279.     IF bullet%(i) <= ileadingrow AND i4 > 0 AND i4 <= imaxalienforce THEN
  280.         IF RTRIM$(a(i4)) <> "" THEN
  281.             IF bulletcol%(i) >= iltalien(i4) AND bulletcol%(i) - ialiencol <= LEN(RTRIM$(a(i4))) THEN
  282.                 IF MID$(a(i4), bulletcol%(i) - ialiencol, 1) > CHR$(32) THEN
  283.                     ihitaliens = bulletcol%(i) - ialiencol + 1
  284.                     i3 = ihitaliens - 7 + 1: IF i3 < 1 THEN i3 = 1: REM count from the "<" symbol.
  285.                     i2 = INSTR(i3 + 1, a(i4), "<") - 1
  286.                     MID$(a(i4), i2, 7) = SPACE$(7)
  287.                     MID$(matrix(i4), (i2 + 1) \ 7 + 1, 1) = "0"
  288.                 END IF
  289.             END IF
  290.         END IF
  291.     END IF
  292.  
  293. FOR i2 = 1 TO imaxalienmissiles
  294.     IF ia(i2) <> 0 THEN
  295.         IF iy(i2) >= bullet%(i) AND ix(i2) = bulletcol%(i) THEN
  296.             ihitaliens = -i2
  297.             EXIT FOR
  298.         END IF
  299.     END IF
  300.  
  301.  
  302. SUB instructions
  303.  
  304. ''in$ = "EOF"
  305. IF in$ = "" THEN
  306.     key$ = INKEY$
  307.     LOCATE 3, 3, 1, 7, 7: COLOR 7, ibk
  308.     SLEEP 2
  309.     DO
  310.         READ in$
  311.         IF MID$(in$, 1, 3) = "EOF" THEN EXIT DO
  312.         FOR i = 1 TO LEN(in$)
  313.             SOUND 400, .1
  314.             LOCATE , 2 + i
  315.             PRINT MID$(in$, i, 1);
  316.             z = TIMER
  317.             DO
  318.                 IF ABS(z - TIMER) > .1 THEN EXIT DO
  319.             LOOP
  320.         NEXT
  321.         LOCATE , , 0, 7, 0
  322.         key$ = INKEY$
  323.         SLEEP 1
  324.         PRINT
  325.         LOCATE , 3
  326.     LOOP
  327.     key$ = INKEY$
  328.     SLEEP 1
  329.  
  330. IF in$ = "EOF" THEN
  331.     COLOR 7, 1
  332.     FOR i = 1 TO 5
  333.         LOCATE 2 + i, 2: PRINT SPACE$(78)
  334.     NEXT
  335.     FOR i = 3 TO 24
  336.         LOCATE i, 80: PRINT CHR$(179);
  337.     NEXT
  338.     LOCATE 21, 2: PRINT STRING$(78, " ");
  339.     LOCATE 22, 1: PRINT CHR$(179);
  340.     LOCATE 22, 80: PRINT CHR$(179);
  341.     LOCATE 22, 2: PRINT STRING$(78, " ");
  342.     COLOR 0, 3
  343.  
  344. COLOR 0, 3
  345. yy% = CSRLIN: xx% = POS(1)
  346. LOCATE 25, 76 - LEN(LTRIM$(STR$(ihits)))
  347. PRINT LTRIM$(STR$(ihits));
  348. LOCATE 25, 80 - LEN(LTRIM$(STR$(imaxalienforce - alienforce%)))
  349. PRINT "0";
  350. LOCATE yy%, xx%
  351.  
  352. PCOPY 0, 3: REM save skin
  353.  
  354.  
  355. SUB marchdown (ialiencol, ialiencolstat, imotion, iresults)
  356. COLOR 7, ibk
  357. ileadingrow = ileadingrow + 1
  358. ileadingmax = ileadingmax + 1
  359. COLOR 7, ibk
  360. FOR i = 1 TO imaxalienforce
  361.     IF RTRIM$(a(i)) <> "" THEN
  362.         ialiencol = ialiencolstat + imotion
  363.         LOCATE ileadingmax - (imaxalienforce * 2) + i * 2 - 1, lmargin%
  364.         PRINT STRING$(screenwidth%, " ")
  365.         LOCATE , ialiencol + INSTR(a(i), "-")
  366.         iltalien(i) = POS(1)
  367.         PRINT LTRIM$(RTRIM$(a(i)))
  368.     END IF
  369. LOCATE irow, icol
  370. level = level - .025
  371. IF ileadingrow = 22 THEN iresults = -2
  372.  
  373. SUB mdriver (ex%, key$, tankx%)
  374. STATIC MOUSEACT%
  375.  
  376. REM INITIATE MOUSE
  377. IF MOUSEACT% = 0 OR ex% = -1 THEN
  378.     Registers.AX = 0: GOSUB CALLI
  379.     MOUSEACT% = 1
  380.  
  381. IF ex% = 1 THEN
  382.     Registers.AX = 4: Registers.DX = 184: Registers.CX = 304
  383.     Registers.AX = 8: Registers.DX = 184: Registers.CX = 184
  384.     GOSUB CALLI
  385.     EXIT SUB
  386.  
  387. Registers.AX = 3: GOSUB CALLI
  388.  
  389. DX = Registers.DX
  390. CX = Registers.CX
  391. y% = DX \ 8 + 1: x% = CX \ 8 + 1
  392.  
  393. REM MOUSE BUTTONS
  394. LB% = Registers.BX AND 1
  395. RB% = (Registers.BX AND 2) \ 2
  396. MB% = (Registers.BX AND 4) \ 4
  397.  
  398. IF LB% <> 0 THEN
  399.     key$ = CHR$(32)
  400.     IF x% > tankx% THEN key$ = CHR$(0) + "M"
  401.     IF x% < tankx% THEN key$ = CHR$(0) + "K"
  402.  
  403. CALLI:
  404. CALL INTERRUPT(&H33, Registers, Registers)
  405.  
  406.  
  407. SUB movealiens (ialiencol, ialiencolstat, iresults)
  408. STATIC imotion, imarch, imotiondir
  409. IF inextrnd = -1 THEN inextrnd = 0: imotion = 0: imarch = 0: imotiondir = 0
  410. irow = CSRLIN: icol = POS(1)
  411. yy% = CSRLIN: xx% = POS(1)
  412. PCOPY 0, 1: SCREEN 0, 0, 1, 0: LOCATE yy%, xx%, 0, 7, 0
  413. IF imotiondir = 0 THEN imotion = imotion - 1 ELSE imotion = imotion + 1
  414. COLOR 7, ibk
  415.  
  416. FOR i = imaxalienforce TO 1 STEP -1
  417.     IF RTRIM$(a(i)) <> "" THEN
  418.         i2 = i2 + 2
  419.         SOUND 400, .03
  420.         ialiencol = ialiencolstat + imotion
  421.         LOCATE ileadingmax - (imaxalienforce - i) * 2, ialiencol + INSTR(a(i), "-")
  422.         IF POS(1) = lmargin% THEN imarch = 1
  423.         iltalien(i) = POS(1)
  424.         IF imotiondir = 0 THEN
  425.             PRINT LTRIM$(RTRIM$(a(i))); " "
  426.         ELSE
  427.             LOCATE , POS(1) - 1
  428.             PRINT " "; LTRIM$(RTRIM$(a(i)))
  429.         END IF
  430.         IF ialiencol + LEN(RTRIM$(a(i))) = screenwidth% THEN imarch = -1
  431.     END IF
  432.  
  433. IF imarch = 1 THEN imotiondir = 1: CALL marchdown(ialiencol, ialiencolstat, imotion, iresults)
  434. IF imarch = -1 THEN imotiondir = 0: CALL marchdown(ialiencol, ialiencolstat, imotion, iresults)
  435. IF imarch = 0 THEN
  436.     IF ABS(TIMER - z2alienfire) > firerate THEN
  437.         firerate = (INT(RND * 10) + 1) / 20
  438.         IF iwait = 0 THEN CALL alienattack(ialiencolstat, ialiencol)
  439.     END IF
  440.     imarch = 0
  441. PCOPY 1, 0: SCREEN 0, 0, 0, 0
  442. LOCATE irow, icol, 1, 7, 7
  443.  
  444. SUB mship (imothership)
  445. STATIC x%, mov%, z4, mothership$
  446.  
  447. yy% = CSRLIN: xx% = POS(1): COLOR 7, ibk
  448. IF imothership = -1 THEN
  449.     imothership = 1
  450.     x% = lmargin%
  451.     mothership$ = CHR$(254) + CHR$(254) + "O" + CHR$(254) + CHR$(254)
  452.     mov% = 1
  453.  
  454. IF ABS(TIMER - z4) > .05 THEN GOSUB mothership: z4 = TIMER: LOCATE yy%, xx%: EXIT SUB
  455. ''IF ABS(TIMER - z2) > .2 THEN GOSUB bullets: z2 = TIMER
  456. LOCATE yy%, xx%
  457.  
  458. mothership:
  459. IF x% + LEN(mothership$) = screenwidth% + lmargin% THEN mov% = -1 ELSE IF x% = lmargin% THEN mov% = 1
  460. x% = x% + mov%
  461. LOCATE topmargin%, x%
  462. PRINT mothership$;
  463. IF x% > 1 AND mov% = 1 THEN
  464.     LOCATE , POS(1) - LEN(mothership$) - 1: PRINT " ";
  465. IF mov% = -1 THEN PRINT " ";
  466.  
  467.  
  468. DEFINT A-H, J-Z
  469. SUB qbide
  470. PALETTE 2, 59
  471. COLOR 15, 1
  472.  
  473. COLOR 0, 7
  474. LOCATE 1, 1
  475. LOCATE 1, 1: PRINT "   File  Edit  View  Search  Run  Debug  Calls  Options                   Help"
  476.  
  477. COLOR 7, 1
  478.  
  479. LOCATE 2, 1: PRINT CHR$(218)
  480. LOCATE 2, 2: PRINT STRING$(78, CHR$(196))
  481. LOCATE 2, 80: PRINT CHR$(191)
  482.  
  483. LOCATE 2, 76: PRINT CHR$(180)
  484. LOCATE 2, 78: PRINT CHR$(195)
  485.  
  486. COLOR 1, 7
  487. LOCATE 2, 77: PRINT CHR$(24)
  488. LOCATE 2, 36: PRINT " Untitled "
  489.  
  490. COLOR 7, 1
  491. FOR Rows = 3 TO 24
  492.     LOCATE Rows, 1: PRINT CHR$(179);
  493.     LOCATE Rows, 80: PRINT CHR$(179);
  494. NEXT Rows
  495.  
  496. LOCATE 22, 1: PRINT CHR$(195)
  497. LOCATE 22, 80: PRINT CHR$(180)
  498. LOCATE 22, 2: PRINT STRING$(78, CHR$(196))
  499. LOCATE 22, 35
  500. PRINT " Immediate "
  501.  
  502. COLOR 0, 7
  503. LOCATE 21, 3: PRINT STRING$(76, CHR$(176))
  504. LOCATE 21, 2: PRINT CHR$(27)
  505. LOCATE 21, 3: PRINT CHR$(219)
  506. LOCATE 21, 79: PRINT CHR$(26)
  507. FOR Rows = 4 TO 19
  508.     LOCATE Rows, 80: PRINT CHR$(176)
  509. NEXT Rows
  510. LOCATE 3, 80: PRINT CHR$(24)
  511. LOCATE 4, 80: PRINT CHR$(219)
  512. LOCATE 20, 80: PRINT CHR$(25)
  513.  
  514. COLOR 0, 3: LOCATE 25, 1: PRINT " <Shift+F1=Help> <F6=Window> <F2=Subs> <F5=Run> <F8=Step> ";
  515. LOCATE 25, 59: PRINT SPACE$(4);
  516. COLOR 0, 3
  517. LOCATE 25, 63: PRINT CHR$(179);
  518. LOCATE 25, 64: PRINT SPACE$(6);
  519. LOCATE 25, 68: PRINT "C  00001:001 ";
  520.  
  521.  
  522. DEFSNG A-H, J-Z
  523. SUB reprintaliens (ialiencol, ihitaliens, iresults, i4, i, imothership)
  524. IF ihitaliens > 0 THEN
  525.     ihits = ihits + 1
  526.     IF (ihits + 15) MOD 20 = 0 AND imothership = 0 THEN imothership = -1
  527.     LOCATE bullet%(i), lmargin%: PRINT SPACE$(screenwidth%);
  528.     iltalien(i4) = POS(1)
  529.  
  530.     IF RTRIM$(a(i4)) = "" THEN
  531.         alienforce% = alienforce% - 1
  532.         IF alienforce% = 0 THEN iresults = iresults + 1
  533.         IF bullet%(i) = ileadingrow THEN ileadingrow = ileadingrow - 2
  534.     ELSE
  535.         LOCATE bullet%(i), ialiencol + INSTR(a(i4), "-"): PRINT LTRIM$(RTRIM$(a(i4)))
  536.     END IF
  537.     i2 = ABS(ihitaliens)
  538.     LOCATE iy(i2), ix(i2)
  539.     PRINT " ";: iy(i2) = 0
  540.     ia(i2) = 0
  541.     LOCATE irow, icol
  542.     SOUND 1000, .5
  543.  
  544. ihitaliens = 0
  545. bullet%(i) = -bullet%(i)
  546.  
  547. COLOR 0, 3
  548. yy% = CSRLIN: xx% = POS(1)
  549. LOCATE 25, 76 - LEN(LTRIM$(STR$(ihits)))
  550. PRINT LTRIM$(STR$(ihits));
  551. LOCATE 25, 80 - LEN(LTRIM$(STR$(imaxalienforce - alienforce%)))
  552. PRINT LTRIM$(STR$(imaxalienforce - alienforce%));
  553. LOCATE yy%, xx%
  554. COLOR 7, ibk
  555.  

Edit: Hey, I found the mother ship version! Mouse to move, left click to shoot.

 
tenor.gif

Offline Aurel

  • Forum Regular
  • Posts: 167
    • View Profile
Re: Shooter Start
« Reply #5 on: March 31, 2019, 04:03:34 pm »
I am not gamer but i must say that i like    SMcNeill shooter
Please just rebuild this ugly shape of cannon or ship .
mooving and fire works fine

mark ..sorry but what is that ?

pete
finish compiler...also shooter is craAAzy !
//////////////////////////////////////////////////////////////////
https://aurelsoft.ucoz.com
https://www.facebook.com/groups/470369984111370
//////////////////////////////////////////////////////////////////

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Shooter Start
« Reply #6 on: March 31, 2019, 04:14:13 pm »
Code: QB64: [Select]
  1. mark ..sorry but what is that ?

Sorry, it's a free moving shooter that points in any direction you move or swings around CCW or CW depending which mouse button you press. Try out the shooter here in Reply #1: https://www.qb64.org/forum/index.php?topic=392.msg3613#msg3613

Perhaps you'd rather be stuck on a track only able to shoot in one direction by pumping the arrow and spacebar keys. ;-))
« Last Edit: March 31, 2019, 04:28:17 pm by bplus »

Offline Aurel

  • Forum Regular
  • Posts: 167
    • View Profile
Re: Shooter Start
« Reply #7 on: April 01, 2019, 02:10:14 am »
yo mark
Quote
Perhaps you'd rather be stuck on a track only able to shoot in one direction by pumping the arrow and spacebar keys. ;-))

Yes...and you know why?
simply because ...sorry man but your "mooving" is very " so so "
i will found one old shooter in CB i should post it on rtroB written in dx...then you will see difference.
for a simple shooter i prefer < - > space
//////////////////////////////////////////////////////////////////
https://aurelsoft.ucoz.com
https://www.facebook.com/groups/470369984111370
//////////////////////////////////////////////////////////////////

Offline _vince

  • Seasoned Forum Regular
  • Posts: 422
    • View Profile
Re: Shooter Start
« Reply #8 on: April 01, 2019, 09:17:55 am »
You're quite the critic, Aurel

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Shooter Start
« Reply #9 on: April 01, 2019, 10:22:33 am »
yo mark
Quote
Perhaps you'd rather be stuck on a track only able to shoot in one direction by pumping the arrow and spacebar keys. ;-))

Yes...and you know why?
simply because ...sorry man but your "mooving" is very " so so "
i will found one old shooter in CB i should post it on rtroB written in dx...then you will see difference.
for a simple shooter i prefer < - > space

Ha! One track mind stuck in Recursive Decent Parsing! ;-))

I am not much of a gamer either but I love the sweeping mouse control over pounding little arrow keys. Perhaps I should have used a mouse button for firing shots instead of rotating a machine gun like turret with unlimited ammo. But when you are fighting off invaders for survival, who wants to worry about having enough ammo? :)

OK the fix is on it's way.

(On my keyboard, they jammed 4 arrow keys in the space of three letter buttons making it miserable to play games.)

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Shooter Start
« Reply #10 on: April 01, 2019, 12:08:57 pm »
OK now mouse buttons trigger shots and limited to 3 active bullets, move mouse towards target and click.
Code: QB64: [Select]
  1. _TITLE "Mouse Action Shooter MB triggers" 'B+ 2019-04-01
  2. 'Mouse Action Shooter started from eRATication 5 by bplus 2018-08-06"
  3. ' upodate Mouse Action Shooter with MB triggers 2019-04-01
  4.  
  5. 'screen dimensions
  6. CONST ww = 1200
  7. CONST wh = 700
  8. CONST nBullets = 3
  9. CONST bSpeed = 20
  10. CONST shooterRadius = 50
  11.  
  12. TYPE shooterType
  13.     x AS SINGLE
  14.     y AS SINGLE
  15.     a AS SINGLE
  16.  
  17. TYPE bulletType
  18.     x AS INTEGER
  19.     y AS INTEGER
  20.     dx AS INTEGER
  21.     dy AS INTEGER
  22.     live AS INTEGER
  23.  
  24. SCREEN _NEWIMAGE(ww, wh, 32)
  25. _SCREENMOVE 100, 20
  26.  
  27.  
  28. DIM SHARED GameOn, newRound, fire, mb1, mb2, last1, last2
  29.  
  30. DIM SHARED b(nBullets) AS bulletType
  31. DIM SHARED shooter AS shooterType
  32. shooter.x = ww / 2
  33. shooter.y = wh / 2
  34. shooter.a = 0
  35. lastx = ww / 2: lasty = wh / 2
  36. GameOn = 1
  37. WHILE GameOn
  38.     CLS
  39.     fire = 0: mb1 = 0: mb2 = 0
  40.     shooter.x = _MOUSEX: shooter.y = _MOUSEY
  41.     IF ABS(lastx - shooter.x) > 3 AND ABS(lasty - shooter.y) > 3 THEN
  42.         shooter.a = _ATAN2(shooter.y - lasty, shooter.x - lastx)
  43.         lastx = shooter.x: lasty = shooter.y
  44.     END IF
  45.     t = TIMER(.001)
  46.     IF _MOUSEBUTTON(1) THEN 'when ship is heading north the left button should be left
  47.         IF t - last2 > .25 THEN mb2 = 1: last2 = t
  48.     END IF
  49.         IF t - last1 > .25 THEN mb1 = 1: last1 = t
  50.     END IF
  51.     drawshooter
  52.     handleBullets
  53.     _DISPLAY
  54.     _LIMIT 30
  55.  
  56. SUB handleBullets ()
  57.     FOR i = 0 TO nBullets - 1
  58.         IF b(i).live = 0 AND mb1 = 1 THEN 'have in active bullet index to use
  59.             b(i).x = shooter.x + (shooterRadius) * COS(shooter.a + _PI(7 / 8))
  60.             b(i).y = shooter.y + (shooterRadius) * SIN(shooter.a + _PI(7 / 8))
  61.             b(i).dx = bSpeed * COS(shooter.a)
  62.             b(i).dy = bSpeed * SIN(shooter.a)
  63.             b(i).live = 1
  64.             mb1 = 0
  65.         ELSEIF b(i).live = 0 AND mb2 = 1 THEN
  66.             b(i).x = shooter.x + (shooterRadius) * COS(shooter.a - _PI(7 / 8))
  67.             b(i).y = shooter.y + (shooterRadius) * SIN(shooter.a - _PI(7 / 8))
  68.             b(i).dx = bSpeed * COS(shooter.a)
  69.             b(i).dy = bSpeed * SIN(shooter.a)
  70.             b(i).live = 1
  71.             mb2 = 0
  72.  
  73.         ELSEIF b(i).live = 1 THEN 'new location
  74.             b(i).x = b(i).x + b(i).dx
  75.             b(i).y = b(i).y + b(i).dy
  76.             IF b(i).x > 0 AND b(i).x < ww AND b(i).y > 0 AND b(i).y < wh THEN 'in bounds draw it
  77.                 'check for collision with ...
  78.  
  79.                 'else draw bullet
  80.                 ba = _ATAN2(b(i).dy, b(i).dx): b = 15
  81.                 x1 = b(i).x + b * COS(ba)
  82.                 y1 = b(i).y + b * SIN(ba)
  83.                 x2 = b(i).x + b * COS(ba + _PI(5 / 6))
  84.                 y2 = b(i).y + b * SIN(ba + _PI(5 / 6))
  85.                 x3 = b(i).x + b * COS(ba + _PI(7 / 6))
  86.                 y3 = b(i).y + b * SIN(ba + _PI(7 / 6))
  87.                 fTri x1, y1, x2, y2, x3, y3, _RGB32(0, 0, 160)
  88.                 'fcirc b(i).x, b(i).y, 4, _RGB32(64, 0, 0)
  89.             ELSE
  90.                 b(i).live = 0 'dectiveate
  91.             END IF
  92.         END IF
  93.     NEXT
  94.  
  95. SUB drawshooter ()
  96.     'just a wedge
  97.     x1 = shooter.x + shooterRadius * COS(shooter.a)
  98.     y1 = shooter.y + shooterRadius * SIN(shooter.a)
  99.     x2 = shooter.x + shooterRadius * COS(shooter.a + _PI(7 / 8))
  100.     y2 = shooter.y + shooterRadius * SIN(shooter.a + _PI(7 / 8))
  101.     x3 = shooter.x + shooterRadius * COS(shooter.a - _PI(7 / 8))
  102.     y3 = shooter.y + shooterRadius * SIN(shooter.a - _PI(7 / 8))
  103.     fTri x1, y1, x2, y2, x3, y3, _RGB32(155, 55, 0)
  104.     x2 = shooter.x + shooterRadius * COS(shooter.a + _PI(15 / 16))
  105.     y2 = shooter.y + shooterRadius * SIN(shooter.a + _PI(15 / 16))
  106.     x3 = shooter.x + shooterRadius * COS(shooter.a - _PI(15 / 16))
  107.     y3 = shooter.y + shooterRadius * SIN(shooter.a - _PI(15 / 16))
  108.     fTri x1, y1, x2, y2, x3, y3, _RGB32(255, 255, 255)
  109.  
  110. ' found at [abandoned, outdated and now likely malicious qb64 dot net website - don’t go there]:    http://www.[abandoned, outdated and now likely malicious qb64 dot net website - don’t go there]/forum/index.php?topic=14425.0
  111. SUB fTri (x1, y1, x2, y2, x3, y3, K AS _UNSIGNED LONG)
  112.     a& = _NEWIMAGE(1, 1, 32)
  113.     _DEST a&
  114.     PSET (0, 0), K
  115.     _DEST 0
  116.     _MAPTRIANGLE _SEAMLESS(0, 0)-(0, 0)-(0, 0), a& TO(x1, y1)-(x2, y2)-(x3, y3)
  117.     _FREEIMAGE a& '<<< this is important!
  118.  

Offline Aurel

  • Forum Regular
  • Posts: 167
    • View Profile
Re: Shooter Start
« Reply #11 on: April 01, 2019, 01:59:09 pm »
Quote
You're quite the critic, Aurel

ahh no...Mark is my old online friend and i know that he can better.
//////////////////////////////////////////////////////////////////
https://aurelsoft.ucoz.com
https://www.facebook.com/groups/470369984111370
//////////////////////////////////////////////////////////////////

Offline Ashish

  • Forum Resident
  • Posts: 630
  • Never Give Up!
    • View Profile
Re: Shooter Start
« Reply #12 on: April 03, 2019, 01:09:37 am »
@Pete
Impressive.
@bplus
It is nice in your program that direction can be easily controlled  by mouse.
if (Me.success) {Me.improve()} else {Me.tryAgain()}


My Projects - https://github.com/AshishKingdom?tab=repositories
OpenGL tutorials - https://ashishkingdom.github.io/OpenGL-Tutorials