Author Topic: Polybius  (Read 5798 times)

0 Members and 1 Guest are viewing this topic.

Offline pforpond

  • Newbie
  • Posts: 76
  • I am me
    • View Profile
Polybius
« on: November 13, 2019, 02:05:15 pm »
I wrote a small arcade game based on the fictional game Polybius that terrorised the arcade goers of 1981. The rules are simple, shoot the shapes and avoid letting them hit the bottom of the screen. Don't let the subliminal messages get to you ;)

Code: QB64: [Select]
  1. REM Polybius.
  2. REM By Sinnesloschen.
  3.  
  4. setup:
  5. REM sets up game and loads files
  6. REM error handler
  7. ON ERROR GOTO errorhandler
  8. REM sets screen mode
  9. SCREEN _NEWIMAGE(255, 302, 32)
  10. _TITLE "Polybius"
  11. REM launches developer console
  12. '$CONSOLE
  13. '_CONSOLE ON
  14. REM launches timer
  15. LET itime = TIMER
  16. LET ctime = 0
  17. REM checks data folder exists
  18. IF _DIREXISTS("data\") THEN
  19.     REM nothing :)
  20.     ERROR 666
  21. REM loads and applies font
  22. LET gamefont = _LOADFONT("data\gamefont.ttf", 12)
  23. _FONT gamefont
  24. REM loads image files
  25. LET titledisplay = _LOADIMAGE("data\title.png")
  26. LET titledisplay2 = _LOADIMAGE("data\title2.png")
  27. REM loads audio files
  28. LET titlemusic = _SNDOPEN("data\titlemusic.ogg")
  29. LET bulletfire = _SNDOPEN("data\bullet.ogg")
  30. LET titlesfx = _SNDOPEN("data\titlesfx.ogg")
  31. LET gamestart = _SNDOPEN("data\gamestart.ogg")
  32. LET gameover = _SNDOPEN("data\gameover.ogg")
  33. LET hit = _SNDOPEN("data\hit.ogg")
  34. LET newlevel = _SNDOPEN("data\newlevel.ogg")
  35. LET playerhit = _SNDOPEN("data\playerhit.ogg")
  36. LET playerdeath = _SNDOPEN("data\playerdeath.ogg")
  37. REM sets draw values
  38. LET playership$ = "E5 F5 L10 D10 R10 U10 L10 G10 R20 H10 R10 F10 L20 E10"
  39. LET bullet$ = "U10"
  40. LET triangle$ = "F15 L30 E15"
  41. LET square$ = "R10 U20 L20 D20 R10"
  42. LET diamond$ = "E10 H10 G10 F10"
  43. LET particle$ = "D1"
  44. REM displays loading visuals
  45.     LET temp = INT(RND * 302)
  46.     LINE (0, temp)-(302, temp), &HFF5454FC
  47.     _DELAY 0.05
  48.     LET temp2 = temp2 + 1
  49.     CLS
  50. LOOP UNTIL temp2 >= 20
  51. COLOR &HFF5454FC
  52. _PRINTSTRING ((225 / 2), (302 / 2)), "ROM OK"
  53. GOSUB titlescreen
  54. GOTO playgame
  55.  
  56. timekeeper:
  57. REM keeps game time
  58. LET ctime = (TIMER - itime)
  59. LET ctime = INT(ctime)
  60. IF playinggame = 0 THEN RETURN
  61. REM generates time events
  62. IF nextlevel = 0 THEN
  63.         REM next level
  64.         LET nextlevel = ctime + 40
  65. IF level > 1 THEN
  66.         IF nextmessage = 0 THEN
  67.                 REM next message
  68.                 LET nextmessage = ctime + INT(RND * 60) + 1
  69.         END IF
  70. REM executes time events
  71. IF nextlevel =< ctime THEN
  72.         REM next level
  73.         LET nextlevel = 0
  74.         CLS
  75.         GOSUB nextlevel
  76. IF level > 1 THEN
  77.         IF nextmessage =< ctime THEN
  78.                 REM next message
  79.                 LET nextmessage = 0
  80.                 GOSUB subliminalmessage
  81.         END IF
  82.  
  83. subliminalmessage:
  84. REM brainwashing messages
  85. LET messagem = INT(RND * 5) + 1
  86. IF messagem = 1 THEN LET messagem$ = "CONSUME": LET messagel = 7
  87. IF messagem = 2 THEN LET messagem$ = "OBEY": LET messagel = 4
  88. IF messagem = 3 THEN LET messagem$ = "BE AFRAID": LET messagel = 8
  89. IF messagem = 4 THEN LET messagem$ = "STAY AWAKE": LET messagel = 10
  90. IF messagem = 5 THEN LET messagem$ = "KEEP WORKING": LET messagel = 12
  91. _PRINTSTRING(((225 / 2)-(messagel / 2)), (302 / 2)), messagem$
  92. _DELAY 0.5
  93.  
  94. newvalues:
  95. REM generates values for new game
  96. LET playinggame = 1
  97. LET score = 0
  98. LET health = 100
  99. LET level = 0
  100. LET playerx = (255 / 2)
  101. LET oldplayerx = playerx
  102. LET playery = 290
  103. LET oldplayery = playery
  104. LET fire = 0
  105. LET particle = 0
  106. LET speed = 4
  107. LET frames = 60
  108. REM generates new stars
  109. LET star1x = INT(RND * 255) + 1
  110. LET star1y = INT(RND * 302) + 1
  111. LET star2x = INT(RND * 255) + 1
  112. LET star2y = INT(RND * 302) + 1
  113. LET star3x = INT(RND * 255) + 1
  114. LET star3y = INT(RND * 302) + 1
  115. LET star4x = INT(RND * 255) + 1
  116. LET star4y = INT(RND * 302) + 1
  117. LET star5x = INT(RND * 255) + 1
  118. LET star5y = INT(RND * 302) + 1
  119. LET star6x = INT(RND * 255) + 1
  120. LET star6y = INT(RND * 302) + 1
  121. LET star7x = INT(RND * 255) + 1
  122. LET star7y = INT(RND * 302) + 1
  123. LET star8x = INT(RND * 255) + 1
  124. LET star8y = INT(RND * 302) + 1
  125. LET star9x = INT(RND * 255) + 1
  126. LET star9y = INT(RND * 302) + 1
  127. LET star10x = INT(RND * 255) + 1
  128. LET star10y = INT(RND * 302) + 1
  129. REM generates old stars
  130. LET oldstar1y = star1y
  131. LET oldstar2y = star2y
  132. LET oldstar3y = star3y
  133. LET oldstar4y = star4y
  134. LET oldstar5y = star5y
  135. LET oldstar6y = star6y
  136. LET oldstar7y = star7y
  137. LET oldstar8y = star8y
  138. LET oldstar9y = star9y
  139. LET oldstar10y = star10y
  140. LET oldstar1x = star1x
  141. LET oldstar2x = star2x
  142. LET oldstar3x = star3x
  143. LET oldstar4x = star4x
  144. LET oldstar5x = star5x
  145. LET oldstar6x = star6x
  146. LET oldstar7x = star7x
  147. LET oldstar8x = star8x
  148. LET oldstar9x = star9x
  149. LET oldstar10x = star10x
  150. LET particlelimit = 20
  151.  
  152. playgame:
  153. REM new game starts
  154. GOSUB newvalues: REM sets new game values
  155.     LET a$ = UCASE$(INKEY$)
  156.     IF level = 0 THEN GOSUB nextlevel
  157.     GOSUB drawstars
  158.     GOSUB drawhud
  159.     GOSUB drawplayer
  160.     GOSUB drawfire
  161.     GOSUB drawparticle
  162.     GOSUB calcenemy
  163.     GOSUB timekeeper
  164.     GOSUB inputter
  165.     GOSUB objectcollision
  166.     IF health <= 0 THEN GOTO gameover
  167.     'GOSUB devconsole
  168.     _LIMIT frames
  169.  
  170. gameover:
  171. REM game over sequence
  172. PSET (playerx, playery), &HFF000000
  173. DRAW playership$
  174. _SNDPLAY playerdeath: REM plays sound
  175. REM draws particles
  176. LET particle = 1
  177. LET particlex = playerx
  178. LET particley = playery
  179. LET particlec = 1
  180. LET particlelimit = particlelimit * 2
  181.         GOSUB drawparticle
  182.         _LIMIT frames
  183. LOOP UNTIL particle = 0
  184. REM plays game over music
  185. _SNDPLAY gameover
  186.         LET gameovertemp = _SNDPLAYING(gameover)
  187. LOOP UNTIL gameovertemp = 0
  188. _PRINTSTRING(1, 1), "GAME OVER!"
  189. _PRINTSTRING(1, 15), "SCORE: " + STR$(score)
  190. GOTO endgame
  191.  
  192.  
  193. drawstars:
  194. REM draws stars
  195. REM erase old stars
  196. IF oldstar1 <> star1y THEN
  197.     REM erase star1
  198.     LINE (oldstar1x, oldstar1y)-(oldstar1x, oldstar1y), &HFF000000
  199.     LET oldstar1y = star1y
  200.     LET oldstar1x = star1x
  201. IF oldstar2y <> star2y THEN
  202.     REM erase star2
  203.     LINE (oldstar2x, oldstar2y)-(oldstar2x, oldstar2y), &HFF000000
  204.     LET oldstar2y = star2y
  205.     LET oldstar2x = star2x
  206. IF oldstar3y <> star3y THEN
  207.     REM erase star3
  208.     LINE (oldstar3x, oldstar3y)-(oldstar3x, oldstar3y), &HFF000000
  209.     LET oldstar3y = star3y
  210.     LET oldstar3x = star3x
  211. IF oldstar4y <> star4y THEN
  212.     REM erase star4
  213.     LINE (oldstar4x, oldstar4y)-(oldstar4x, oldstar4y), &HFF000000
  214.     LET oldstar4y = star4y
  215.     LET oldstar4x = star4x
  216. IF oldstar5y <> star5y THEN
  217.     REM erase star5
  218.     LINE (oldstar5x, oldstar5y)-(oldstar5x, oldstar5y), &HFF000000
  219.     LET oldstar5y = star5y
  220.     LET oldstar5x = star5x
  221. IF oldstar6y <> star6y THEN
  222.     REM erase star6
  223.     LINE (oldstar6x, oldstar6y)-(oldstar6x, oldstar6y), &HFF000000
  224.     LET oldstar6y = star6y
  225.     LET oldstar6x = star6x
  226. IF oldstar7y <> star7y THEN
  227.     REM erase star7
  228.     LINE (oldstar7x, oldstar7y)-(oldstar7x, oldstar7y), &HFF000000
  229.     LET oldstar7y = star7y
  230.     LET oldstar7x = star7x
  231. IF oldstar8y <> star8y THEN
  232.     REM erase star8
  233.     LINE (oldstar8x, oldstar8y)-(oldstar8x, oldstar8y), &HFF000000
  234.     LET oldstar8y = star8y
  235.     LET oldstar8x = star8x
  236. IF oldstar9y <> star9y THEN
  237.     REM erase star9
  238.     LINE (oldstar9x, oldstar9y)-(oldstar9x, oldstar9y), &HFF000000
  239.     LET oldstar9y = star9y
  240.     LET oldstar9x = star9x
  241. IF oldstar10y <> star10y THEN
  242.     REM erase star10
  243.     LINE (oldstar10x, oldstar10y)-(oldstar10x, oldstar10y), &HFF000000
  244.     LET oldstar10y = star10y
  245.     LET oldstar10x = star10x
  246. REM draw stars
  247. LINE (star1x, star1y)-(star1x, star1y), &HFFFCFCFC
  248. LINE (star2x, star2y)-(star2x, star2y), &HFFFCFCFC
  249. LINE (star3x, star3y)-(star3x, star3y), &HFFFCFCFC
  250. LINE (star4x, star4y)-(star4x, star4y), &HFFFCFCFC
  251. LINE (star5x, star5y)-(star5x, star5y), &HFFFCFCFC
  252. LINE (star6x, star6y)-(star6x, star6y), &HFFFCFCFC
  253. LINE (star7x, star7y)-(star7x, star7y), &HFFFCFCFC
  254. LINE (star8x, star8y)-(star8x, star8y), &HFFFCFCFC
  255. LINE (star9x, star9y)-(star9x, star9y), &HFFFCFCFC
  256. LINE (star10x, star10y)-(star10x, star10y), &HFFFCFCFC
  257. REM calc star movement
  258. LET star1y = star1y + speed / 2
  259. LET star2y = star2y + speed / 2
  260. LET star3y = star3y + speed / 2
  261. LET star4y = star4y + speed / 2
  262. LET star5y = star5y + speed / 2
  263. LET star6y = star6y + speed / 2
  264. LET star7y = star7y + speed / 2
  265. LET star8y = star8y + speed / 2
  266. LET star9y = star9y + speed / 2
  267. LET star10y = star10y + speed / 2
  268. REM keep stars within window
  269. IF star1y > 302 THEN LET star1y = 1: LET star1x = INT(RND * 255) + 1
  270. IF star2y > 302 THEN LET star2y = 1: LET star2x = INT(RND * 255) + 1
  271. IF star3y > 302 THEN LET star3y = 1: LET star3x = INT(RND * 255) + 1
  272. IF star4y > 302 THEN LET star4y = 1: LET star4x = INT(RND * 255) + 1
  273. IF star5y > 302 THEN LET star5y = 1: LET star5x = INT(RND * 255) + 1
  274. IF star6y > 302 THEN LET star6y = 1: LET star6x = INT(RND * 255) + 1
  275. IF star7y > 302 THEN LET star7y = 1: LET star7x = INT(RND * 255) + 1
  276. IF star8y > 302 THEN LET star8y = 1: LET star8x = INT(RND * 255) + 1
  277. IF star9y > 302 THEN LET star9y = 1: LET star9x = INT(RND * 255) + 1
  278. IF star10y > 302 THEN LET star10y = 1: LET star10x = INT(RND * 255) + 1
  279.  
  280. nextlevel:
  281. REM increases level / game intro
  282. REM generates level
  283. LET level = level + 1
  284. REM generates player ship location
  285. LET levelship = playery
  286. LET olevelship = levelship
  287. REM plays music
  288. IF level = 1 THEN _SNDPLAY gamestart
  289. IF level > 1 THEN _SNDPLAY newlevel
  290. LET starend = 666: REM temp values
  291.         GOSUB drawstars
  292.     REM erase old player ship
  293.     IF olevelship <> levelship THEN
  294.         PSET (255 / 2, olevelship), &HFF000000
  295.         DRAW playership$
  296.         LET olevelship = levelship
  297.     END IF
  298.     REM draw player ship
  299.     IF health > 75 THEN PSET (255 / 2, levelship), &HFF54FC54
  300.     IF health <= 75 AND health > 25 THEN PSET (255 / 2, levelship), &HFFFCFC54
  301.     IF health <= 25 THEN PSET (255 / 2, levelship), &HFFFC5454
  302.     DRAW playership$
  303.     LET levelship = levelship - speed
  304.     IF levelship < (302 / 2) THEN LET levelship = (302 / 2)
  305.     REM display level text
  306.     COLOR &HFF5454FC
  307.     _PRINTSTRING ((255 / 2) - 8, 10), "LEVEL " + STR$(level)
  308.     _LIMIT frames: REM fps limit
  309.     REM detects when music ends
  310.     IF level = 1 THEN starend = _SNDPLAYING(gamestart)
  311.     IF level > 1 THEN starend = _SNDPLAYING(newlevel)
  312. LOOP UNTIL starend = 0
  313.  
  314.  
  315. drawparticle:
  316. REM draws explopsion particles
  317. IF particle = 0 THEN RETURN: REM return for if particles arent needed
  318. IF particle = 1 THEN
  319.     REM sets up particles
  320.     LET p1x = particlex
  321.     LET p2x = particlex
  322.     LET p3x = particlex
  323.     LET p4x = particlex
  324.     LET p1y = particley
  325.     LET p2y = particley
  326.     LET p3y = particley
  327.     LET p4y = particley
  328.     LET particle = 2
  329.     LET particlemove = 0
  330.     REM sets old values
  331.     LET op1y = p1y
  332.     LET op2y = p2y
  333.     LET op3y = p3y
  334.     LET op4y = p4y
  335.     LET op1x = p1x
  336.     LET op2x = p2x
  337.     LET op3x = p3x
  338.     LET op4x = p4x
  339. IF particle = 2 THEN
  340.     IF p1x <> op1x THEN
  341.         REM erase old particle 1
  342.         LINE (op1x, op1y)-(op1x, op1y), &HFF000000
  343.         LET op1y = p1y
  344.         LET op1x = p1x
  345.     END IF
  346.     IF p2x <> op2x THEN
  347.         REM erase old particle 2
  348.         LINE (op2x, op2y)-(op2x, op2y), &HFF000000
  349.         LET op2y = p2y
  350.         LET op2x = p2x
  351.     END IF
  352.     IF p3x <> op3x THEN
  353.         REM erase old particle 3
  354.         LINE (op3x, op3y)-(op3x, op3y), &HFF000000
  355.         LET op3y = p3y
  356.         LET op3x = p3x
  357.     END IF
  358.     IF p4x <> op4x THEN
  359.         REM erase old particle 4
  360.         LINE (op4x, op4y)-(op4x, op4y), &HFF000000
  361.         LET op4y = p4y
  362.         LET op4x = p4x
  363.     END IF
  364.     REM draws particles
  365.     IF particlec = 1 THEN
  366.                 LINE (p1x, p1y)-(p1x, p1y), &HFFFC54FC
  367.                 LINE (p2x, p2y)-(p2x, p2y), &HFFFC54FC
  368.                 LINE (p3x, p3y)-(p3x, p3y), &HFFFC54FC
  369.                 LINE (p4x, p4y)-(p4x, p4y), &HFFFC54FC
  370.     END IF
  371.     IF particlec = 2 THEN
  372.                 LINE (p1x, p1y)-(p1x, p1y), &HFF54FCFC
  373.                 LINE (p2x, p2y)-(p2x, p2y), &HFF54FCFC
  374.                 LINE (p3x, p3y)-(p3x, p3y), &HFF54FCFC
  375.                 LINE (p4x, p4y)-(p4x, p4y), &HFF54FCFC
  376.     END IF
  377.     IF particlec = 3 THEN
  378.                 LINE (p1x, p1y)-(p1x, p1y), &HFFFCFC54
  379.                 LINE (p2x, p2y)-(p2x, p2y), &HFFFCFC54
  380.                 LINE (p3x, p3y)-(p3x, p3y), &HFFFCFC54
  381.                 LINE (p4x, p4y)-(p4x, p4y), &HFFFCFC54
  382.     END IF
  383.     REM sets particle values for next
  384.     LET p1x = p1x - 1: LET p1y = p1y - 1
  385.     LET p2x = p2x - 1: LET p2y = p2y + 1
  386.     LET p3x = p3x + 1: LET p3y = p3y - 1
  387.     LET p4x = p4x + 1: LET p4y = p4y + 1
  388.     LET particlemove = particlemove + 1
  389.     IF particlemove >= particlelimit THEN
  390.         REM ends particles
  391.         LET particle = 0
  392.         LINE (p1x, p1y)-(p1x, p1y), &HFF000000
  393.         LINE (p2x, p2y)-(p2x, p2y), &HFF000000
  394.         LINE (p3x, p3y)-(p3x, p3y), &HFF000000
  395.         LINE (p4x, p4y)-(p4x, p4y), &HFF000000
  396.         LINE (op1x, op1y)-(op1x, op1y), &HFF000000
  397.         LINE (op2x, op2y)-(op2x, op2y), &HFF000000
  398.         LINE (op3x, op3y)-(op3x, op3y), &HFF000000
  399.         LINE (op4x, op4y)-(op4x, op4y), &HFF000000
  400.     END IF
  401.  
  402. calcenemy:
  403. REM calculates enemy sprites
  404. FOR x = 1 TO level
  405.     IF x = 1 THEN
  406.         REM enemy 1
  407.         IF etype1 = 0 THEN
  408.             REM generates enemy type and location
  409.             LET etype1 = INT(RND * 3) + 1
  410.             LET enemy1x = INT(RND * 255)
  411.             LET enemy1y = 0
  412.             LET oldenemy1x = enemy1x
  413.             LET oldenemy1y = enemy1y
  414.         END IF
  415.         REM sets draw values
  416.         LET enemy1y = enemy1y + (speed / 4)
  417.         LET drawenemyx = enemy1x
  418.         LET drawenemyy = enemy1y
  419.         LET drawetype = etype1
  420.         LET olddrawenemyx = oldenemy1x
  421.         LET olddrawenemyy = oldenemy1y
  422.         GOSUB drawenemy
  423.         LET oldenemy1y = enemy1y
  424.         IF enemy1y > 302 THEN LET etype1 = 0: GOSUB hurtplayer
  425.     END IF
  426.     IF x = 2 THEN
  427.         REM enemy 2
  428.         IF etype2 = 0 THEN
  429.             REM generates enemy type and location
  430.             LET etype2 = INT(RND * 3) + 1
  431.             LET enemy2x = INT(RND * 255)
  432.             LET enemy2y = 0
  433.             LET oldenemy2x = enemy2x
  434.             LET oldenemy2y = enemy2y
  435.         END IF
  436.         REM sets draw values
  437.         LET enemy2y = enemy2y + (speed / 4)
  438.         LET drawenemyx = enemy2x
  439.         LET drawenemyy = enemy2y
  440.         LET drawetype = etype2
  441.         LET olddrawenemyx = oldenemy2x
  442.         LET olddrawenemyy = oldenemy2y
  443.         GOSUB drawenemy
  444.         LET oldenemy2y = enemy2y
  445.         IF enemy2y > 302 THEN LET etype2 = 0: GOSUB hurtplayer
  446.     END IF
  447.     IF x = 3 THEN
  448.         REM enemy 3
  449.         IF etype3 = 0 THEN
  450.             REM generates enemy type and location
  451.             LET etype3 = INT(RND * 3) + 1
  452.             LET enemy3x = INT(RND * 255)
  453.             LET enemy3y = 0
  454.             LET oldenemy3x = enemy3x
  455.             LET oldenemy3y = enemy3y
  456.         END IF
  457.         REM sets draw values
  458.         LET enemy3y = enemy3y + (speed / 4)
  459.         LET drawenemyx = enemy3x
  460.         LET drawenemyy = enemy3y
  461.         LET drawetype = etype3
  462.         LET olddrawenemyx = oldenemy3x
  463.         LET olddrawenemyy = oldenemy3y
  464.         GOSUB drawenemy
  465.         LET oldenemy3y = enemy3y
  466.         IF enemy3y > 302 THEN LET etype3 = 0: GOSUB hurtplayer
  467.     END IF
  468.     IF x = 4 THEN
  469.         REM enemy 4
  470.         IF etype4 = 0 THEN
  471.             REM generates enemy type and location
  472.             LET etype4 = INT(RND * 3) + 1
  473.             LET enemy4x = INT(RND * 255)
  474.             LET enemy4y = 0
  475.             LET oldenemy4x = enemy4x
  476.             LET oldenemy4y = enemy4y
  477.         END IF
  478.         REM sets draw values
  479.         LET enemy4y = enemy4y + (speed / 4)
  480.         LET drawenemyx = enemy4x
  481.         LET drawenemyy = enemy4y
  482.         LET drawetype = etype4
  483.         LET olddrawenemyx = oldenemy4x
  484.         LET olddrawenemyy = oldenemy4y
  485.         GOSUB drawenemy
  486.         LET oldenemy4y = enemy4y
  487.         IF enemy4y > 302 THEN LET etype4 = 0: GOSUB hurtplayer
  488.     END IF
  489.     IF x = 5 THEN
  490.         REM enemy 5
  491.         IF etype5 = 0 THEN
  492.             REM generates enemy type and location
  493.             LET etype5 = INT(RND * 3) + 1
  494.             LET enemy5x = INT(RND * 255)
  495.             LET enemy5y = 0
  496.             LET oldenemy5x = enemy5x
  497.             LET oldenemy5y = enemy5y
  498.         END IF
  499.         REM sets draw values
  500.         LET enemy5y = enemy5y + (speed / 4)
  501.         LET drawenemyx = enemy5x
  502.         LET drawenemyy = enemy5y
  503.         LET drawetype = etype5
  504.         LET olddrawenemyx = oldenemy5x
  505.         LET olddrawenemyy = oldenemy5y
  506.         GOSUB drawenemy
  507.         LET oldenemy5y = enemy5y
  508.         IF enemy5y > 302 THEN LET etype5 = 0: GOSUB hurtplayer
  509.     END IF
  510.     IF x = 6 THEN
  511.         REM enemy 6
  512.         IF etype6 = 0 THEN
  513.             REM generates enemy type and location
  514.             LET etype6 = INT(RND * 3) + 1
  515.             LET enemy6x = INT(RND * 255)
  516.             LET enemy6y = 0
  517.             LET oldenemy6x = enemy6x
  518.             LET oldenemy6y = enemy6y
  519.         END IF
  520.         REM sets draw values
  521.         LET enemy6y = enemy6y + (speed / 4)
  522.         LET drawenemyx = enemy6x
  523.         LET drawenemyy = enemy6y
  524.         LET drawetype = etype6
  525.         LET olddrawenemyx = oldenemy6x
  526.         LET olddrawenemyy = oldenemy6y
  527.         GOSUB drawenemy
  528.         LET oldenemy6y = enemy6y
  529.         IF enemy6y > 302 THEN LET etype6 = 0: GOSUB hurtplayer
  530.     END IF
  531.     IF x = 7 THEN
  532.         REM enemy 7
  533.         IF etype7 = 0 THEN
  534.             REM generates enemy type and location
  535.             LET etype7 = INT(RND * 3) + 1
  536.             LET enemy7x = INT(RND * 255)
  537.             LET enemy7y = 0
  538.             LET oldenemy7x = enemy7x
  539.             LET oldenemy7y = enemy7y
  540.         END IF
  541.         REM sets draw values
  542.         LET enemy7y = enemy7y + (speed / 4)
  543.         LET drawenemyx = enemy7x
  544.         LET drawenemyy = enemy7y
  545.         LET drawetype = etype7
  546.         LET olddrawenemyx = oldenemy7x
  547.         LET olddrawenemyy = oldenemy7y
  548.         GOSUB drawenemy
  549.         LET oldenemy7y = enemy7y
  550.         IF enemy7y > 302 THEN LET etype7 = 0: GOSUB hurtplayer
  551.     END IF
  552.     IF x = 8 THEN
  553.         REM enemy 8
  554.         IF etype8 = 0 THEN
  555.             REM generates enemy type and location
  556.             LET etype8 = INT(RND * 3) + 1
  557.             LET enemy8x = INT(RND * 255)
  558.             LET enemy8y = 0
  559.             LET oldenemy8x = enemy8x
  560.             LET oldenemy8y = enemy8y
  561.         END IF
  562.         REM sets draw values
  563.         LET enemy8y = enemy8y + (speed / 4)
  564.         LET drawenemyx = enemy8x
  565.         LET drawenemyy = enemy8y
  566.         LET drawetype = etype8
  567.         LET olddrawenemyx = oldenemy8x
  568.         LET olddrawenemyy = oldenemy8y
  569.         GOSUB drawenemy
  570.         LET oldenemy8y = enemy8y
  571.         IF enemy8y > 302 THEN LET etype8 = 0: GOSUB hurtplayer
  572.     END IF
  573.     IF x = 9 THEN
  574.         REM enemy 9
  575.         IF etype9 = 0 THEN
  576.             REM generates enemy type and location
  577.             LET etype9 = INT(RND * 3) + 1
  578.             LET enemy9x = INT(RND * 255)
  579.             LET enemy9y = 0
  580.             LET oldenemy9x = enemy9x
  581.             LET oldenemy9y = enemy9y
  582.         END IF
  583.         REM sets draw values
  584.         LET enemy9y = enemy9y + (speed / 4)
  585.         LET drawenemyx = enemy9x
  586.         LET drawenemyy = enemy9y
  587.         LET drawetype = etype9
  588.         LET olddrawenemyx = oldenemy9x
  589.         LET olddrawenemyy = oldenemy9y
  590.         GOSUB drawenemy
  591.         LET oldenemy9y = enemy9y
  592.         IF enemy9y > 302 THEN LET etype9 = 0: GOSUB hurtplayer
  593.     END IF
  594.     IF x = 10 THEN
  595.         REM enemy 10
  596.         IF etype10 = 0 THEN
  597.             REM generates enemy type and location
  598.             LET etype10 = INT(RND * 3) + 1
  599.             LET enemy10x = INT(RND * 255)
  600.             LET enemy10y = 0
  601.             LET oldenemy10x = enemy10x
  602.             LET oldenemy10y = enemy10y
  603.         END IF
  604.         REM sets draw values
  605.         LET enemy10y = enemy10y + (speed / 4)
  606.         LET drawenemyx = enemy10x
  607.         LET drawenemyy = enemy10y
  608.         LET drawetype = etype10
  609.         LET olddrawenemyx = oldenemy10x
  610.         LET olddrawenemyy = oldenemy10y
  611.         GOSUB drawenemy
  612.         LET oldenemy10y = enemy10y
  613.         IF enemy10y > 302 THEN LET etype10 = 0: GOSUB hurtplayer
  614.     END IF
  615.  
  616. hurtplayer:
  617. REM hurts player and removes old enemy
  618. IF drawetype = 1 THEN
  619.     REM remove square
  620.     PSET (drawenemyx, drawenemyy), &HFF000000
  621.     DRAW square$
  622.     LET health = health - 3
  623. IF drawetype = 2 THEN
  624.     REM remove triangle
  625.     PSET (drawenemyx, drawenemyy), &HFF000000
  626.     DRAW triangle$
  627.     LET health = health - 5
  628. IF drawetype = 3 THEN
  629.     REM remove diamond
  630.     PSET (drawenemyx, drawenemyy), &HFF000000
  631.     DRAW diamond$
  632.     LET health = health - 10
  633. _SNDPLAY playerhit
  634. IF health > 0 THEN
  635.         REM particles
  636.         LET particle = 1
  637.         LET particlex = drawenemyx
  638.         LET particley = drawenemyy
  639.         LET particlec = drawetype
  640.         CLS
  641.  
  642. drawenemy:
  643. REM draws enemy sprites
  644. IF drawetype = 1 THEN
  645.     REM square
  646.     IF olddrawenemyy <> drawenemyy THEN
  647.         REM erases old square
  648.         PSET (olddrawenemyx, olddrawenemyy), &HFF000000
  649.         DRAW square$
  650.     END IF
  651.     PSET (drawenemyx, drawenemyy), &HFFFC54FC
  652.     DRAW square$
  653. IF drawetype = 2 THEN
  654.     REM triangle
  655.     IF olddrawenemyy <> drawenemyy THEN
  656.         REM erases old triangle
  657.         PSET (olddrawenemyx, olddrawenemyy), &HFF000000
  658.         DRAW triangle$
  659.     END IF
  660.     PSET (drawenemyx, drawenemyy), &HFF54FCFC
  661.     DRAW triangle$
  662. IF drawetype = 3 THEN
  663.     REM diamond
  664.     IF olddrawenemyy <> drawenemyy THEN
  665.         REM erases old diamond
  666.         PSET (olddrawenemyx, olddrawenemyy), &HFF000000
  667.         DRAW diamond$
  668.     END IF
  669.     PSET (drawenemyx, drawenemyy), &HFFFCFC54
  670.     DRAW diamond$
  671.  
  672. errorhandler:
  673. REM handles errors
  674. PRINT "ERROR: "; ERR
  675. PRINT "LINE: "; _ERRORLINE
  676. IF ERR = 666 THEN PRINT "DATA FOLDER NOT FOUND"
  677. PRINT "POLYBIUS WILL NOW CLOSE"
  678.  
  679. drawfire:
  680. REM draws bullets
  681. IF fire = 0 THEN RETURN: REM return if no bullets fired
  682. IF fire = 1 THEN
  683.     REM FIRE BULLET
  684.     IF oldfirey <> firey THEN
  685.         REM erases old bullet
  686.         PSET (firex, oldfirey), &HFF000000
  687.         DRAW bullet$
  688.         LET oldfirey = firey
  689.     END IF
  690.     IF health > 75 THEN PSET (firex, firey), &HFF54FC54
  691.         IF health <= 75 AND health > 25 THEN PSET (firex, firey), &HFFFCFC54
  692.         IF health <= 25 THEN PSET (firex, firey), &HFFFC5454
  693.     DRAW bullet$
  694.     LET firey = firey - speed
  695.     IF firey < 12 THEN
  696.         REM ends fire
  697.         LET fire = 0
  698.         PSET (firex, oldfirey), &HFF000000
  699.         DRAW bullet$
  700.     END IF
  701.  
  702. objectcollision:
  703. REM object collision
  704. REM player window boundaries
  705. IF playerx < -4 THEN LET playerx = -4
  706. IF playerx > 249 THEN LET playerx = 249
  707. REM bullet and enemy
  708. FOR x = 1 TO level
  709.     IF x = 1 THEN
  710.         IF firex > enemy1x - 10 AND firex < enemy1x + 10 THEN
  711.             IF firey <= enemy1y THEN
  712.                 IF etype1 = 1 THEN LET score = score + 1
  713.                 IF etype1 = 2 THEN LET score = score + 3
  714.                 IF etype1 = 3 THEN LET score = score + 5
  715.                 LET fire = 0
  716.                 LET blowx = oldenemy1x
  717.                 LET blowy = oldenemy1y
  718.                 LET blowtype = etype1
  719.                 LET etype1 = 0
  720.                 GOSUB blowenemy
  721.             END IF
  722.         END IF
  723.     END IF
  724.     IF x = 2 THEN
  725.         IF firex > enemy2x - 10 AND firex < enemy2x + 10 THEN
  726.             IF firey <= enemy2y THEN
  727.                 IF etype2 = 1 THEN LET score = score + 1
  728.                 IF etype2 = 2 THEN LET score = score + 3
  729.                 IF etype2 = 3 THEN LET score = score + 5
  730.                 LET fire = 0
  731.                 LET blowx = oldenemy2x
  732.                 LET blowy = oldenemy2y
  733.                 LET blowtype = etype2
  734.                 LET etype2 = 0
  735.                 GOSUB blowenemy
  736.             END IF
  737.         END IF
  738.     END IF
  739.     IF x = 3 THEN
  740.         IF firex > enemy3x - 10 AND firex < enemy3x + 10 THEN
  741.             IF firey <= enemy3y THEN
  742.                 IF etype3 = 1 THEN LET score = score + 1
  743.                 IF etype3 = 2 THEN LET score = score + 3
  744.                 IF etype3 = 3 THEN LET score = score + 5
  745.                 LET fire = 0
  746.                 LET blowx = oldenemy3x
  747.                 LET blowy = oldenemy3y
  748.                 LET blowtype = etype3
  749.                 LET etype3 = 0
  750.                 GOSUB blowenemy
  751.             END IF
  752.         END IF
  753.     END IF
  754.     IF x = 4 THEN
  755.         IF firex > enemy4x - 10 AND firex < enemy4x + 10 THEN
  756.             IF firey <= enemy4y THEN
  757.                 IF etype4 = 1 THEN LET score = score + 1
  758.                 IF etype4 = 2 THEN LET score = score + 3
  759.                 IF etype4 = 3 THEN LET score = score + 5
  760.                 LET fire = 0
  761.                 LET blowx = oldenemy4x
  762.                 LET blowy = oldenemy4y
  763.                 LET blowtype = etype4
  764.                 LET etype4 = 0
  765.                 GOSUB blowenemy
  766.             END IF
  767.         END IF
  768.     END IF
  769.     IF x = 5 THEN
  770.         IF firex > enemy5x - 10 AND firex < enemy5x + 10 THEN
  771.             IF firey <= enemy5y THEN
  772.                 IF etype5 = 1 THEN LET score = score + 1
  773.                 IF etype5 = 2 THEN LET score = score + 3
  774.                 IF etype5 = 3 THEN LET score = score + 5
  775.                 LET fire = 0
  776.                 LET blowx = oldenemy5x
  777.                 LET blowy = oldenemy5y
  778.                 LET blowtype = etype5
  779.                 LET etype5 = 0
  780.                 GOSUB blowenemy
  781.             END IF
  782.         END IF
  783.     END IF
  784.     IF x = 6 THEN
  785.         IF firex > enemy6x - 10 AND firex < enemy6x + 10 THEN
  786.             IF firey <= enemy6y THEN
  787.                 IF etype6 = 1 THEN LET score = score + 1
  788.                 IF etype6 = 2 THEN LET score = score + 3
  789.                 IF etype6 = 3 THEN LET score = score + 5
  790.                 LET fire = 0
  791.                 LET blowx = oldenemy6x
  792.                 LET blowy = oldenemy6y
  793.                 LET blowtype = etype6
  794.                 LET etype6 = 0
  795.                 GOSUB blowenemy
  796.             END IF
  797.         END IF
  798.     END IF
  799.     IF x = 7 THEN
  800.         IF firex > enemy7x - 10 AND firex < enemy7x + 10 THEN
  801.             IF firey <= enemy7y THEN
  802.                 IF etype7 = 1 THEN LET score = score + 1
  803.                 IF etype7 = 2 THEN LET score = score + 3
  804.                 IF etype7 = 3 THEN LET score = score + 5
  805.                 LET fire = 0
  806.                 LET blowx = oldenemy7x
  807.                 LET blowy = oldenemy7y
  808.                 LET blowtype = etype7
  809.                 LET etype7 = 0
  810.                 GOSUB blowenemy
  811.             END IF
  812.         END IF
  813.     END IF
  814.     IF x = 8 THEN
  815.         IF firex > enemy8x - 10 AND firex < enemy8x + 10 THEN
  816.             IF firey <= enemy8y THEN
  817.                 IF etype8 = 1 THEN LET score = score + 1
  818.                 IF etype8 = 2 THEN LET score = score + 3
  819.                 IF etype8 = 3 THEN LET score = score + 5
  820.                 LET fire = 0
  821.                 LET blowx = oldenemy8x
  822.                 LET blowy = oldenemy8y
  823.                 LET blowtype = etype8
  824.                 LET etype8 = 0
  825.                 GOSUB blowenemy
  826.             END IF
  827.         END IF
  828.     END IF
  829.     IF x = 9 THEN
  830.         IF firex > enemy9x - 10 AND firex < enemy9x + 10 THEN
  831.             IF firey <= enemy9y THEN
  832.                 IF etype9 = 1 THEN LET score = score + 1
  833.                 IF etype9 = 2 THEN LET score = score + 3
  834.                 IF etype9 = 3 THEN LET score = score + 5
  835.                 LET fire = 0
  836.                 LET blowx = oldenemy9x
  837.                 LET blowy = oldenemy9y
  838.                 LET blowtype = etype9
  839.                 LET etype9 = 0
  840.                 GOSUB blowenemy
  841.             END IF
  842.         END IF
  843.     END IF
  844.     IF x = 10 THEN
  845.         IF firex > enemy10x - 10 AND firex < enemy10x + 10 THEN
  846.             IF firey <= enemy10y THEN
  847.                 IF etype10 = 1 THEN LET score = score + 1
  848.                 IF etype10 = 2 THEN LET score = score + 3
  849.                 IF etype10 = 3 THEN LET score = score + 5
  850.                 LET fire = 0
  851.                 LET blowx = oldenemy10x
  852.                 LET blowy = oldenemy10y
  853.                 LET blowtype = etype10
  854.                 LET etype10 = 0
  855.                 GOSUB blowenemy
  856.             END IF
  857.         END IF
  858.     END IF
  859.  
  860. blowenemy:
  861. REM blows up enemy
  862. IF blowtype = 1 THEN
  863.     REM erases old square
  864.     PSET (blowx, blowy), &HFF000000
  865.     DRAW square$
  866. IF blowtype = 2 THEN
  867.     REM erases old triangle
  868.     PSET (blowx, blowy), &HFF000000
  869.     DRAW triangle$
  870. IF blowtype = 3 THEN
  871.     REM erases old diamond
  872.     PSET (blowx, blowy), &HFF000000
  873.     DRAW diamond$
  874. REM erases bullet
  875. PSET (firex, oldfirey), &HFF000000
  876. DRAW bullet$
  877. REM plays hit sound
  878. LET particle = 1
  879. LET particlex = blowx
  880. LET particley = blowy
  881. LET particlec = blowtype
  882.  
  883. devconsole:
  884. REM developer console
  885. REM console lines go here
  886.  
  887.  
  888. drawplayer:
  889. REM draws player ship
  890. IF oldplayerx <> playerx THEN
  891.     REM removes old player ship
  892.     PSET (oldplayerx, oldplayery), &HFF000000
  893.     DRAW playership$
  894.     LET oldplayerx = playerx
  895. REM draws new ship
  896. IF health > 75 THEN PSET (playerx, playery), &HFF54FC54
  897. IF health <= 75 AND health > 25 THEN PSET (playerx, playery), &HFFFCFC54
  898. IF health <= 25 THEN PSET (playerx, playery), &HFFFC5454
  899. DRAW playership$
  900.  
  901. drawhud:
  902. REM draws the game hud (score and health)
  903. COLOR &HFF5454FC
  904. _PRINTSTRING (1, 1), "HEALTH: " + STR$(health)
  905. _PRINTSTRING (180, 1), "SCORE: " + STR$(score)
  906. REM draws seperator lines
  907. LINE (0, 13)-(302, 13), &HFF5454FC
  908. LINE (0, 15)-(302, 15), &HFF5454FC
  909.  
  910. inputter:
  911. REM game input
  912. IF a$ = "Q" THEN GOTO endgame
  913. IF _KEYDOWN(19712) THEN LET playerx = playerx + speed
  914. IF _KEYDOWN(19200) THEN LET playerx = playerx - speed
  915. IF a$ = " " THEN
  916.     IF fire = 0 THEN
  917.         LET fire = 1
  918.         LET firex = playerx + 5
  919.         LET firey = playery + 10
  920.         LET oldfirex = firex
  921.         LET oldfirey = firey
  922.         _SNDPLAY bulletfire
  923.     END IF
  924.  
  925. titlescreen:
  926. REM displays titlescreen
  927. _PUTIMAGE (0, 0)-(255, 302), titledisplay
  928. _SNDPLAY titlemusic
  929. REM displays occasional flashes after music
  930.     IF _SNDPLAYING(titlemusic) = 0 THEN
  931.         IF titletemp = 0 THEN LET titletemp = ctime + 20
  932.         IF titletemp <= ctime THEN
  933.             _SNDLOOP titlesfx
  934.             FOR t = 1 TO 10
  935.                 _PUTIMAGE (0, 0)-(255, 302), titledisplay2
  936.                 _DELAY 0.1
  937.                 _PUTIMAGE (0, 0)-(255, 302), titledisplay
  938.                 _DELAY 0.1
  939.             NEXT t
  940.             _SNDSTOP titlesfx
  941.             LET titletemp = ctime + 20
  942.         END IF
  943.     END IF
  944.     GOSUB timekeeper
  945. _SNDSTOP titlemusic
  946.  
  947. endgame:
  948. REM unloads all files from memory and quits game
  949. REM unloads images
  950. _FREEIMAGE titledisplay
  951. _FREEIMAGE titledisplay2
  952. REM unloads audio
  953. _SNDCLOSE titlemusic
  954. _SNDCLOSE bulletfire
  955. _SNDCLOSE titlesfx
  956. _SNDCLOSE gamestart
  957. _SNDCLOSE gameover
  958. _SNDCLOSE newlevel
  959. _SNDCLOSE playerhit
  960. _SNDCLOSE playerdeath
  961. REM Danni Pond
  962.  

