Author Topic: 1945  (Read 2828 times)

0 Members and 1 Guest are viewing this topic.

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
Re: 1945
« Reply #30 on: December 12, 2021, 02:27:52 pm »
Aurel,

Good to know. Thank you.

Bplus,

I knew it! I just knew it!  Looks like it was blind luck on my part... Died on the first try? The second try?

I have been updating the rcbasic version as well... The only problem I had was the "rapid firing". RC recognises "Timer" but not "Timer(.001)". At the moment, RC, has "normal" shooting... but that's another story... Yes. Back to the updating of RC... No glitches whatsoever... That would indicate that my ability to convert Naalaa to QB is questionable at best. Back to the drawing board... *sigh*  So much for version 5....
Logic is the beginning of wisdom.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: 1945
« Reply #31 on: December 12, 2021, 03:04:15 pm »
@johnno56

I am wondering how things can continue when the health < 0, for several frames this continued. I suspect a simple little logic error or missed check somewhere.

For RC timer, if you can't get a timer below parts of a second, how about counting loops before allowing a bullet to be fired. ie fired a bullet, fired = 10 and fired =fired - 1 each loop if fired < 0 then another bullet allowed. I think I will try that now, today.

PS I worked the green Health Bar to show more 3D coloring of green, first get rid of red, 2nd start at 50 not 143 3rd increment colors by 50.

It's possible when set something off to side, things are still colliding with it. Should not be necessary to move things to the side but to check both objects are active before display or collision checks.

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
Re: 1945
« Reply #32 on: December 12, 2021, 03:53:46 pm »
I have created an "ExitGame" routine (except for running out of lives - gotta keep the high scores...) and error trapping. Escaping from all other screens will exit the game.

I am not getting any negative values for health... "Several frames"? Probably why I did not see it... lol

Any improvements to the "Panel" would be great... The original did look a little, shall we say, spartan.

Moving objects "off to the side" is the direct result of the conversion. Poor excuse saying, "That is how the original was coded". Appreciate anything you can do to correct that.

Oh. I have also modified the ammo and health power-ups. As well as the normal reasons for dropping the power-ups, I have also included a random number to drop the power-ups. Not sure how that will effect the CPU... Not overly familiar with QB64 timer function to make it more efficient.

 

ps: Let us hope you will last longer than one game... lol
Logic is the beginning of wisdom.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: 1945
« Reply #33 on: December 12, 2021, 05:28:15 pm »
Dang! you have v6 up, oh well working from v5 I did this:

Bullets off the timer now optional after 10 frames from last fired.
I have reworked much running everything under Option _Explicit. Removed 2 variables abandoned, DIM'd a million more and found a typo explox2 supposed to be explo2X. I reduced ammo to 100 same as max bullets that can be active and increased repairs to 50 because usually lose more trying to get repair!! I made bullet hits same loss as collision so if you hear 4 hits, you know goodbye plane:

 
Code: QB64: [Select]
  1. ' 1945qb translated by Johnno from Naalaa
  2. '2021-12-06 bplus mod splash screen / menu
  3. '2021-12-07 bplus give the players plane more than 1 bullet!
  4. '2021-12-11 bplus added Top Ten Score tracker combined with Go again function v4
  5. ' from v5 johnno's fixed collision rectangles
  6. '2021-12-12 bplus allows bullet if 10 frames have passed since last, fired, variable
  7. '2021-12-12 bplus review all variables under Option _Explicit and search
  8. ' removed quit, dead variables found typo explox2 supposed to be explo2x
  9. ' decreased ammo to 100 same as max active bullets
  10. ' increased health +50 because loose health getting to health st it's no help!!!
  11. ' made bullet hitting plane same as crashes -25, so you hear 4 hits on plane you know goodbye plane
  12.  
  13. Const xmax = 640, ymax = 480
  14. _Title "1945"
  15.  
  16. Screen _NewImage(xmax, ymax, 32)
  17.  
  18. '   ARRAYS
  19. Dim backgroundX(21)
  20. Dim backgroundY(16)
  21. Dim transitionX(21)
  22. Dim transitionY(16)
  23. Dim enemyX(5)
  24. Dim enemyY(5)
  25. Dim superenemyX(5)
  26. Dim superenemyY(5)
  27. Dim decision(2)
  28. Dim enemybulletX(2)
  29. Dim enemybulletY(2)
  30. Dim enemyshot(2)
  31. Dim islandImage(3)
  32. Dim islandX(3)
  33. Dim islandY(3)
  34. Dim img(60)
  35.  
  36.  
  37.  
  38. trans = _RGBA32(0, 0, 0, 0)
  39.  
  40.  
  41. Dim width0, height0, width3, height3, width5, height5, width27, height27, width28, height28, width29, height29
  42. Dim width30, height30, width32, height32, width35, height35, width36, height36, ammo, repairActive, ammoActive
  43.  
  44. width0 = 57
  45. height0 = 42
  46. width3 = 9
  47. height3 = 19
  48. width5 = 32
  49. height5 = 32
  50. width27 = 5
  51. height27 = 5
  52. width28 = 94
  53. height28 = 31
  54. width29 = 6
  55. height29 = 11
  56. width30 = 278
  57. height30 = 141
  58. width32 = 115
  59. height32 = 58
  60. width35 = 18
  61. height35 = 28
  62. width36 = 18
  63. height36 = 28
  64.  
  65. hit = 0
  66. ammo = 100
  67. repairActive = 0
  68. ammoActive = 0
  69.  
  70. '   LOAD ASSETS
  71. '   ===========
  72.  
  73. '   Images
  74. '
  75. img(0) = _LoadImage("data/plane1.png")
  76. img(1) = _LoadImage("data/plane2.png")
  77. img(2) = _LoadImage("data/plane3.png")
  78. img(3) = _LoadImage("data/bullet.png")
  79. img(4) = _LoadImage("data/sea.png")
  80. img(5) = _LoadImage("data/enemy1.png")
  81. img(6) = _LoadImage("data/enemy2.png")
  82. img(7) = _LoadImage("data/enemy3.png")
  83. img(8) = _LoadImage("data/explosion1.png")
  84. img(9) = _LoadImage("data/explosion2.png")
  85. img(10) = _LoadImage("data/explosion3.png")
  86. img(11) = _LoadImage("data/explosion4.png")
  87. img(12) = _LoadImage("data/explosion5.png")
  88. img(13) = _LoadImage("data/explosion6.png")
  89. img(14) = _LoadImage("data/bigexplosion1.png")
  90. img(15) = _LoadImage("data/bigexplosion2.png")
  91. img(16) = _LoadImage("data/bigexplosion3.png")
  92. img(17) = _LoadImage("data/bigexplosion4.png")
  93. img(18) = _LoadImage("data/bigexplosion5.png")
  94. img(19) = _LoadImage("data/bigexplosion6.png")
  95. img(20) = _LoadImage("data/bigexplosion7.png")
  96. img(21) = _LoadImage("data/island1.png")
  97. img(22) = _LoadImage("data/island2.png")
  98. img(23) = _LoadImage("data/island3.png")
  99. img(24) = _LoadImage("data/superenemy1.png")
  100. img(25) = _LoadImage("data/superenemy2.png")
  101. img(26) = _LoadImage("data/superenemy3.png")
  102. img(27) = _LoadImage("data/enemybullet.png")
  103. img(28) = _LoadImage("data/menu.png")
  104. img(29) = _LoadImage("data/arrow.png")
  105. img(30) = _LoadImage("data/biglogo.png")
  106. img(31) = _LoadImage("data/life.png")
  107. img(32) = _LoadImage("data/logo.png")
  108. img(33) = _LoadImage("data/paused.png")
  109. img(34) = _LoadImage("data/gameover.png")
  110.  
  111. '   Power ups
  112. img(35) = _LoadImage("data/repair.png") '   health
  113. img(36) = _LoadImage("data/ammo.png") '     ammunition
  114.  
  115. '   Sounds
  116. '
  117. Dim As Long shoot, explosion, collide, plane_shot, pu_health, pu_ammo
  118. shoot = _SndOpen("data/shoot.wav")
  119. explosion = _SndOpen("data/explosion.wav")
  120. collide = _SndOpen("data/collide.wav")
  121. plane_shot = _SndOpen("data/plane_shot.wav")
  122. pu_health = _SndOpen("data/health.wav")
  123. pu_ammo = _SndOpen("data/ammo.wav")
  124.  
  125. '   Fonts
  126. '
  127. Dim As Long arial14, war60, war12
  128. arial14 = _LoadFont("data/arial.ttf", 14)
  129. war60 = _LoadFont("data/armalite.ttf", 60)
  130. war12 = _LoadFont("data/armalite.ttf", 12)
  131.  
  132. Dim i, a
  133.  
  134.  
  135.  
  136. '   TILING THE BACKGROUND
  137. '   =====================
  138. 'backgroundX((640 / 32) + 1)
  139. 'backgroundY((480 / 32) + 1)
  140. 'transitionX((640 / 32) + 1)
  141. 'transitionY((480 / 32) + 1)
  142. For i = 0 To 640 / 32
  143.     backgroundX(i) = i * 32
  144.     transitionX(i) = i * 32
  145.     For a = 0 To 480 / 32
  146.         backgroundY(a) = a * 32
  147.         transitionY(a) = a * 32
  148.     Next
  149.  
  150.  
  151. '   A GAME MENU TO START WITH
  152. '   =========================
  153.  
  154. Dim menu, k&, z
  155.  
  156. menu = 0
  157. Color _RGB32(150, 0, 0)
  158.     Cls
  159.  
  160.  
  161.     '_PutImage ((640 - width30) / 2, 5), img(30)
  162.     _PutImage , img(30) ' full screen image
  163.  
  164.     If menu = 0 Then
  165.         _Font war60
  166.         Color _RGB32(255, 255, 255)
  167.         centerText 0, _Width, ymax * .6, "Play Game"
  168.         Color _RGB32(70, 0, 0)
  169.         _Font war12
  170.         centerText 0, _Width, ymax * .6 + 70, "Quit"
  171.     Else
  172.         _Font war12
  173.         Color _RGB32(70, 0, 0)
  174.         centerText 0, _Width, ymax * .6, "Play Game"
  175.         _Font war60
  176.         Color _RGB32(255, 255, 255)
  177.         centerText 0, _Width, ymax * .6 + 70, "Quit"
  178.     End If
  179.  
  180.     '_PutImage ((640 - width28) / 2, height30 + 30), img(28)
  181.     '_PutImage (((640 - width28) / 2) - width29, height30 + (30 + menu * 19)), img(29)
  182.     k& = _KeyHit
  183.     If k& = (18432) Then
  184.         menu = menu - 1
  185.     End If
  186.     If k& = (20480) Then
  187.         menu = menu + 1
  188.     End If
  189.  
  190.     If menu > 1 Then
  191.         menu = 0
  192.     End If
  193.     If menu < 0 Then
  194.         menu = 1
  195.     End If
  196.  
  197.     If _KeyDown(32) And menu = 0 Then
  198.         Exit Do
  199.     End If
  200.     If _KeyDown(32) And menu = 1 Then
  201.         For i = 0 To 640 / 32
  202.             For z = 0 To 480 / 32
  203.                 _PutImage (transitionX(i), transitionY(z)), img(4)
  204.                 _Display
  205.                 _Limit 300
  206.             Next
  207.         Next
  208.         _PutImage (0, 0), img(34)
  209.         _Display
  210.         _Delay 1
  211.         System 'ExitGame()
  212.     End If
  213.     _Display
  214.     _Limit 20
  215.  
  216. For i = 0 To 640 / 32
  217.     For z = 0 To 480 / 32
  218.         _PutImage (transitionX(i), transitionY(z)), img(4)
  219.         _Display
  220.         _Delay 0.01
  221.     Next
  222.  
  223. Dim nBullets, frame, explo_frame, bigexplo_frame, bigexploX, bigexploY, explo2_frame, speed, planeX, planeY, shot, exploX, exploY
  224. Dim explo2X, explo2Y, score, lives, health, bullseye, shots_fired, bigexploactive, repairX, repairY, repairSpeed, ammoX, ammoY, ammoSpeed
  225. Dim fired, t, w, q, o, x, j, s, c, goAgain$
  226. nBullets = 100
  227.  
  228. restart:
  229. _Font arial14
  230. '   INITIALIZING VARIABLES
  231. '   =================================
  232. ammo = 100  ' EDIT renew ammo
  233. Type bullet
  234.     As Single x, y, active
  235. ReDim bullets(1 To nBullets) As bullet
  236.  
  237. frame = 0
  238. explo_frame = 0
  239. bigexplo_frame = 0
  240. bigexploX = -70
  241. bigexploY = -70
  242. explo2_frame = 0
  243. speed = 6
  244. planeX = 320
  245. planeY = 480 - 128
  246. enemyshot(0) = 0
  247. enemyshot(1) = 0
  248. shot = 0
  249. exploX = -30
  250. exploY = -30
  251. explo2X = -30
  252. explo2Y = -30
  253. score = 0
  254. lives = 3
  255. health = 100
  256. bullseye = 1
  257. shots_fired = 1
  258. bigexploactive = 0
  259.  
  260.  
  261. '   SETTING THE POSITIONS OF THE ENEMY PLANES
  262. '   =========================================
  263. For i = 0 To 4
  264.     enemyX(i) = Int(Rnd * 608)
  265.     enemyY(i) = 0 - Int(Rnd * 480) - 32
  266. For i = 0 To 1
  267.     superenemyX(i) = Int(Rnd * 608)
  268.     superenemyY(i) = 0 - Int(Rnd * 480) - 32
  269.     enemybulletX(i) = superenemyX(i) + 13
  270.     enemybulletY(i) = superenemyY(i) + 17
  271.  
  272. '   SETTING THE POSITIONS AND STARTING IMAGES OF THE ISLANDS
  273. '   ========================================================
  274. For i = 0 To 2
  275.     islandX(i) = Int(Rnd * 576)
  276.     islandY(i) = 0 - Int(Rnd * 480)
  277.     islandImage(i) = img(i + 21)
  278.  
  279. '   SETUP POWER UPS
  280. '   ===============
  281. repairX = Int(Rnd * 608)
  282. repairY = 0 - Int(Rnd * 480)
  283. repairSpeed = 2
  284.  
  285. ammoX = Int(Rnd * 608)
  286. ammoY = 0 - Int(Rnd * 480)
  287. ammoSpeed = 2
  288.  
  289. '   THE 'ACTUAL' GAME LOOP
  290. '   ======================
  291.  
  292.     fired = fired - 1 ' >>>> use frame  count instead of timer to allow shooting a bullet
  293.  
  294.  
  295.     '   CLEARING THE SCREEN
  296.     '   ===================
  297.     Cls
  298.  
  299.     '   MOVING THE PLAYER WITH THE ARROW KEYS
  300.     '   =====================================
  301.     '   OH, AND SHOOTING WITH THE SPACEBAR
  302.     '   ==================================
  303.     If _KeyDown(27) Then
  304.         End
  305.     End If
  306.     If _KeyDown(18432) Then
  307.         planeY = planeY - speed
  308.     End If
  309.     If _KeyDown(20480) Then
  310.         planeY = planeY + 4
  311.     End If
  312.     If _KeyDown(19200) Then
  313.         planeX = planeX - speed
  314.     End If
  315.     If _KeyDown(19712) Then
  316.         planeX = planeX + speed
  317.     End If
  318.     If _KeyDown(32) Then
  319.         ' find inactive bullet
  320.         If fired < 0 And ammo > 0 Then
  321.             For i = 1 To nBullets
  322.                 If bullets(i).active = 0 Then
  323.                     bullets(i).x = planeX + 27 ' 17
  324.                     bullets(i).y = planeY + 5
  325.                     bullets(i).active = -1
  326.                     _SndPlay (shoot)
  327.                     shots_fired = shots_fired + 1
  328.                     ammo = ammo - 1
  329.                     fired = 10
  330.                     Exit For
  331.                 End If
  332.             Next
  333.         End If
  334.     End If
  335.  
  336.     '   MOVING THE ENEMY PLANES
  337.     '   =======================
  338.     For z = 0 To 4
  339.         If enemyY(z) > 480 Then
  340.             enemyX(z) = Int(Rnd * 608)
  341.             enemyY(z) = 0 - Int(Rnd * 480)
  342.         Else
  343.             enemyY(z) = enemyY(z) + speed
  344.         End If
  345.     Next
  346.     For z = 0 To 1
  347.         If superenemyY(z) > 480 Then
  348.             superenemyX(z) = Int(Rnd * 608)
  349.             superenemyY(z) = 0 - Int(Rnd * 480)
  350.         Else
  351.             superenemyY(z) = superenemyY(z) + speed
  352.         End If
  353.     Next
  354.  
  355.     '   MOVING THE ISLANDS
  356.     '   ==================
  357.     For z = 0 To 2
  358.         If islandY(z) > 480 Then
  359.             islandX(z) = Int(Rnd * 576)
  360.             islandY(z) = 0 - Int(Rnd * 480)
  361.             islandImage(z) = img(Int(Rnd * 3) + 21)
  362.         Else
  363.             islandY(z) = islandY(z) + 3
  364.         End If
  365.     Next
  366.  
  367.     '   CHECKING WHEN WE BEAT OR BEING BEATEN
  368.     '   =====================================
  369.     For t = 0 To 4
  370.         '   Collision with enemy?
  371.         collision planeX, planeY, width0, height0, enemyX(t), enemyY(t), width5, height5
  372.         If hit = 1 Then
  373.             'collision(r1x, r1y, r1w, r1h, r2x, r2y, r2w, r2h)
  374.             If exploX > 0 Then
  375.                 explo2X = enemyX(t)
  376.                 explo2Y = enemyY(t)
  377.             Else
  378.                 exploX = enemyX(t)
  379.                 exploY = enemyY(t)
  380.             End If
  381.             _SndPlay (explosion)
  382.             enemyX(t) = Int(Rnd * 608)
  383.             enemyY(t) = 0 - Int(Rnd * 480)
  384.             health = health - 25
  385.             If health <= 0 Then
  386.                 bigexploactive = 1
  387.                 bigexploX = planeX
  388.                 bigexploY = planeY
  389.                 planeX = -70
  390.                 planeY = -70
  391.             End If
  392.             enemyX(t) = Int(Rnd * 608)
  393.             enemyY(t) = 0 - Int(Rnd * 480)
  394.         End If
  395.  
  396.  
  397.         'If shot = 1 Then
  398.         For i = 1 To nBullets
  399.             '   Collision with player bullet and enemy
  400.             collision bullets(i).x, bullets(i).y, width3, height3, enemyX(t), enemyY(t), width5, height5
  401.             If hit = 1 Then
  402.                 If exploX > 0 Then
  403.                     explo2X = enemyX(t)
  404.                     explo2Y = enemyY(t)
  405.                 Else
  406.                     exploX = enemyX(t)
  407.                     exploY = enemyY(t)
  408.                 End If
  409.                 _SndPlay (explosion)
  410.                 enemyX(t) = Int(Rnd * 608)
  411.                 enemyY(t) = 0 - Int(Rnd * 480)
  412.                 bullets(i).x = -30
  413.                 bullets(i).y = -30
  414.                 bullets(i).active = 0
  415.                 score = score + 50
  416.                 bullseye = bullseye + 1
  417.             End If
  418.             'End If
  419.         Next
  420.     Next
  421.     For t = 0 To 1
  422.         '   Collision with player and superenemy
  423.         collision planeX, planeY, width0, height0, superenemyX(t), superenemyY(t), width5, height5
  424.         If hit = 1 Then
  425.             If exploX > 0 Then
  426.                 explo2X = superenemyX(t)
  427.                 explo2Y = superenemyY(t)
  428.             Else
  429.                 exploX = superenemyX(t)
  430.                 exploY = superenemyY(t)
  431.             End If
  432.             _SndPlay (explosion)
  433.             superenemyX(t) = Int(Rnd * 608)
  434.             superenemyY(t) = 0 - Int(Rnd * 480)
  435.             health = health - 25
  436.             If health <= 0 Then
  437.                 bigexploactive = 1
  438.                 bigexploX = planeX
  439.                 bigexploY = planeY
  440.                 planeX = -70
  441.                 planeY = -70
  442.             End If
  443.             superenemyX(t) = Int(Rnd * 608)
  444.             superenemyY(t) = 0 - Int(Rnd * 480)
  445.         End If
  446.  
  447.  
  448.         '   Collision with player bullet and superenemy
  449.         For i = 1 To nBullets
  450.             collision bullets(i).x, bullets(i).y, width3, height3, superenemyX(t), superenemyY(t), width5, height5
  451.             If hit = 1 Then
  452.                 If exploX > 0 Then
  453.                     explo2X = superenemyX(t)
  454.                     explo2Y = superenemyY(t)
  455.                 Else
  456.                     exploX = superenemyX(t)
  457.                     exploY = superenemyY(t)
  458.                 End If
  459.                 _SndPlay (explosion)
  460.                 superenemyX(t) = Int(Rnd * 608)
  461.                 superenemyY(t) = 0 - Int(Rnd * 480)
  462.                 bullets(i).x = -30
  463.                 bullets(i).y = -30
  464.                 bullets(i).active = 0
  465.                 score = score + 100
  466.                 bullseye = bullseye + 1
  467.             End If
  468.         Next
  469.     Next
  470.     For t = 0 To 1
  471.         '   Collision with player and enemy bullet
  472.         If enemyshot(t) = 1 Then
  473.             collision planeX, planeY, width0, height0, enemybulletX(t), enemybulletY(t), width27, height27
  474.             If hit = 1 Then
  475.                 health = health - 25
  476.                 If health <= 0 Then
  477.                     bigexploactive = 1
  478.                     bigexploX = planeX
  479.                     bigexploY = planeY
  480.                     enemybulletX(t) = -30 'had players bullets here!!!
  481.                     enemybulletY(t) = -30
  482.                 End If
  483.                 _SndPlay (explosion)
  484.                 If exploX > 0 And exploX < 640 Then
  485.                     explo2X = enemybulletX(t)
  486.                     explo2Y = enemybulletY(t)
  487.                 Else
  488.                     exploX = enemybulletX(t)
  489.                     exploY = enemybulletY(t)
  490.                 End If
  491.                 enemybulletX(t) = superenemyX(t) + 14 '1
  492.                 enemybulletY(t) = superenemyY(t) + 17 '7
  493.                 enemyshot(t) = 0
  494.             End If
  495.         End If
  496.     Next
  497.  
  498.  
  499.     '   FLYING OVER THE ENDLESSLY SCROLLING SEA
  500.     '   =======================================
  501.     For w = 0 To 15
  502.         backgroundY(w) = backgroundY(w) + 3
  503.         If backgroundY(w) > 480 Then
  504.             backgroundY(w) = backgroundY(w) - 512
  505.         End If
  506.         For q = 0 To 19
  507.             _PutImage (backgroundX(q), backgroundY(w)), img(4)
  508.         Next
  509.     Next
  510.  
  511.     '   WHICH LOOKS DULL WITHOUT ISLANDS
  512.     '   ================================
  513.     For o = 0 To 2
  514.         _PutImage (islandX(o), islandY(o)), islandImage(o)
  515.     Next
  516.  
  517.     '   KEEPING OUR PLANE IN THE SCREEN AND DISPLAY IT
  518.     '   ==============================================
  519.     frame = frame + 1
  520.     If frame > 2 Then
  521.         frame = 0
  522.     End If
  523.     If planeX < 0 And bigexploactive = 0 Then
  524.         planeX = 0
  525.     End If
  526.     If planeY < 0 And bigexploactive = 0 Then
  527.         planeY = 0
  528.     End If
  529.     If planeX + width0 > 640 Then
  530.         planeX = 640 - width0
  531.     End If
  532.     If planeY + height0 > 480 - 64 Then
  533.         planeY = 480 - height0 - 64
  534.     End If
  535.     _PutImage (planeX, planeY), img(frame)
  536.  
  537.     '   WE HAVE TO SEE WHAT WE ARE FIGHTING
  538.     '   ===================================
  539.     For x = 0 To 4
  540.         _PutImage (enemyX(x), enemyY(x)), img(frame + 5)
  541.     Next
  542.     For i = 0 To 1
  543.         If enemyshot(i) = 0 Then
  544.             decision(i) = Int(Rnd * 199)
  545.         End If
  546.         If decision(i) = 9 Then
  547.             If enemybulletY(i) < 480 Then
  548.                 enemybulletY(i) = enemybulletY(i) + 10
  549.                 enemyshot(i) = 1
  550.             Else
  551.                 enemybulletX(i) = superenemyX(i) + 14 '1
  552.                 enemybulletY(i) = superenemyY(i) + 17 '7
  553.                 enemyshot(i) = 0
  554.             End If
  555.         Else
  556.             enemybulletX(i) = superenemyX(i) + 14 '1
  557.             enemybulletY(i) = superenemyY(i) + 17 '7
  558.             enemyshot(i) = 0
  559.         End If
  560.         If superenemyY(i) > 0 Then
  561.             _PutImage (enemybulletX(i), enemybulletY(i)), img(27)
  562.         End If
  563.     Next
  564.     For x = 0 To 1
  565.         _PutImage (superenemyX(x), superenemyY(x)), img(frame + 24)
  566.     Next
  567.  
  568.     '   AND WITH WHAT
  569.     '   =============
  570.     For j = 1 To nBullets
  571.         If bullets(j).y > 0 And bullets(j).active Then
  572.             bullets(j).y = bullets(j).y - speed * 2
  573.             _PutImage (bullets(j).x, bullets(j).y), img(3)
  574.         Else
  575.             bullets(j).x = -30
  576.             bullets(j).y = -30
  577.             bullets(j).active = 0
  578.         End If
  579.     Next
  580.  
  581.     '   A NICE EXPLOSION
  582.     '   ================
  583.     If explo_frame < 5 And exploX > 0 Then
  584.         explo_frame = explo_frame + 1
  585.         _PutImage (exploX, exploY), img(explo_frame + 8)
  586.     Else
  587.         explo_frame = 0
  588.         exploX = -30
  589.         exploY = -30
  590.     End If
  591.  
  592.     '   A SECOND NICE EXPLOSION
  593.     '   =======================
  594.     If explo2_frame < 5 And explo2X > 0 Then
  595.         explo2_frame = explo2_frame + 1
  596.         _PutImage (explo2X, explo2Y), img(explo2_frame + 8)
  597.     Else
  598.         explo2_frame = 0
  599.         explo2X = -30
  600.         explo2Y = -30
  601.     End If
  602.  
  603.  
  604.     '   A BIGGER EXPLOSION
  605.     '   ==================
  606.     If bigexploactive = 1 Then
  607.         For s = 0 To 4
  608.             enemyX(s) = Int(Rnd * 608)
  609.             enemyY(s) = 0 - Int(Rnd * 480)
  610.         Next
  611.         For s = 0 To 1
  612.             superenemyX(s) = Int(Rnd * 608)
  613.             superenemyY(s) = 0 - Int(Rnd * 480)
  614.         Next
  615.     End If
  616.     If bigexploX > 0 And bigexploX < 640 Then
  617.         bigexplo_frame = bigexplo_frame + 1
  618.     End If
  619.     If bigexplo_frame > 6 Then
  620.         bigexploactive = 0
  621.         bigexplo_frame = 0
  622.         bigexploX = -70
  623.         bigexploY = -70
  624.         lives = lives - 1
  625.         planeX = 320
  626.         planeY = 480 - 128
  627.         health = 100
  628.     End If
  629.     _PutImage (bigexploX, bigexploY), img(bigexplo_frame + 14)
  630.  
  631.  
  632.     '   Power Ups
  633.  
  634.     '   HEALTH
  635.     '
  636.     If health < 80 Then
  637.         repairActive = 1
  638.     End If
  639.     If repairActive = 1 Then
  640.         _PutImage (repairX, repairY), img(35)
  641.         repairY = repairY + repairSpeed
  642.         If repairY > ymax Then
  643.             repairActive = 0
  644.             repairX = Int(Rnd * 608)
  645.             repairY = 0 - Int(Rnd * 480)
  646.         End If
  647.     End If
  648.     collision planeX, planeY, width0, height0, repairX, repairY, width35, height35
  649.     If hit = 1 Then
  650.         If health < 100 Then
  651.             health = health + 50
  652.             If health > 100 Then health = 100
  653.             repairX = Int(Rnd * 608)
  654.             repairY = 0 - Int(Rnd * 480)
  655.             repairActive = 0
  656.             _SndPlay (pu_health)
  657.         End If
  658.     End If
  659.  
  660.  
  661.     '   AMMUNITION
  662.     '
  663.     If ammo < 90 Then
  664.         ammoActive = 1
  665.     End If
  666.     If ammoActive = 1 Then
  667.         _PutImage (ammoX, ammoY), img(36)
  668.         ammoY = ammoY + ammoSpeed
  669.         If ammoY > ymax Then
  670.             ammoX = Int(Rnd * 608)
  671.             ammoY = 0 - Int(Rnd * 480)
  672.         End If
  673.     End If
  674.     collision planeX, planeY, width0, height0, ammoX, ammoY, width36, height36
  675.     If hit = 1 Then
  676.         If ammo < 90 Then
  677.             ammo = ammo + 10
  678.             ammoX = Int(Rnd * 608)
  679.             ammoY = 0 - Int(Rnd * 480)
  680.             ammoActive = 0
  681.             _SndPlay (pu_ammo)
  682.         End If
  683.     End If
  684.  
  685.  
  686.     '   INFORMATION PANEL
  687.     '   =================
  688.     Line (0, 480 - 63)-Step(640, 63), _RGB32(220, 220, 220), BF
  689.     Line (5, 480 - 58)-Step(635, 58), _RGB32(180, 180, 180), BF
  690.     Line (5, 480 - 58)-Step(630, 58), _RGB32(120, 120, 120), BF
  691.     Line (6, 480 - 22)-Step(103, 12), _RGB32(0, 0, 255), B
  692.     Line (7, 480 - 21)-Step(100, 10), _RGB32(0, 0, 0), B
  693.     c = 50
  694.     For z = 1 To 10
  695.         Line (7, 480 - 22 + z)-(7 + health, 480 - 22 + z), _RGB32(0, c, 0)
  696.         If z > 5 Then
  697.             c = c - 50
  698.         Else
  699.             c = c + 50
  700.         End If
  701.     Next
  702.     _Font arial14
  703.     Color _RGB32(0, 0, 0), trans
  704.     _PrintString (5, 480 - 58), "Score: " + Str$(score)
  705.     _PrintString (5, 480 - 48), "Accuracy: " + Str$(Int((bullseye / shots_fired) * 100)) + "%"
  706.     _PrintString (300, 480 - 48), "Ammo: " + Str$(ammo)
  707.     _PrintString (110, 480 - 22), Str$(health)
  708.     For i = 1 To lives
  709.         _PutImage (120 + i * 32, 480 - 32), img(31)
  710.     Next
  711.     _PutImage (640 - width32, 480 - 58), img(32)
  712.  
  713.     '   IF ALL LIVES ARE GONE, THEN IT`S GAME OVER
  714.     '   =========================================
  715.     If lives < 0 Then
  716.         _PutImage (0, 0), img(34)
  717.         _Display
  718.         _Delay 1
  719.         Exit Do
  720.     End If
  721.  
  722.     '   DRAWING EVERYTHNG AND WAITING
  723.     '   =============================
  724.     '   AND PAUSING THE GAME IF HIS MAJESTY WANTS SO
  725.     '   ============================================
  726.     If InKey$ = "p" Or InKey$ = "P" Then
  727.         _PutImage (0, 0), img(33)
  728.         _Display
  729.         While InKey$ = "": Wend
  730.     End If
  731.  
  732.     _Limit 30
  733.     _Display
  734. goAgain$ = topTenGoAgain$(score)
  735. If Len(goAgain$) = 0 Then GoTo restart
  736.  
  737.  
  738. '=======================================================
  739. Sub collision (r1x, r1y, r1w, r1h, r2x, r2y, r2w, r2h)
  740.     If (r1x + r1w >= r2x And r1x <= r2x + r2w And r1y + r1h >= r2y And r1y <= r2y + r2h) Then
  741.         hit = 1
  742.     Else
  743.         hit = 0
  744.     End If
  745.  
  746. Sub centerText (x1, x2, midy, s$) ' ' if you want to center fit a string between two goal posts x1, and x2
  747.     _PrintString ((x1 + x2) / 2 - _PrintWidth(s$) / 2, midy - _FontHeight(_Font) / 2), s$
  748.  
  749. ' This FUNCTION creates a file in the same folder as your .bas source or .exe
  750. 'EDIT: 2019-07-29 change to FUNCTION to combine Top Ten update functions with Go Again reply.
  751. Function topTenGoAgain$ (compareScore As Integer)
  752.     Dim fName$, n As Integer, names$(1 To 10), scores(1 To 10), name$, score As Integer
  753.     Dim settleScore As Integer, i As Integer, dummy$
  754.     Color &HFFFFFFFF, &HFF000000
  755.  
  756.     fName$ = "Top 10 Scores for 1945.txt" '<<<  since this is toolbox code change this as needed for app
  757.     Cls: Print: Print "Your score was:"; compareScore: Print: Print "Top Ten Scorers and Scores:"
  758.     If _FileExists(fName$) Then
  759.         Open fName$ For Input As #1
  760.         While EOF(1) = 0 And n < 10
  761.             n = n + 1
  762.             Input #1, name$
  763.             Input #1, score
  764.             If compareScore >= score And settleScore = 0 Then
  765.                 Print "You have made the Top Ten!"
  766.                 Input "Type your name here: ", names$(n)
  767.                 scores(n) = compareScore
  768.                 settleScore = -1
  769.                 n = n + 1
  770.                 If n <= 10 Then names$(n) = name$: scores(n) = score
  771.             Else
  772.                 scores(n) = score: names$(n) = name$
  773.             End If
  774.         Wend
  775.         Close #1
  776.         If n < 10 And settleScore = 0 Then
  777.             Print "There is a slot open for your name and score."
  778.             Input "Enter your name here (nothing quits): ", name$
  779.             If name$ <> "" Then
  780.                 n = n + 1: names$(n) = name$: scores(n) = compareScore
  781.             Else
  782.                 System
  783.             End If
  784.         End If
  785.         Open fName$ For Output As #1
  786.         If n > 10 Then n = 10
  787.         For i = 1 To n
  788.             Print #1, names$(i): Print #1, scores(i)
  789.             Print i, names$(i), scores(i)
  790.         Next
  791.         Close #1
  792.     Else
  793.         Print "You are first into file!"
  794.         Input "Enter your name here (nothing quits):"; name$
  795.         If name$ = "" Then System
  796.         Open fName$ For Output As #1
  797.         Print #1, name$: Print #1, compareScore
  798.         Close #1
  799.     End If
  800.     Print: Input "Press Enter to play again, any + Enter to quit... "; dummy$
  801.     topTenGoAgain$ = dummy$
  802.  
  803.  

