Author Topic: 1945  (Read 2827 times)

0 Members and 1 Guest are viewing this topic.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: 1945
« Reply #15 on: December 07, 2021, 09:52:11 pm »
Here's an example of something I moved around:
Code: QB64: [Select]
  1.     For z = 0 To 1
  2.         superenemyY(z) = superenemyY(z) + speed
  3.         If superenemyY(z) > 480 Then
  4.             superenemyX(z) = Int(Rnd * 608)
  5.             superenemyY(z) = 0 - Int(Rnd * 480)
  6.         End If
  7.     Next
  8.  
  9.  

I changed the position with speed and then I checked where the new location was and if beyond then reassign.

The code before was checking before the move, then doing the move. That could screw things up.

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
Re: 1945
« Reply #16 on: December 07, 2021, 11:34:41 pm »
The problem has been fixed!

I suspected that the problem was with the collision detection parts of the game... obviously...
Trial and error commenting out each detection routine with varying results but no solution.
The problem involved colliding with the white planes, the Super Enemy, so I isolated all the other detection sections (just in case) and ran only with 'collide with superenemy'. Picked it to bits with no joy.

The phrase, "None are as blind as those that do not see", finally sprang to mind.

The solution was within the comment of the section: "Collision with player and superenemy"

Look closely at 'that' section.... In the program you have already installed... The routine 'detects' superenemies but only handles enemies !!

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.  
  5. xmax = 640
  6. ymax = 480
  7. _Title "1945"
  8.  
  9. Screen _NewImage(xmax, ymax, 32)
  10.  
  11. '   ARRAYS
  12. Dim backgroundX(21)
  13. Dim backgroundY(16)
  14. Dim transitionX(21)
  15. Dim transitionY(16)
  16. Dim enemyX(5)
  17. Dim enemyY(5)
  18. Dim superenemyX(5)
  19. Dim superenemyY(5)
  20. Dim decision(2)
  21. Dim enemybulletX(2)
  22. Dim enemybulletY(2)
  23. Dim enemyshot(2)
  24. Dim islandImage(3)
  25. Dim islandX(3)
  26. Dim islandY(3)
  27. Dim img(34)
  28.  
  29.  
  30.  
  31. trans = _RGBA32(0, 0, 0, 0)
  32.  
  33. width0 = 65
  34. height0 = 65
  35. width3 = 9
  36. height3 = 19
  37. width5 = 32
  38. height5 = 32
  39. width27 = 5
  40. height27 = 5
  41. width28 = 94
  42. height28 = 31
  43. width29 = 6
  44. height29 = 11
  45. width30 = 278
  46. height30 = 141
  47. width32 = 115
  48. height32 = 58
  49.  
  50. quit = 0
  51. dead = false
  52. hit = 0
  53.  
  54. '   LOAD ASSETS
  55. '   ===========
  56.  
  57. '   Images
  58. '
  59. img(0) = _LoadImage("data/plane1.png")
  60. img(1) = _LoadImage("data/plane2.png")
  61. img(2) = _LoadImage("data/plane3.png")
  62. img(3) = _LoadImage("data/bullet.png")
  63. img(4) = _LoadImage("data/sea.png")
  64. img(5) = _LoadImage("data/enemy1.png")
  65. img(6) = _LoadImage("data/enemy2.png")
  66. img(7) = _LoadImage("data/enemy3.png")
  67. img(8) = _LoadImage("data/explosion1.png")
  68. img(9) = _LoadImage("data/explosion2.png")
  69. img(10) = _LoadImage("data/explosion3.png")
  70. img(11) = _LoadImage("data/explosion4.png")
  71. img(12) = _LoadImage("data/explosion5.png")
  72. img(13) = _LoadImage("data/explosion6.png")
  73. img(14) = _LoadImage("data/bigexplosion1.png")
  74. img(15) = _LoadImage("data/bigexplosion2.png")
  75. img(16) = _LoadImage("data/bigexplosion3.png")
  76. img(17) = _LoadImage("data/bigexplosion4.png")
  77. img(18) = _LoadImage("data/bigexplosion5.png")
  78. img(19) = _LoadImage("data/bigexplosion6.png")
  79. img(20) = _LoadImage("data/bigexplosion7.png")
  80. img(21) = _LoadImage("data/island1.png")
  81. img(22) = _LoadImage("data/island2.png")
  82. img(23) = _LoadImage("data/island3.png")
  83. img(24) = _LoadImage("data/superenemy1.png")
  84. img(25) = _LoadImage("data/superenemy2.png")
  85. img(26) = _LoadImage("data/superenemy3.png")
  86. img(27) = _LoadImage("data/enemybullet.png")
  87. img(28) = _LoadImage("data/menu.png")
  88. img(29) = _LoadImage("data/arrow.png")
  89. img(30) = _LoadImage("data/biglogo.png")
  90. img(31) = _LoadImage("data/life.png")
  91. img(32) = _LoadImage("data/logo.png")
  92. img(33) = _LoadImage("data/paused.png")
  93. img(34) = _LoadImage("data/gameover.png")
  94.  
  95. '   Sounds
  96. '
  97. shoot = _SndOpen("data/shoot.wav")
  98. explosion = _SndOpen("data/explosion.wav")
  99. collide = _SndOpen("data/collide.wav")
  100. plane_shot = _SndOpen("data/plane_shot.wav")
  101.  
  102. '   Fonts
  103. '
  104. arial14 = _LoadFont("data/arial.ttf", 14)
  105. War60 = _LoadFont("data/armalite.ttf", 60)
  106. War12 = _LoadFont("data/armalite.ttf", 12)
  107.  
  108. '   TILING THE BACKGROUND
  109. '   =====================
  110. 'backgroundX((640 / 32) + 1)
  111. 'backgroundY((480 / 32) + 1)
  112. 'transitionX((640 / 32) + 1)
  113. 'transitionY((480 / 32) + 1)
  114. For i = 0 To 640 / 32
  115.     backgroundX(i) = i * 32
  116.     transitionX(i) = i * 32
  117.     For a = 0 To 480 / 32
  118.         backgroundY(a) = a * 32
  119.         transitionY(a) = a * 32
  120.     Next
  121.  
  122.  
  123. '   A GAME MENU TO START WITH
  124. '   =========================
  125. menu = 0
  126. Color _RGB32(150, 0, 0)
  127.     Cls
  128.  
  129.  
  130.     '_PutImage ((640 - width30) / 2, 5), img(30)
  131.     _PutImage , img(30) ' full screen image
  132.  
  133.     If menu = 0 Then
  134.         _Font War60
  135.         Color _RGB32(255, 255, 255)
  136.         centerText 0, _Width, ymax * .6, "Play Game"
  137.         Color _RGB32(70, 0, 0)
  138.         _Font War12
  139.         centerText 0, _Width, ymax * .6 + 70, "Quit"
  140.     Else
  141.         _Font War12
  142.         Color _RGB32(70, 0, 0)
  143.         centerText 0, _Width, ymax * .6, "Play Game"
  144.         _Font War60
  145.         Color _RGB32(255, 255, 255)
  146.         centerText 0, _Width, ymax * .6 + 70, "Quit"
  147.     End If
  148.  
  149.     '_PutImage ((640 - width28) / 2, height30 + 30), img(28)
  150.     '_PutImage (((640 - width28) / 2) - width29, height30 + (30 + menu * 19)), img(29)
  151.     k& = _KeyHit
  152.     If k& = (18432) Then
  153.         menu = menu - 1
  154.     End If
  155.     If k& = (20480) Then
  156.         menu = menu + 1
  157.     End If
  158.  
  159.     If menu > 1 Then
  160.         menu = 0
  161.     End If
  162.     If menu < 0 Then
  163.         menu = 1
  164.     End If
  165.  
  166.     If _KeyDown(32) And menu = 0 Then
  167.         Exit Do
  168.     End If
  169.     If _KeyDown(32) And menu = 1 Then
  170.         For i = 0 To 640 / 32
  171.             For z = 0 To 480 / 32
  172.                 _PutImage (transitionX(i), transitionY(z)), img(4)
  173.                 _Display
  174.                 _Limit 300
  175.             Next
  176.         Next
  177.         _PutImage (0, 0), img(34)
  178.         _Display
  179.         _Delay 1
  180.         System: 'ExitGame()
  181.     End If
  182.     _Display
  183.     _Limit 20
  184.  
  185. _Font arial14
  186. For i = 0 To 640 / 32
  187.     For z = 0 To 480 / 32
  188.         _PutImage (transitionX(i), transitionY(z)), img(4)
  189.         _Display
  190.         _Delay 0.01
  191.     Next
  192.  
  193. '   INITIALIZING VARIABLES
  194. '   =================================
  195. nBullets = 100
  196. Type bullet
  197.     As Single x, y, dx, dy, active
  198. ReDim bullets(1 To nBullets) As bullet
  199.  
  200. frame = 0
  201. explo_frame = 0
  202. bigexplo_frame = 0
  203. bigexplox = -70
  204. bigexploy = -70
  205. explo2_frame = 0
  206. speed = 6
  207. scrollspeed = 1
  208. planex = 320
  209. planey = 480 - 128
  210. enemyshot(0) = 0
  211. enemyshot(1) = 0
  212. shot = 0
  213. explox = -30
  214. exploy = -30
  215. explo2x = -30
  216. explo2y = -30
  217. score = 0
  218. lives = 3
  219. health = 100
  220. bullseye = 1
  221. shots_fired = 1
  222. bigexploactive = 0
  223.  
  224.  
  225. '   SETTING THE POSITIONS OF THE ENEMY PLANES
  226. '   =========================================
  227. For i = 0 To 4
  228.     enemyX(i) = Int(Rnd * 608)
  229.     enemyY(i) = 0 - Int(Rnd * 480) - 32
  230. For i = 0 To 1
  231.     superenemyX(i) = Int(Rnd * 608)
  232.     superenemyY(i) = 0 - Int(Rnd * 480) - 32
  233.     enemybulletX(i) = superenemyX(i) + 13
  234.     enemybulletY(i) = superenemyY(i) + 17
  235.  
  236. '   SETTING THE POSITIONS AND STARTING IMAGES OF THE ISLANDS
  237. '   ========================================================
  238. For i = 0 To 2
  239.     islandX(i) = Int(Rnd * 576)
  240.     islandY(i) = 0 - Int(Rnd * 480)
  241.     islandImage(i) = img(i + 21)
  242.  
  243. '   THE 'ACTUAL' GAME LOOP
  244. '   ======================
  245.     If quit = 1 Then
  246.         For i = 0 To 640 / 32
  247.             For z = 0 To 480 / 32
  248.                 _PutImage (transitionX(i), transitionY(z)), img(4)
  249.                 _Display
  250.  
  251.             Next
  252.         Next
  253.         _PutImage (0, 0), img(34)
  254.         _Display
  255.         _Delay 1
  256.         Exit Do
  257.     End If
  258.  
  259.     '   CLEARING THE SCREEN
  260.     '   ===================
  261.     Cls
  262.  
  263.     '   MOVING THE PLAYER WITH THE ARROW KEYS
  264.     '   =====================================
  265.     '   OH, AND SHOOTING WITH THE SPACEBAR
  266.     '   ==================================
  267.     If _KeyDown(27) Then
  268.         quit = 1
  269.     End If
  270.     If _KeyDown(18432) Then
  271.         planey = planey - speed
  272.     End If
  273.     If _KeyDown(20480) Then
  274.         planey = planey + 4
  275.     End If
  276.     If _KeyDown(19200) Then
  277.         planex = planex - speed
  278.     End If
  279.     If _KeyDown(19712) Then
  280.         planex = planex + speed
  281.     End If
  282.     If _KeyDown(32) Then
  283.         ' find inactive bullet
  284.         If Timer - lastFire > .4 Then
  285.             For i = 1 To nBullets
  286.                 If bullets(i).active = 0 Then
  287.                     bullets(i).x = planex + 27 ' 17
  288.                     bullets(i).y = planey + 5
  289.                     bullets(i).active = -1
  290.                     _SndPlay (shoot)
  291.                     shots_fired = shots_fired + 1
  292.                     lastFire = Timer(.001)
  293.                     Exit For
  294.                 End If
  295.             Next
  296.         End If
  297.     End If
  298.  
  299.     '   MOVING THE ENEMY PLANES
  300.     '   =======================
  301.     For z = 0 To 4
  302.         If enemyY(z) > 480 Then
  303.             enemyX(z) = Int(Rnd * 608)
  304.             enemyY(z) = 0 - Int(Rnd * 480)
  305.         Else
  306.             enemyY(z) = enemyY(z) + speed
  307.         End If
  308.     Next
  309.     For z = 0 To 1
  310.         If superenemyY(z) > 480 Then
  311.             superenemyX(z) = Int(Rnd * 608)
  312.             superenemyY(z) = 0 - Int(Rnd * 480)
  313.         Else
  314.             superenemyY(z) = superenemyY(z) + speed
  315.         End If
  316.     Next
  317.  
  318.     '   MOVING THE ISLANDS
  319.     '   ==================
  320.     For z = 0 To 2
  321.         If islandY(z) > 480 Then
  322.             islandX(z) = Int(Rnd * 576)
  323.             islandY(z) = 0 - Int(Rnd * 480)
  324.             islandImage(z) = img(Int(Rnd * 3) + 21)
  325.         Else
  326.             islandY(z) = islandY(z) + 3
  327.         End If
  328.     Next
  329.  
  330.     '   CHECKING WHEN WE BEAT OR BEING BEATEN
  331.     '   =====================================
  332.     For t = 0 To 4
  333.         '   Collision with enemy?
  334.         collision planex, planey, width0, height0, enemyX(t), enemyY(t), width5, height5
  335.         If hit = 1 Then
  336.             'collision(r1x, r1y, r1w, r1h, r2x, r2y, r2w, r2h)
  337.             If explox > 0 Then
  338.                 explo2x = enemyX(t)
  339.                 explo2y = enemyY(t)
  340.             Else
  341.                 explox = enemyX(t)
  342.                 exploy = enemyY(t)
  343.             End If
  344.             _SndPlay (explosion)
  345.             enemyX(t) = Int(Rnd * 608)
  346.             enemyY(t) = 0 - Int(Rnd * 480)
  347.             health = health - 25
  348.             If health <= 0 Then
  349.                 bigexploactive = 1
  350.                 bigexplox = planex
  351.                 bigexploy = planey
  352.                 planex = -70
  353.                 planey = -70
  354.             End If
  355.             enemyX(t) = Int(Rnd * 608)
  356.             enemyY(t) = 0 - Int(Rnd * 480)
  357.         End If
  358.  
  359.  
  360.         'If shot = 1 Then
  361.         For i = 1 To nBullets
  362.             '   Collision with player bullet and enemy
  363.             collision bullets(i).x, bullets(i).y, width3, height3, enemyX(t), enemyY(t), width5, height5
  364.             If hit = 1 Then
  365.                 If explox > 0 Then
  366.                     explo2x = enemyX(t)
  367.                     explo2y = enemyY(t)
  368.                 Else
  369.                     explox = enemyX(t)
  370.                     exploy = enemyY(t)
  371.                 End If
  372.                 _SndPlay (explosion)
  373.                 enemyX(t) = Int(Rnd * 608)
  374.                 enemyY(t) = 0 - Int(Rnd * 480)
  375.                 bullets(i).x = -30
  376.                 bullets(i).y = -30
  377.                 bullets(i).active = 0
  378.                 score = score + 50
  379.                 bullseye = bullseye + 1
  380.             End If
  381.             'End If
  382.         Next
  383.     Next
  384.     For t = 0 To 1
  385.         '   Collision with player and superenemy  <<==========
  386.         collision planex, planey, width0, height0, superenemyX(t), superenemyY(t), width5, height5
  387.         If hit = 1 Then
  388.             If explox > 0 Then
  389.                 explo2x = superenemyX(t) ' <<======
  390.                 explo2y = superenemyY(t) ' <<======
  391.             Else
  392.                 explox = enemyX(t)
  393.                 exploy = enemyY(t)
  394.             End If
  395.             _SndPlay (explosion)
  396.             superenemyX(t) = Int(Rnd * 608) ' <<======
  397.             superenemyY(t) = 0 - Int(Rnd * 480) ' <<======
  398.             health = health - 25
  399.             If health <= 0 Then
  400.                 bigexploactive = 1
  401.                 bigexplox = planex
  402.                 bigexploy = planey
  403.                 planex = -70
  404.                 planey = -70
  405.             End If
  406.             superenemyX(t) = Int(Rnd * 608) ' <<======
  407.             superenemyY(t) = 0 - Int(Rnd * 480) ' <<======
  408.         End If
  409.  
  410.  
  411.         '   Collision with player bullet and superenemy
  412.         For i = 1 To nBullets
  413.             collision bullets(i).x, bullets(i).y, width3, height3, superenemyX(t), superenemyY(t), width5, height5
  414.             If hit = 1 Then
  415.                 If explox > 0 Then
  416.                     explo2x = superenemyX(t)
  417.                     explo2y = superenemyY(t)
  418.                 Else
  419.                     explox = superenemyX(t)
  420.                     exploy = superenemyY(t)
  421.                 End If
  422.                 _SndPlay (explosion)
  423.                 superenemyX(t) = Int(Rnd * 608)
  424.                 superenemyY(t) = 0 - Int(Rnd * 480)
  425.                 bullets(i).x = -30
  426.                 bullets(i).y = -30
  427.                 bullets(i).active = 0
  428.                 score = score + 100
  429.                 bullseye = bullseye + 1
  430.             End If
  431.         Next
  432.     Next
  433.     For t = 0 To 1
  434.         '   Collision with player and enemy bullet
  435.         If enemyshot(t) = 1 Then
  436.             collision planex, planey, width0, height0, enemybulletX(t), enemybulletY(t), width27, height27
  437.             If hit = 1 Then
  438.                 health = health - 10
  439.                 If health <= 0 Then
  440.                     bigexploactive = 1
  441.                     bigexplox = planex
  442.                     bigexploy = planey
  443.                     enemybulletX(t) = -30 'had players bullets here!!!
  444.                     enemybulletY(t) = -30
  445.                 End If
  446.                 _SndPlay (explosion)
  447.                 If explox > 0 And explox < 640 Then
  448.                     explox2 = enemybulletX(t)
  449.                     exploy2 = enemybulletY(t)
  450.                 Else
  451.                     explox = enemybulletX(t)
  452.                     exploy = enemybulletY(t)
  453.                 End If
  454.                 enemybulletX(t) = superenemyX(t) + 14 '1
  455.                 enemybulletY(t) = superenemyY(t) + 17 '7
  456.                 enemyshot(t) = 0
  457.             End If
  458.         End If
  459.     Next
  460.  
  461.     '   FLYING OVER THE ENDLESSLY SCROLLING SEA
  462.     '   =======================================
  463.     For w = 0 To 15
  464.         backgroundY(w) = backgroundY(w) + 3
  465.         If backgroundY(w) > 480 Then
  466.             backgroundY(w) = backgroundY(w) - 512
  467.         End If
  468.         For q = 0 To 19
  469.             _PutImage (backgroundX(q), backgroundY(w)), img(4)
  470.         Next
  471.     Next
  472.  
  473.     '   WHICH LOOKS DULL WITHOUT ISLANDS
  474.     '   ================================
  475.     For o = 0 To 2
  476.         _PutImage (islandX(o), islandY(o)), islandImage(o)
  477.     Next
  478.  
  479.     '   KEEPING OUR PLANE IN THE SCREEN AND DISPLAY IT
  480.     '   ==============================================
  481.     frame = frame + 1
  482.     If frame > 2 Then
  483.         frame = 0
  484.     End If
  485.     If planex < 0 And bigexploactive = 0 Then
  486.         planex = 0
  487.     End If
  488.     If planey < 0 And bigexploactive = 0 Then
  489.         planey = 0
  490.     End If
  491.     If planex + width0 > 640 Then
  492.         planex = 640 - width0
  493.     End If
  494.     If planey + height0 > 480 - 64 Then
  495.         planey = 480 - height0 - 64
  496.     End If
  497.     _PutImage (planex, planey), img(frame)
  498.  
  499.     '   WE HAVE TO SEE WHAT WE ARE FIGHTING
  500.     '   ===================================
  501.     For x = 0 To 4
  502.         _PutImage (enemyX(x), enemyY(x)), img(frame + 5)
  503.     Next
  504.     For i = 0 To 1
  505.         If enemyshot(i) = 0 Then
  506.             decision(i) = Int(Rnd * 199)
  507.         End If
  508.         If decision(i) = 9 Then
  509.             If enemybulletY(i) < 480 Then
  510.                 enemybulletY(i) = enemybulletY(i) + 10
  511.                 enemyshot(i) = 1
  512.             Else
  513.                 enemybulletX(i) = superenemyX(i) + 14 '1
  514.                 enemybulletY(i) = superenemyY(i) + 17 '7
  515.                 enemyshot(i) = 0
  516.             End If
  517.         Else
  518.             enemybulletX(i) = superenemyX(i) + 14 '1
  519.             enemybulletY(i) = superenemyY(i) + 17 '7
  520.             enemyshot(i) = 0
  521.         End If
  522.         If superenemyY(i) > 0 Then
  523.             _PutImage (enemybulletX(i), enemybulletY(i)), img(27)
  524.         End If
  525.     Next
  526.     For x = 0 To 1
  527.         _PutImage (superenemyX(x), superenemyY(x)), img(frame + 24)
  528.     Next
  529.  
  530.     '   AND WITH WHAT
  531.     '   =============
  532.     For j = 1 To nBullets
  533.         If bullets(j).y > 0 And bullets(j).active Then
  534.             bullets(j).y = bullets(j).y - speed * 2
  535.             _PutImage (bullets(j).x, bullets(j).y), img(3)
  536.         Else
  537.             bullets(j).x = -30
  538.             bullets(j).y = -30
  539.             bullets(j).active = 0
  540.         End If
  541.     Next
  542.  
  543.     '   A NICE EXPLOSION
  544.     '   ================
  545.     If explo_frame < 5 And explox > 0 Then
  546.         explo_frame = explo_frame + 1
  547.         _PutImage (explox, exploy), img(explo_frame + 8)
  548.     Else
  549.         explo_frame = 0
  550.         explox = -30
  551.         exploy = -30
  552.     End If
  553.  
  554.     '   A SECOND NICE EXPLOSION
  555.     '   =======================
  556.     If explo2_frame < 5 And explo2x > 0 Then
  557.         explo2_frame = explo2_frame + 1
  558.         _PutImage (explo2x, explo2y), img(explo2_frame + 8)
  559.     Else
  560.         explo2_frame = 0
  561.         explo2x = -30
  562.         explo2y = -30
  563.     End If
  564.  
  565.  
  566.     '   A BIGGER EXPLOSION
  567.     '   ==================
  568.     If bigexploactive = 1 Then
  569.         For s = 0 To 4
  570.             enemyX(s) = Int(Rnd * 608)
  571.             enemyY(s) = 0 - Int(Rnd * 480)
  572.         Next
  573.         For s = 0 To 1
  574.             superenemyX(s) = Int(Rnd * 608)
  575.             superenemyY(s) = 0 - Int(Rnd * 480)
  576.         Next
  577.     End If
  578.     If bigexplox > 0 And bigexplox < 640 Then
  579.         bigexplo_frame = bigexplo_frame + 1
  580.     End If
  581.     If bigexplo_frame > 6 Then
  582.         bigexploactive = 0
  583.         bigexplo_frame = 0
  584.         bigexplox = -70
  585.         bigexploy = -70
  586.         lives = lives - 1
  587.         planex = 320
  588.         planey = 480 - 128
  589.         health = 100
  590.     End If
  591.     _PutImage (bigexplox, bigexploy), img(bigexplo_frame + 14)
  592.  
  593.     '   INFORMATION PANEL
  594.     '   =================
  595.     Line (0, 480 - 63)-Step(640, 63), _RGB32(220, 220, 220), BF
  596.     Line (5, 480 - 58)-Step(635, 58), _RGB32(180, 180, 180), BF
  597.     Line (5, 480 - 58)-Step(630, 58), _RGB32(120, 120, 120), BF
  598.     Line (6, 480 - 22)-Step(103, 12), _RGB32(0, 0, 255), B
  599.     Line (7, 480 - 21)-Step(100, 10), _RGB32(0, 0, 0), B
  600.     c = 143
  601.     For z = 1 To 10
  602.         Line (7, 480 - 22 + z)-(7 + health, 480 - 22 + z), _RGB32(255, c, 0)
  603.         If z > 5 Then
  604.             c = c - 44
  605.         Else
  606.             c = c + 44
  607.         End If
  608.     Next
  609.     _Font arial14
  610.     Color _RGB32(0, 0, 0), trans
  611.     _PrintString (5, 480 - 58), "Score: " + Str$(score)
  612.     _PrintString (5, 480 - 48), "Accuracy: " + Str$((bullseye / shots_fired) * 100) + "%"
  613.     For i = 1 To lives
  614.         _PutImage (120 + i * 32, 480 - 32), img(31)
  615.     Next
  616.     _PutImage (640 - width32, 480 - 58), img(32)
  617.  
  618.     '   IF ALL LIVES ARE GONE, THEN IT`S GAME OVER
  619.     '   =========================================
  620.     If lives < 0 Then
  621.         _PutImage (0, 0), img(34)
  622.         _Display
  623.         _Delay 1
  624.         System
  625.     End If
  626.  
  627.     '   DRAWING EVERYTHNG AND WAITING
  628.     '   =============================
  629.     '   AND PAUSING THE GAME IF HIS MAJESTY WANTS SO
  630.     '   ============================================
  631.     If InKey$ = "p" Or InKey$ = "P" Then
  632.         _PutImage (0, 0), img(33)
  633.         _Display
  634.         While InKey$ = "": Wend
  635.     End If
  636.  
  637.     _Limit 30
  638.     _Display
  639.  
  640.  
  641.  
  642.  
  643.  
  644. '=======================================================
  645. Sub collision (r1x, r1y, r1w, r1h, r2x, r2y, r2w, r2h)
  646.     If (r1x + r1w >= r2x And r1x <= r2x + r2w And r1y + r1h >= r2y And r1y <= r2y + r2h) Then
  647.         hit = 1
  648.     Else
  649.         hit = 0
  650.     End If
  651.  
  652. Sub centerText (x1, x2, midy, s$) ' ' if you want to center fit a string between two goal posts x1, and x2
  653.     _PrintString ((x1 + x2) / 2 - _PrintWidth(s$) / 2, midy - _FontHeight(_Font) / 2), s$
  654.  
  655.  