Extract the data file to your QB64 folder then compile. Arrow Keys move. Space fires a bullet. Q quits the game. Hope you all enjoy :)
* data.zip (Filesize: 5.03 MB, Downloads: 135)
Loading Signature...

Offline RhoSigma

  • QB64 Developer
  • Forum Resident
  • Posts: 565
    • View Profile
Re: Polybius
« Reply #1 on: November 13, 2019, 02:59:23 pm »
« Last Edit: January 31, 2022, 06:48:57 pm by RhoSigma »
My Projects:   https://qb64forum.alephc.xyz/index.php?topic=809
GuiTools - A graphic UI framework (can do multiple UI forms/windows in one program)
Libraries - ImageProcess, StringBuffers (virt. files), MD5/SHA2-Hash, LZW etc.
Bonus - Blankers, QB64/Notepad++ setup pack

Offline pforpond

  • Newbie
  • Posts: 76
  • I am me
    • View Profile
Re: Polybius
« Reply #2 on: November 13, 2019, 03:43:47 pm »
http://www.qb64.org/wiki/LET

I disagree. I find LET very useful in distinguishing when values are changing in my code. I'm pretty sure the computers of today can handle the extra bytes.
Loading Signature...

Offline Lucky_Strikez

  • Newbie
  • Posts: 7
    • View Profile
