Author Topic: 1945  (Read 2829 times)

0 Members and 1 Guest are viewing this topic.

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
1945
« on: December 06, 2021, 02:25:21 pm »
Bplus,

Here is the QB64 conversion of Naalaa's 1945. It is not optimised. Just concentrated on getting to work. I have also included the '1945.txt' Naalaa listing as well. No. Your 'Accuracy' text formatting has not been applied... lol

Let me know what you think? Suggestions for improvement are always appreciated... and in my case, expected... lol

J
 


Logic is the beginning of wisdom.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: 1945
« Reply #1 on: December 06, 2021, 03:35:20 pm »
@johnno56  Cool! I'll give it the old look see.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: 1945
« Reply #2 on: December 06, 2021, 04:48:02 pm »
Every once and awhile I loose my plane and the new planes coming down just flash for moment and disappear while the ocean continues down as normal? Not sure what causes problem but some games play normal.

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

That War font is excellent so I made use of it in Open Splash / Menu.

A very nice translation from Naalaa, nice start!

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
Re: 1945
« Reply #3 on: December 07, 2021, 02:13:01 am »
Cool menu. I like it.

"Nice start"? Are you possibly thinking of power-ups etc?

I have the complete sprite sheet of the game. There are LOTS of stuff that the basic Naalaa version did not include... eg: Multi-directional weapons; Submarines; Ships; POW; Flying fortress-type enemies; High Score system... Maybe add repair power up; extra life; (not sure about ammunition - that would require that ammo was limited to start with)

Food for thought...
Logic is the beginning of wisdom.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: 1945
« Reply #4 on: December 07, 2021, 08:13:15 am »
Yeah, waiting for bullet to hit top of screen before can shoot another is a bit boring.

I would say that is next thing to get going before adding more stuff plus of course the fix to whatever is causing the loss of the plane images occasionally.
« Last Edit: December 07, 2021, 08:24:26 am by bplus »

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
Re: 1945
« Reply #5 on: December 07, 2021, 01:55:40 pm »
Slow bullets? Boring? It is meant to be slow or boring. One of the power-ups is faster bullets. (obviously not implemented - either because of time constraints or lack of know-how or just getting the game to work). In the meantime, I will create faster bullets... *sigh*

I also noticed that "glitch" as well. It happens only when the play collides with the white planes. Shooting them is fine. It also happens in the RCBasic version... I will look into it... In the meantime, 'shoot' the white planes... lol
Logic is the beginning of wisdom.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: 1945
« Reply #6 on: December 07, 2021, 02:05:14 pm »
No not slow bullets, one bullet is what is boring. Having to wait for the one bullet to reach the top of the screen before another bullet can shoot is what I am talking about.

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
Re: 1945
« Reply #7 on: December 07, 2021, 02:11:27 pm »
Temporary bullet speed fix: On or about line #531 within the section "and with what"... change 'bullety = bullety - speed * 2' to 'bullety = bullety - 25'

Originally the bullet speed was set to '6'