if glitch wasn't from typo then it may still exist.

I started other mods earlier this afternoon they were wrong minded as i think you are using planeX, planeY for explosion locations but I don't see them so they may not have been saved or done on the last version.

Let me know if you find anything goofy.

EDIT: renew ammo on restart
« Last Edit: December 12, 2021, 05:48:23 pm by bplus »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: 1945
« Reply #34 on: December 14, 2021, 12:15:30 pm »
@johnno56

Any confirmation on that typo I found, did it remove the glitch for you?

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
Re: 1945
« Reply #35 on: December 14, 2021, 07:06:21 pm »
I get an "Invalid Handle" on line 170.
But img(30) is defined as "biglogo.png"

If I use _putimage(0, 0), img(30) it works... The image is the default size and sits in the top left corner. Menu works fine. I cannot understand why the image will not display as 'fullscreen'...
Logic is the beginning of wisdom.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: 1945
« Reply #36 on: December 14, 2021, 07:16:34 pm »
I get an "Invalid Handle" on line 170.
But img(30) is defined as "biglogo.png"

If I use _putimage(0, 0), img(30) it works... The image is the default size and sits in the top left corner. Menu works fine. I cannot understand why the image will not display as 'fullscreen'...

I don't get it, that's been there since your first post???

PS check your PM's


Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
Re: 1945
« Reply #37 on: December 15, 2021, 01:41:26 am »
I believe you... I checked the file/filename the array reference and the command to display it... I just now tested version 4 (it has the same commands etc) and it ran just fine... One thing that I did notice was the command at the top of the program, 'option _explicit' - How does QB64 interpret that command? Just ran the game without that command and it ran just fine... Just as confused as the old farmer who was presented with 3 shovels and told to take his pick...
Logic is the beginning of wisdom.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: 1945
« Reply #38 on: December 15, 2021, 08:37:55 am »
@johnno56