Re: Polybius
« Reply #3 on: November 16, 2019, 09:42:51 pm »
Nice work! It's quite entertaining.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Polybius
« Reply #4 on: November 16, 2019, 10:19:27 pm »
https://www.atlasobscura.com/articles/the-urban-legend-of-the-governments-mindcontrolling-arcade-game

Dang! I thought Polybius meant an unnatural fear of using arrays. ;-))

Offline keybone

  • Forum Regular
  • Posts: 116
  • My name a Nursultan Tulyakbay.
    • View Profile
Re: Polybius
« Reply #5 on: November 17, 2019, 10:21:24 pm »
I disagree. I find LET very useful in distinguishing when values are changing in my code. I'm pretty sure the computers of today can handle the extra bytes.

LET might not have any purpose, but it is absolutely rediculous that some people feel the need to tell others not to use it.
LET doesnt make any difference whatsoever, it doesnt make the code any better or any worse.
People should just keep their mouths shut about it, and let people that want to use it do so without any shit talking.
That LET wiki entry is plain opinionated, biased, unprofessional, and insulting to cavemen. It should be reverted back to it's previous state.

I am from a Kazakhstan, we follow the hawk.

Offline keybone

  • Forum Regular
  • Posts: 116
  • My name a Nursultan Tulyakbay.
    • View Profile