Logic is the beginning of wisdom.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: 1945
« Reply #17 on: December 07, 2021, 11:42:48 pm »
Ah I see it, shouldn't 406 and 407 be changed also to SuperEnemies?

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
Re: 1945
« Reply #18 on: December 07, 2021, 11:58:34 pm »
Well spotted. Remind me to give you a Gold Star as you move to the top of the class.... lol
Logic is the beginning of wisdom.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: 1945
« Reply #19 on: December 08, 2021, 12:01:23 am »
Yeah give yourself one too, these things so easy to overlook.

Ding dong, the glitch is dead!

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
Re: 1945
« Reply #20 on: December 08, 2021, 12:06:16 am »
What was happening was that the Super Enemy would continue to move 'through' the player. Subtracting 25% health through every cycle. The program, detecting that the health has dropped below zero, resets all the 'enemy' and the player. Instead of resetting only the Super Enemy.

But what surprises me, is that, this existed in the original Naalaa version. I am no where near as clever as those guys yet I picked it up. Mind you, it took me ages to find it... lol

Anyway. Nuff said. Time for a coffee before I think about power ups...
Logic is the beginning of wisdom.

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
Re: 1945
« Reply #21 on: December 08, 2021, 05:24:59 am »
Bplus

Ok. I have simple health and ammo power/pick ups. How many rounds of ammo do you think is fair to start with and at what figure do you think the ammo should drop to before pickup and how many rounds should be added?