In regards to the 'glitch'... The same thing happens when running the Naalaa version... Looks like the conversion was a little 'too' accurate... lol
Logic is the beginning of wisdom.

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
Re: 1945
« Reply #8 on: December 07, 2021, 02:16:10 pm »
Multiple bullets? As there is no real 'challenge' by 'spraying' bullets at the enemy, an ammunition system would need to be implemented, so that the player does not just hold the space bar down 'ad infinitum'... Moo ha ha... (no more lessons in Latin...)
Logic is the beginning of wisdom.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: 1945
« Reply #9 on: December 07, 2021, 03:33:52 pm »
Multiple bullets but a .4 sec wait for next bullet activation, so you have to be a little accurate:
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 = enemyX(t)
  390.                 explo2y = enemyY(t)
  391.             Else
  392.                 explox = enemyX(t)
  393.                 exploy = enemyY(t)
  394.             End If
  395.             _SndPlay (explosion)
  396.             enemyX(t) = Int(Rnd * 608)
  397.             enemyY(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.             enemyX(t) = Int(Rnd * 608)
  407.             enemyY(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.  
  433.  
  434.     Next
  435.     For t = 0 To 1
  436.         '   Collision with player and enemy bullet
  437.         If enemyshot(t) = 1 Then
  438.             collision planex, planey, width0, height0, enemybulletX(t), enemybulletY(t), width27, height27
  439.             If hit = 1 Then
  440.                 health = health - 10
  441.                 If health <= 0 Then
  442.                     bigexploactive = 1
  443.                     bigexplox = planex
  444.                     bigexploy = planey
  445.                     enemybulletX(t) = -30 'had players bullets here!!!
  446.                     enemybulletY(t) = -30
  447.                 End If
  448.                 _SndPlay (explosion)
  449.                 If explox > 0 And explox < 640 Then
  450.                     explox2 = enemybulletX(t)
  451.                     exploy2 = enemybulletY(t)
  452.                 Else
  453.                     explox = enemybulletX(t)
  454.                     exploy = enemybulletY(t)
  455.                 End If
  456.                 enemybulletX(t) = superenemyX(t) + 14 '1
  457.                 enemybulletY(t) = superenemyY(t) + 17 '7
  458.                 enemyshot(t) = 0
  459.             End If
  460.         End If
  461.     Next
  462.  
  463.     '   FLYING OVER THE ENDLESSLY SCROLLING SEA
  464.     '   =======================================
  465.     For w = 0 To 15
  466.         backgroundY(w) = backgroundY(w) + 3
  467.         If backgroundY(w) > 480 Then
  468.             backgroundY(w) = backgroundY(w) - 512
  469.         End If
  470.         For q = 0 To 19
  471.             _PutImage (backgroundX(q), backgroundY(w)), img(4)
  472.         Next
  473.     Next
  474.  
  475.     '   WHICH LOOKS DULL WITHOUT ISLANDS
  476.     '   ================================
  477.     For o = 0 To 2
  478.         _PutImage (islandX(o), islandY(o)), islandImage(o)
  479.     Next
  480.  
  481.     '   KEEPING OUR PLANE IN THE SCREEN AND DISPLAY IT
  482.     '   ==============================================
  483.     frame = frame + 1
  484.     If frame > 2 Then
  485.         frame = 0
  486.     End If
  487.     If planex < 0 And bigexploactive = 0 Then
  488.         planex = 0
  489.     End If
  490.     If planey < 0 And bigexploactive = 0 Then
  491.         planey = 0
  492.     End If
  493.     If planex + width0 > 640 Then
  494.         planex = 640 - width0
  495.     End If
  496.     If planey + height0 > 480 - 64 Then
  497.         planey = 480 - height0 - 64
  498.     End If
  499.     _PutImage (planex, planey), img(frame)
  500.  
  501.     '   WE HAVE TO SEE WHAT WE ARE FIGHTING
  502.     '   ===================================
  503.     For x = 0 To 4
  504.         _PutImage (enemyX(x), enemyY(x)), img(frame + 5)
  505.     Next
  506.     For i = 0 To 1
  507.         If enemyshot(i) = 0 Then
  508.             decision(i) = Int(Rnd * 199)
  509.         End If
  510.         If decision(i) = 9 Then
  511.             If enemybulletY(i) < 480 Then
  512.                 enemybulletY(i) = enemybulletY(i) + 10
  513.                 enemyshot(i) = 1
  514.             Else
  515.                 enemybulletX(i) = superenemyX(i) + 14 '1
  516.                 enemybulletY(i) = superenemyY(i) + 17 '7
  517.                 enemyshot(i) = 0
  518.             End If
  519.         Else
  520.             enemybulletX(i) = superenemyX(i) + 14 '1
  521.             enemybulletY(i) = superenemyY(i) + 17 '7
  522.             enemyshot(i) = 0
  523.         End If
  524.         If superenemyY(i) > 0 Then
  525.             _PutImage (enemybulletX(i), enemybulletY(i)), img(27)
  526.         End If
  527.     Next
  528.     For x = 0 To 1
  529.         _PutImage (superenemyX(x), superenemyY(x)), img(frame + 24)
  530.     Next
  531.  
  532.  
  533.  
  534.     '   AND WITH WHAT
  535.     '   =============
  536.     For j = 1 To nBullets
  537.         If bullets(j).y > 0 And bullets(j).active Then
  538.             bullets(j).y = bullets(j).y - speed * 2
  539.             _PutImage (bullets(j).x, bullets(j).y), img(3)
  540.         Else
  541.             bullets(j).x = -30
  542.             bullets(j).y = -30
  543.             bullets(j).active = 0
  544.         End If
  545.     Next
  546.  
  547.  
  548.  
  549.  
  550.     '   A NICE EXPLOSION
  551.     '   ================
  552.     If explo_frame < 5 And explox > 0 Then
  553.         explo_frame = explo_frame + 1
  554.         _PutImage (explox, exploy), img(explo_frame + 8)
  555.     Else
  556.         explo_frame = 0
  557.         explox = -30
  558.         exploy = -30
  559.     End If
  560.  
  561.  
  562.     '   A SECOND NICE EXPLOSION
  563.     '   =======================
  564.     If explo2_frame < 5 And explo2x > 0 Then
  565.         explo2_frame = explo2_frame + 1
  566.         _PutImage (explo2x, explo2y), img(explo2_frame + 8)
  567.     Else
  568.         explo2_frame = 0
  569.         explo2x = -30
  570.         explo2y = -30
  571.     End If
  572.  
  573.  
  574.     '   A BIGGER EXPLOSION
  575.     '   ==================
  576.     If bigexploactive = 1 Then
  577.         For s = 0 To 4
  578.             enemyX(s) = Int(Rnd * 608)
  579.             enemyY(s) = 0 - Int(Rnd * 480)
  580.         Next
  581.         For s = 0 To 1
  582.             superenemyX(s) = Int(Rnd * 608)
  583.             superenemyY(s) = 0 - Int(Rnd * 480)
  584.         Next
  585.     End If
  586.     If bigexplox > 0 And bigexplox < 640 Then
  587.         bigexplo_frame = bigexplo_frame + 1
  588.     End If
  589.     If bigexplo_frame > 6 Then
  590.         bigexploactive = 0
  591.         bigexplo_frame = 0
  592.         bigexplox = -70
  593.         bigexploy = -70
  594.         lives = lives - 1
  595.         planex = 320
  596.         planey = 480 - 128
  597.         health = 100
  598.     End If
  599.     _PutImage (bigexplox, bigexploy), img(bigexplo_frame + 14)
  600.  
  601.     '   INFORMATION PANEL
  602.     '   =================
  603.     Line (0, 480 - 63)-Step(640, 63), _RGB32(220, 220, 220), BF
  604.     Line (5, 480 - 58)-Step(635, 58), _RGB32(180, 180, 180), BF
  605.     Line (5, 480 - 58)-Step(630, 58), _RGB32(120, 120, 120), BF
  606.     Line (6, 480 - 22)-Step(103, 12), _RGB32(0, 0, 255), B
  607.     Line (7, 480 - 21)-Step(100, 10), _RGB32(0, 0, 0), B
  608.     c = 143
  609.     For z = 1 To 10
  610.         Line (7, 480 - 22 + z)-(7 + health, 480 - 22 + z), _RGB32(255, c, 0)
  611.         If z > 5 Then
  612.             c = c - 44
  613.         Else
  614.             c = c + 44
  615.         End If
  616.     Next
  617.     _Font arial14
  618.     Color _RGB32(0, 0, 0), trans
  619.     _PrintString (5, 480 - 58), "Score: " + Str$(score)
  620.     _PrintString (5, 480 - 48), "Accuracy: " + Str$((bullseye / shots_fired) * 100) + "%"
  621.     For i = 1 To lives
  622.         _PutImage (120 + i * 32, 480 - 32), img(31)
  623.     Next
  624.     _PutImage (640 - width32, 480 - 58), img(32)
  625.  
  626.     '   IF ALL LIVES ARE GONE, THEN IT`S GAME OVER
  627.     '   =========================================
  628.     If lives < 0 Then
  629.         _PutImage (0, 0), img(34)
  630.         _Display
  631.         _Delay 1
  632.         System
  633.     End If
  634.  
  635.     '   DRAWING EVERYTHNG AND WAITING
  636.     '   =============================
  637.     '   AND PAUSING THE GAME IF HIS MAJESTY WANTS SO
  638.     '   ============================================
  639.     If InKey$ = "p" Or InKey$ = "P" Then
  640.         _PutImage (0, 0), img(33)
  641.         _Display
  642.         While InKey$ = "": Wend
  643.     End If
  644.  
  645.     _Limit 30
  646.     _Display
  647.  
  648.  
  649.  
  650.  
  651.  
  652. '=======================================================
  653. Sub collision (r1x, r1y, r1w, r1h, r2x, r2y, r2w, r2h)
  654.     If (r1x + r1w >= r2x And r1x <= r2x + r2w And r1y + r1h >= r2y And r1y <= r2y + r2h) Then
  655.         hit = 1
  656.     Else
  657.         hit = 0
  658.     End If
  659.  
  660. Sub centerText (x1, x2, midy, s$) ' ' if you want to center fit a string between two goal posts x1, and x2
  661.     _PrintString ((x1 + x2) / 2 - _PrintWidth(s$) / 2, midy - _FontHeight(_Font) / 2), s$
  662.  
  663.  

PS I may have fixed glitch, fixed something because you had place where it should have been enemy bullet but had player bullet instead.
« Last Edit: December 07, 2021, 03:41:51 pm by bplus »

Offline George McGinn

  • Global Moderator
  • Forum Regular
  • Posts: 210
    • Resume
Re: 1945
« Reply #10 on: December 07, 2021, 05:55:40 pm »
I like this game. Thanks.
____________________________________________________________________
George McGinn
Theoretical/Applied Computer Scientist
Member: IEEE, IEEE Computer Society
Technical Council on Software Engineering
IEEE Standards Association
American Association for the Advancement of Science (AAAS)

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
Re: 1945
« Reply #11 on: December 07, 2021, 06:50:55 pm »
Thanks George... But it is not 'my' work. Created by the guys at Naalaa. I only did a 'convert'.

Bplus: There was a game, not sure if it was a top-down shooter for pygame or not, but the player, by default, used a gun that fired one bullet at a time... admittedly, there was a delay between shots, but still single-shot. Picking up a machine-gun, increased the firing rate, but because of the recoil, accuracy was sacrificed... Food for thought

Were did you find the "random feature" involving enemy bullets? Because crashing into the white plane still causes all planes to vanish...
Logic is the beginning of wisdom.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: 1945
« Reply #12 on: December 07, 2021, 06:55:24 pm »
@johnno56

Lines 459, 460 in last post, I marked the place with a comment. It was not random feature, it was the wrong bullet, instead of enemy bullet you had the player's bullet. This is right after doing a collision test with player plane and enemy  bullet, so clearly enemy bullets were meant to be reassigned.

So it's crashing into white plane, no did not catch that. That's good intell, now we have places to check.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: 1945
« Reply #13 on: December 07, 2021, 07:53:52 pm »
Moved some stuff around, haven't been able to replicate the glitch even purposely crashing into white planes!

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.         enemyY(z) = enemyY(z) + speed
  303.         If enemyY(z) > 480 Then
  304.             enemyX(z) = Int(Rnd * 608)
  305.             enemyY(z) = 0 - Int(Rnd * 480)
  306.         End If
  307.     Next
  308.     For z = 0 To 1
  309.         superenemyY(z) = superenemyY(z) + speed
  310.         If superenemyY(z) > 480 Then
  311.             superenemyX(z) = Int(Rnd * 608)
  312.             superenemyY(z) = 0 - Int(Rnd * 480)
  313.         End If
  314.     Next
  315.  
  316.     '   MOVING THE ISLANDS
  317.     '   ==================
  318.     For z = 0 To 2
  319.         islandY(z) = islandY(z) + 3
  320.         If islandY(z) > 480 Then
  321.             islandX(z) = Int(Rnd * 576)
  322.             islandY(z) = 0 - Int(Rnd * 480)
  323.             islandImage(z) = img(Int(Rnd * 3) + 21)
  324.         End If
  325.     Next
  326.  
  327.     '   CHECKING WHEN WE BEAT OR BEING BEATEN
  328.     '   =====================================
  329.     For t = 0 To 4
  330.         '   Collision with enemy?
  331.         collision planex, planey, width0, height0, enemyX(t), enemyY(t), width5, height5
  332.         If hit = 1 Then
  333.             'collision(r1x, r1y, r1w, r1h, r2x, r2y, r2w, r2h)
  334.             If explox > 0 Then
  335.                 explo2x = enemyX(t)
  336.                 explo2y = enemyY(t)
  337.             Else
  338.                 explox = enemyX(t)
  339.                 exploy = enemyY(t)
  340.             End If
  341.             _SndPlay (explosion)
  342.             enemyX(t) = Int(Rnd * 608)
  343.             enemyY(t) = 0 - Int(Rnd * 480)
  344.             health = health - 25
  345.             If health <= 0 Then
  346.                 bigexploactive = 1
  347.                 bigexplox = planex
  348.                 bigexploy = planey
  349.                 planex = -70 '>>>>>>>>>>>>>>>>>>>>>>> this could disappear the plane !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  350.                 planey = -70
  351.             End If
  352.             'enemyX(t) = Int(Rnd * 608)         ' you have this twice???????????????
  353.             'enemyY(t) = 0 - Int(Rnd * 480)
  354.         End If
  355.  
  356.  
  357.         'If shot = 1 Then
  358.         For i = 1 To nBullets
  359.             '   Collision with player bullet and enemy
  360.             collision bullets(i).x, bullets(i).y, width3, height3, enemyX(t), enemyY(t), width5, height5
  361.             If hit = 1 Then
  362.                 If explox > 0 Then
  363.                     explo2x = enemyX(t)
  364.                     explo2y = enemyY(t)
  365.                 Else
  366.                     explox = enemyX(t)
  367.                     exploy = enemyY(t)
  368.                 End If
  369.                 _SndPlay (explosion)
  370.                 enemyX(t) = Int(Rnd * 608)
  371.                 enemyY(t) = 0 - Int(Rnd * 480)
  372.                 bullets(i).x = -30
  373.                 bullets(i).y = -30
  374.                 bullets(i).active = 0
  375.                 score = score + 50
  376.                 bullseye = bullseye + 1
  377.             End If
  378.             'End If
  379.         Next
  380.     Next
  381.     For t = 0 To 1
  382.         '   Collision with player and superenemy
  383.         collision planex, planey, width0, height0, superenemyX(t), superenemyY(t), width5, height5
  384.         If hit = 1 Then
  385.             If explox > 0 Then
  386.                 explo2x = enemyX(t)
  387.                 explo2y = enemyY(t)
  388.             Else
  389.                 explox = enemyX(t)
  390.                 exploy = enemyY(t)
  391.             End If
  392.             _SndPlay (explosion)
  393.             enemyX(t) = Int(Rnd * 608)
  394.             enemyY(t) = 0 - Int(Rnd * 480)
  395.             health = health - 25
  396.             If health <= 0 Then
  397.                 bigexploactive = 1
  398.                 bigexplox = planex
  399.                 bigexploy = planey
  400.                 planex = -70 '>>>>>>>>>>>>>>>>>>>>>>> this could disappear the plane !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  401.                 planey = -70
  402.             End If
  403.             enemyX(t) = Int(Rnd * 608)
  404.             enemyY(t) = 0 - Int(Rnd * 480)
  405.         End If
  406.  
  407.  
  408.         '   Collision with player bullet and superenemy
  409.         For i = 1 To nBullets
  410.             collision bullets(i).x, bullets(i).y, width3, height3, superenemyX(t), superenemyY(t), width5, height5
  411.             If hit = 1 Then
  412.                 If explox > 0 Then
  413.                     explo2x = superenemyX(t)
  414.                     explo2y = superenemyY(t)
  415.                 Else
  416.                     explox = superenemyX(t)
  417.                     exploy = superenemyY(t)
  418.                 End If
  419.                 _SndPlay (explosion)
  420.                 superenemyX(t) = Int(Rnd * 608)
  421.                 superenemyY(t) = 0 - Int(Rnd * 480)
  422.                 bullets(i).x = -30
  423.                 bullets(i).y = -30
  424.                 bullets(i).active = 0
  425.                 score = score + 100
  426.                 bullseye = bullseye + 1
  427.             End If
  428.         Next
  429.  
  430.  
  431.     Next
  432.     For t = 0 To 1
  433.         '   Collision with player and enemy bullet
  434.         If enemyshot(t) = 1 Then
  435.             collision planex, planey, width0, height0, enemybulletX(t), enemybulletY(t), width27, height27
  436.             If hit = 1 Then
  437.                 health = health - 10
  438.                 If health <= 0 Then
  439.                     bigexploactive = 1
  440.                     bigexplox = planex
  441.                     bigexploy = planey
  442.                     enemybulletX(t) = -30 'had players bullets here!!!
  443.                     enemybulletY(t) = -30
  444.                 End If
  445.                 _SndPlay (explosion)
  446.                 If explox > 0 And explox < 640 Then
  447.                     explox2 = enemybulletX(t)
  448.                     exploy2 = enemybulletY(t)
  449.                 Else
  450.                     explox = enemybulletX(t)
  451.                     exploy = enemybulletY(t)
  452.                 End If
  453.                 enemybulletX(t) = superenemyX(t) + 14 '1
  454.                 enemybulletY(t) = superenemyY(t) + 17 '7
  455.                 enemyshot(t) = 0
  456.             End If
  457.         End If
  458.     Next
  459.  
  460.     '   FLYING OVER THE ENDLESSLY SCROLLING SEA
  461.     '   =======================================
  462.     For w = 0 To 15
  463.         backgroundY(w) = backgroundY(w) + 3
  464.         If backgroundY(w) > 480 Then
  465.             backgroundY(w) = backgroundY(w) - 512
  466.         End If
  467.         For q = 0 To 19
  468.             _PutImage (backgroundX(q), backgroundY(w)), img(4)
  469.         Next
  470.     Next
  471.  
  472.     '   WHICH LOOKS DULL WITHOUT ISLANDS
  473.     '   ================================
  474.     For o = 0 To 2
  475.         _PutImage (islandX(o), islandY(o)), islandImage(o)
  476.     Next
  477.  
  478.     '   KEEPING OUR PLANE IN THE SCREEN AND DISPLAY IT
  479.     '   ==============================================
  480.     frame = frame + 1
  481.     If frame > 2 Then
  482.         frame = 0
  483.     End If
  484.     If planex < 0 And bigexploactive = 0 Then
  485.         planex = 0
  486.     End If
  487.     If planey < 0 And bigexploactive = 0 Then
  488.         planey = 0
  489.     End If
  490.     If planex + width0 > 640 Then
  491.         planex = 640 - width0
  492.     End If
  493.     If planey + height0 > 480 - 64 Then
  494.         planey = 480 - height0 - 64
  495.     End If
  496.     _PutImage (planex, planey), img(frame)
  497.  
  498.     '   WE HAVE TO SEE WHAT WE ARE FIGHTING
  499.     '   ===================================
  500.     For x = 0 To 4
  501.         _PutImage (enemyX(x), enemyY(x)), img(frame + 5)
  502.     Next
  503.     For i = 0 To 1
  504.         If enemyshot(i) = 0 Then
  505.             decision(i) = Int(Rnd * 199)
  506.         End If
  507.         If decision(i) = 9 Then
  508.             If enemybulletY(i) < 480 Then
  509.                 enemybulletY(i) = enemybulletY(i) + 10
  510.                 enemyshot(i) = 1
  511.             Else
  512.                 enemybulletX(i) = superenemyX(i) + 14 '1
  513.                 enemybulletY(i) = superenemyY(i) + 17 '7
  514.                 enemyshot(i) = 0
  515.             End If
  516.         Else
  517.             enemybulletX(i) = superenemyX(i) + 14 '1
  518.             enemybulletY(i) = superenemyY(i) + 17 '7
  519.             enemyshot(i) = 0
  520.         End If
  521.         If superenemyY(i) > 0 Then
  522.             _PutImage (enemybulletX(i), enemybulletY(i)), img(27)
  523.         End If
  524.     Next
  525.     For x = 0 To 1
  526.         _PutImage (superenemyX(x), superenemyY(x)), img(frame + 24)
  527.     Next
  528.  
  529.  
  530.  
  531.     '   AND WITH WHAT
  532.     '   =============
  533.     For j = 1 To nBullets
  534.         If bullets(j).y > 0 And bullets(j).active Then
  535.             bullets(j).y = bullets(j).y - speed * 2
  536.             _PutImage (bullets(j).x, bullets(j).y), img(3)
  537.         Else
  538.             bullets(j).x = -30
  539.             bullets(j).y = -30
  540.             bullets(j).active = 0
  541.         End If
  542.     Next
  543.  
  544.  
  545.  
  546.  
  547.     '   A NICE EXPLOSION
  548.     '   ================
  549.     If explo_frame < 5 And explox > 0 Then
  550.         explo_frame = explo_frame + 1
  551.         _PutImage (explox, exploy), img(explo_frame + 8)
  552.     Else
  553.         explo_frame = 0
  554.         explox = -30
  555.         exploy = -30
  556.     End If
  557.  
  558.  
  559.     '   A SECOND NICE EXPLOSION
  560.     '   =======================
  561.     If explo2_frame < 5 And explo2x > 0 Then
  562.         explo2_frame = explo2_frame + 1
  563.         _PutImage (explo2x, explo2y), img(explo2_frame + 8)
  564.     Else
  565.         explo2_frame = 0
  566.         explo2x = -30
  567.         explo2y = -30
  568.     End If
  569.  
  570.  
  571.     '   A BIGGER EXPLOSION
  572.     '   ==================
  573.     If bigexploactive = 1 Then
  574.         For s = 0 To 4
  575.             enemyX(s) = Int(Rnd * 608)
  576.             enemyY(s) = 0 - Int(Rnd * 480)
  577.         Next
  578.         For s = 0 To 1
  579.             superenemyX(s) = Int(Rnd * 608)
  580.             superenemyY(s) = 0 - Int(Rnd * 480)
  581.         Next
  582.     End If
  583.     If bigexplox > 0 And bigexplox < 640 Then
  584.         bigexplo_frame = bigexplo_frame + 1
  585.     End If
  586.     If bigexplo_frame > 6 Then
  587.         bigexploactive = 0
  588.         bigexplo_frame = 0
  589.         bigexplox = -70
  590.         bigexploy = -70
  591.         lives = lives - 1
  592.         planex = 320
  593.         planey = 480 - 128
  594.         health = 100
  595.     End If
  596.     _PutImage (bigexplox, bigexploy), img(bigexplo_frame + 14)
  597.  
  598.     '   INFORMATION PANEL
  599.     '   =================
  600.     Line (0, 480 - 63)-Step(640, 63), _RGB32(220, 220, 220), BF
  601.     Line (5, 480 - 58)-Step(635, 58), _RGB32(180, 180, 180), BF
  602.     Line (5, 480 - 58)-Step(630, 58), _RGB32(120, 120, 120), BF
  603.     Line (6, 480 - 22)-Step(103, 12), _RGB32(0, 0, 255), B
  604.     Line (7, 480 - 21)-Step(100, 10), _RGB32(0, 0, 0), B
  605.     c = 143
  606.     For z = 1 To 10
  607.         Line (7, 480 - 22 + z)-(7 + health, 480 - 22 + z), _RGB32(255, c, 0)
  608.         If z > 5 Then
  609.             c = c - 44
  610.         Else
  611.             c = c + 44
  612.         End If
  613.     Next
  614.     _Font arial14
  615.     Color _RGB32(0, 0, 0), trans
  616.     _PrintString (5, 480 - 58), "Score: " + Str$(score)
  617.     _PrintString (5, 480 - 48), "Accuracy: " + Str$((bullseye / shots_fired) * 100) + "%"
  618.     For i = 1 To lives
  619.         _PutImage (120 + i * 32, 480 - 32), img(31)
  620.     Next
  621.     _PutImage (640 - width32, 480 - 58), img(32)
  622.  
  623.     '   IF ALL LIVES ARE GONE, THEN IT`S GAME OVER
  624.     '   =========================================
  625.     If lives < 0 Then
  626.         _PutImage (0, 0), img(34)
  627.         _Display
  628.         _Delay 1
  629.         Exit Do
  630.     End If
  631.  
  632.     '   DRAWING EVERYTHNG AND WAITING
  633.     '   =============================
  634.     '   AND PAUSING THE GAME IF HIS MAJESTY WANTS SO
  635.     '   ============================================
  636.     If InKey$ = "p" Or InKey$ = "P" Then
  637.         _PutImage (0, 0), img(33)
  638.         _Display
  639.         While InKey$ = "": Wend
  640.     End If
  641.  
  642.     _Limit 30
  643.     _Display
  644.  
  645.  
  646.  
  647.  
  648. '=======================================================
  649. Sub collision (r1x, r1y, r1w, r1h, r2x, r2y, r2w, r2h)
  650.     If (r1x + r1w >= r2x And r1x <= r2x + r2w And r1y + r1h >= r2y And r1y <= r2y + r2h) Then
  651.         hit = 1
  652.     Else
  653.         hit = 0
  654.     End If
  655.  
  656. Sub centerText (x1, x2, midy, s$) ' ' if you want to center fit a string between two goal posts x1, and x2
  657.     _PrintString ((x1 + x2) / 2 - _PrintWidth(s$) / 2, midy - _FontHeight(_Font) / 2), s$
  658.  
  659.  

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
Re: 1945
« Reply #14 on: December 07, 2021, 09:00:53 pm »
The reason why the 'player bullets' was used is because that was in the original Naalaa listing... But yeah. I'm also having fun and games trying to find the cause of the glitch. I have a sneaking suspicion that the collision detect may be involved somehow...
Logic is the beginning of wisdom.