Re: Polybius
« Reply #6 on: November 17, 2019, 10:31:19 pm »
This game is awesome, btw. :)
I am from a Kazakhstan, we follow the hawk.

Offline Lucky_Strikez

  • Newbie
  • Posts: 7
    • View Profile
Re: Polybius
« Reply #7 on: November 17, 2019, 11:08:08 pm »
LET might not have any purpose, but it is absolutely rediculous that some people feel the need to tell others not to use it.
LET doesnt make any difference whatsoever, it doesnt make the code any better or any worse.
People should just keep their mouths shut about it, and let people that want to use it do so without any shit talking.
That LET wiki entry is plain opinionated, biased, unprofessional, and insulting to cavemen. It should be reverted back to it's previous state.

It's called humor, the wiki is hilarious. It's a joke!

Offline keybone

  • Forum Regular
  • Posts: 116
  • My name a Nursultan Tulyakbay.
    • View Profile
Re: Polybius
« Reply #8 on: November 17, 2019, 11:48:54 pm »
It's called humor, the wiki is hilarious. It's a joke!

Well my post was serious, except for the insulting to cavemen part which was also a joke.
The fact of the matter is though that people really do criticize for the use of LET which is rediculous.
It's like shut the heck up and mind your own business. If you dont like someone's use of LET then don't use their code.