Rare pickups... Extra life; Bonus score; etc... anything else?

I was also toying with the idea of slightly increasing the speed of all enemy planes in relation to the score but keeping the power up speeds fixed on slow... Moo ha ha...

A high score table could be an option. That would mean a change to the main menu... and just after it has been fixed so well....
Logic is the beginning of wisdom.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: 1945
« Reply #22 on: December 08, 2021, 08:24:54 am »
Yeah I was thinking High Score Keeper also. I have some code for that and we can pop in the Player log-in at start pretty easily too.

Higher levels the enemy should start attacking the plane's position, Zero in on it so to speak!

Did you say you had ships and subs and bombs?

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
Re: 1945
« Reply #23 on: December 08, 2021, 04:32:29 pm »
Ships; Subs; Bombs; Flying Fortresses; Torpedo Planes (obviously for the Ships and Subs) and a bunch of other stuff I have never seen before... lol

So, the short answer is , yes.

 
1945_sprites.jpg
Logic is the beginning of wisdom.

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
Re: 1945
« Reply #24 on: December 11, 2021, 03:13:55 am »
Ok. Here is a small update.

The game now includes power-ups for health and ammunition. After Health and Ammunition drop below a certain amount, the appropriate icon will "slowly" move down the screen. Icon 'must' be in contact with the player to register. If you have a better, or more efficient method, be my guest... Ignore the collection sound effects. I just grabbed what I had at hand... If you have a better set of sounds, I insist, that you replace them... lol