Option _Explicit should only stop you if you use an undeclared (declared with one: DIM, STATIC, REDIM, CONST) variable. No problem commenting out after checking with it on but it should not interfere with runs unless a bug with Linux use???

Option _Explicit caught the typo I am still trying to get you to notice and fix.
explo2X = -30
explo2Y = -30

used at start , but
explox2, exploy2 used later in handling explosions.

1945v6:
Code: QB64: [Select]
  1.     For t = 0 To 1
  2.         '   Collision with player and enemy bullet
  3.         If enemyshot(t) = 1 Then
  4.             collision planex, planey, width0, height0, enemybulletX(t), enemybulletY(t), width27, height27
  5.             If hit = 1 Then
  6.                 health = health - 10
  7.                 If health <= 0 Then
  8.                     bigexploactive = 1
  9.                     bigexplox = planex
  10.                     bigexploy = planey
  11.                     enemybulletX(t) = -30 'had players bullets here!!!
  12.                     enemybulletY(t) = -30
  13.                 End If
  14.                 _SndPlay (explosion)
  15.                 If explox > 0 And explox < 640 Then
  16.                     explox2 = enemybulletX(t)  '<<<<<<<<<<<<<<<<<<<<<
  17.                     exploy2 = enemybulletY(t)  ' <<<<<<<<<<<<<<<<<<
  18.                 Else
  19.                     explox = enemybulletX(t)
  20.                     exploy = enemybulletY(t)
  21.                 End If
  22.                 enemybulletX(t) = superenemyX(t) + 14 '1
  23.                 enemybulletY(t) = superenemyY(t) + 17 '7
  24.                 enemyshot(t) = 0
  25.             End If
  26.         End If
  27.     Next
  28.  

1945v6
Code: QB64: [Select]
  1.     '   A SECOND NICE EXPLOSION
  2.     '   =======================
  3.     If explo2_frame < 5 And explo2x > 0 Then
  4.         explo2_frame = explo2_frame + 1
  5.         _PutImage (explo2x, explo2y), img(explo2_frame + 8)
  6.     Else
  7.         explo2_frame = 0
  8.         explo2x = -30   ' <<<<<<<<<<<<<<<<<<<<<<<
  9.         explo2y = -30  ' <<<<<<<<<<<<<<<<<<<<<<<<<<<<
  10.     End If
  11.