Btw, I was well aware that the wiki article was a joke...

I am from a Kazakhstan, we follow the hawk.

Offline pforpond

  • Newbie
  • Posts: 76
  • I am me
    • View Profile
Re: Polybius
« Reply #9 on: November 20, 2019, 10:38:08 am »
This game is awesome, btw. :)
Nice work! It's quite entertaining.

Thank you both :) I'm glad it was able to entertain for a while!

https://www.atlasobscura.com/articles/the-urban-legend-of-the-governments-mindcontrolling-arcade-game

Dang! I thought Polybius meant an unnatural fear of using arrays. ;-))

That's interesting because I always thought it was a Greek historian. I guess the name has many uses :)
Loading Signature...

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Polybius
« Reply #10 on: November 20, 2019, 11:43:33 am »
I did not know of the historian but thought it cool that an urban legend inspires imagination for creating a game.

I would have "translated" polybius as poly = many + b = be + i = the humble i + us = just us  ;-))

Offline Jack002

  • Forum Regular
  • Posts: 123
  • Boss, l wanna talk about arrays
    • View Profile
Re: Polybius
« Reply #11 on: November 21, 2019, 04:51:52 pm »
Well my post was serious, except for the insulting to cavemen part which was also a joke.
The fact of the matter is though that people really do criticize for the use of LET which is rediculous.
It's like shut the heck up and mind your own business. If you dont like someone's use of LET then don't use their code.