J

 
Logic is the beginning of wisdom.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: 1945
« Reply #25 on: December 11, 2021, 11:02:16 am »
OK to tie shooting in with ammo status you need this:
Code: QB64: [Select]
  1.     If _KeyDown(32) Then
  2.         ' find inactive bullet
  3.         If Timer - lastFire > .4 And ammo > 0 Then   ' <<<< check if you have ammo before starting another bullet
  4.             For i = 1 To nBullets
  5.                 If bullets(i).active = 0 Then
  6.                     bullets(i).x = planex + 27 ' 17
  7.                     bullets(i).y = planey + 5
  8.                     bullets(i).active = -1
  9.                     _SndPlay (shoot)
  10.                     shots_fired = shots_fired + 1
  11.                     ammo = ammo - 1
  12.                     lastFire = Timer(.001)
  13.                     Exit For
  14.                 End If
  15.             Next
  16.         End If
  17.     End If
  18.  

Offline bplus

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

I ran into that glitch again while testing code plus when you exit with End or System you just hang with a black screen until you hit a key.

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
Re: 1945
« Reply #27 on: December 12, 2021, 05:37:39 am »
I ran into the same glitch.

I was trying to refine the 'hit boxes' of the images... Tested by drawing a box around all the sprites. Found some collision area were a little too generous. But, what I did notice, was the enemy bullets were showing up at the very top of the screen then vanished.

About line #564  "If superenemyY(i) > 0 then" was changed to "If superenemyY(i) > 0 and enemyshot(i) then"

I have played many times since and the glitch no longer appears. I do not know if the above fix has soled the problem or I was just extremely lucky by not repeating the condition that may have caused said glitch.

In refining the hit boxes, some data and images were modified.

J

 
Logic is the beginning of wisdom.

Offline Aurel

  • Forum Regular
  • Posts: 167
Re: 1945
« Reply #28 on: December 12, 2021, 01:30:07 pm »
hi johnno B++

I just download your zip and compile with v1.5
at first game not respond then i figured that is started without data folder
then i add data folder in same folder where is created exe and voila game start...
well ...looking strange at first because it is in full screen (i remember versions in windowed mode)
this one work very well...
//////////////////////////////////////////////////////////////////
https://aurelsoft.ucoz.com
https://www.facebook.com/groups/470369984111370
//////////////////////////////////////////////////////////////////

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: 1945
« Reply #29 on: December 12, 2021, 02:00:13 pm »
Yikes glitch on first run of v5. The Health was -35 and our plane was gone and line on top had all kinds of flashes of planes displayed and gone. Moving left and right maybe up, down, I jiggled the thing onto next plane life and was able to continue game from there.