Btw, I was well aware that the wiki article was a joke...
Keybone, I agree with you about the issue with the word LET.
The only value I see is let solves a problem with the EQUAL sign. You were taught in school = means stuff on the left is the same as stuff on the right. Its not an ASSIGNMENT, its a STATEMENT. Enter BASIC. The idea was to have a way to assign value to something.
LET gets that done. Let this thing have this value.
So if you do that a million times, you can drop the LET and keep going, no problem
That can be the only value to LET I can think of. (other than old man syndrome where it was good enough for my dad and his dad, etc etc)

QB64 is the best!

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Polybius
« Reply #12 on: November 21, 2019, 05:01:48 pm »
Keybone, I agree with you about the issue with the word LET.
The only value I see is let solves a problem with the EQUAL sign. You were taught in school = means stuff on the left is the same as stuff on the right. Its not an ASSIGNMENT, its a STATEMENT. Enter BASIC. The idea was to have a way to assign value to something.
LET gets that done. Let this thing have this value.
So if you do that a million times, you can drop the LET and keep going, no problem
That can be the only value to LET I can think of. (other than old man syndrome where it was good enough for my dad and his dad, etc etc)

Personally, I’m rather happy to have LET in the language.  LET, CALL, and REM are all depreciated, but they’re invaluable tools when I’m debugging or experimenting with long code.

Change one assignment from x = x + 2 to LET x = x + 2, and the code hasn’t changed at all, but I now have an unique search point to quickly navigate to.  Same with replacing a ‘ with REM, or using CALL SUB...

They don’t negatively or positively affect our code, so they’re mainly syntax for readability — and that’s a personal preference, just like commenting code.  Some folks write pages of comments and documentation; others consider it a waste of time.  At the end of the day, it all breaks down to one thing: If it works for you, it works.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Dimster

  • Forum Resident
  • Posts: 500
    • View Profile
Re: Polybius
« Reply #13 on: November 22, 2019, 12:28:19 pm »
Wonder if there could some merit to have a "BUT" and maybe a negative version of LET and CALL -

LET x = x + x BUT DON"T LET x = x +2

If x = x +2 then
  CALL Subroutine1

 If x = x + 2 AND x /x <> 1 then
   DON'T CALL Subroutine1

Offline Jack002

  • Forum Regular
  • Posts: 123
  • Boss, l wanna talk about arrays
    • View Profile
Re: Polybius
« Reply #14 on: November 22, 2019, 04:45:56 pm »
If x = x + 2?
When would this be true?
QB64 is the best!