Author Topic: Flappy Bird  (Read 21578 times)

0 Members and 1 Guest are viewing this topic.

Offline TerryRitchie

  • Seasoned Forum Regular
  • Posts: 495
  • Semper Fidelis
    • View Profile
Flappy Bird
« on: August 19, 2018, 01:13:52 am »
Here's an oldie, my QB64 version of FlappyBird. I used this program as an introduction to game programming in the course I used to teach.

Update 04/29/20

Added EXE ICON support (new ICO file added below to download)
Added ability to press any key to start game
Added ability to press any key to make bird flap

Code: QB64: [Select]
  1. ' -----------------------------------------------
  2. ' QB64 FlappyBird Clone by Terry Ritchie 02/28/14
  3. '
  4. ' This program was created to accompany the QB64
  5. ' Game Programming course located at:
  6. ' http://www.qb64sourcecode.com
  7. '
  8. ' You may not sell or distribute this game! It
  9. ' was made for instructional purposes only.
  10. '
  11. ' Update: 04/29/20
  12. '
  13. ' Added EXE icon support in lines 18 and 19
  14. ' Any key press now starts game in line 274
  15. ' Any key press now flaps bird in line 196
  16. '
  17. ' -----------------------------------------------
  18.  
  19. $EXEICON:'.\fbird.ico'
  20.  
  21. '--------------------------------
  22. '- Variable declaration section -
  23. '--------------------------------
  24.  
  25. CONST FALSE = 0 '            boolean: truth  0
  26. CONST TRUE = NOT FALSE '     boolean: truth -1
  27. CONST LARGE = 0 '            large numbers
  28. CONST SMALL = 1 '            small numbers (not used in current version of game)
  29. CONST GOLD = 0 '             gold medal
  30. CONST SILVER = 1 '           silver medal
  31. CONST LIGHT = 0 '            light colored gold/silver medal
  32. CONST DARK = 1 '             dark colored gold/silver medal
  33.  
  34. TYPE PARALLAX '              parallax scenery settings
  35.     image AS LONG '          scene image
  36.     x AS INTEGER '           scene image x location
  37.     y AS INTEGER '           scene image y location
  38.     frame AS INTEGER '       current parallax frame
  39.     fmax AS INTEGER '        maximum parallax frames allowed
  40.  
  41. TYPE INFLIGHT '              flappy bird inflight characterisitcs
  42.     y AS SINGLE '            flappy bird y location
  43.     yvel AS SINGLE '         flappy bird y velocity
  44.     flap AS INTEGER '        wing flap position
  45.     flapframe AS INTEGER '   wing flap frame counter
  46.     angle AS INTEGER '       angle of flappy bird
  47.  
  48. TYPE PIPE '                  pipe characteristics
  49.     x AS INTEGER '           pipe x location
  50.     y AS INTEGER '           pipe y location
  51.  
  52. DIM Pipes(3) AS PIPE '       define 3 moving sets of pipes
  53. DIM Pipe&(1) '               pipe images 0=top 1=bottom
  54. DIM PipeImage& '             all three pipes drawn image
  55. DIM Birdie AS INFLIGHT '     bird flight characteristics
  56. DIM Scenery(4) AS PARALLAX ' define 4 moving scenes in parallax
  57. DIM Fbird&(8, 3) '           flapping bird images
  58. DIM Num&(9, 1) '             big and small numeral images
  59. DIM Plaque& '                medal/score plaque
  60. DIM FlappyBird& '            Flappy Bird title image
  61. DIM GameOver& '              Game Over image
  62. DIM GetReady& '              Get Ready image
  63. DIM Medal&(1, 1) '           gold/silver medal images
  64. DIM Finger& '                tap finger image
  65. DIM ScoreButton& '           score button image
  66. DIM ShareButton& '           share button image
  67. DIM StartButton& '           start button image
  68. DIM OKButton& '              OK button image
  69. DIM RateButton& '            RATE button image
  70. DIM MenuButton& '            MENU button image
  71. DIM PlayButton& '            PLAY [|>] button image
  72. DIM PauseButton& '           PAUSE [||] button image
  73. DIM HazardBar& '             Hazard bar parallax image
  74. DIM Clouds& '                Clouds parallax image
  75. DIM City& '                  Cityscape parallax image
  76. DIM Bushes& '                Bushes parallax image
  77. DIM New& '                   red NEW image
  78. DIM Clean& '                 clean playing screen image
  79. DIM HitBird% '               boolean: TRUE if bird hits something
  80. DIM HighScore% '             high score
  81. DIM Score% '                 current score
  82. DIM Paused% '                boolean: TRUE if game paused
  83. DIM Ding& '                  ding sound
  84. DIM Flap& '                  flapping sound
  85. DIM Smack& '                 bird smack sound
  86. DIM Latch% '                 boolean: TRUE if mouse button held down
  87. DIM WinX% '                  stops player from exiting program at will
  88.  
  89. '------------------------
  90. '- Main Program Section -
  91. '------------------------
  92.  
  93. SCREEN _NEWIMAGE(432, 768, 32) '                        create 432x768 game screen
  94. _TITLE "FlappyBird" '                                   give window a title
  95. CLS '                                                   clear the screen
  96. _DELAY .5 '                                             slight delay before moving screen to middle
  97. _SCREENMOVE _MIDDLE '                                   move window to center of desktop
  98. WinX% = _EXIT '                                         program will handle all window close requests
  99. LOADASSETS '                                            set/load game graphics/sounds/settings
  100. Birdie.flap = 1 '                                       set initial wing position of bird
  101. DO '                                                    BEGIN MAIN GAME LOOP
  102.     _LIMIT 60 '                                         60 frames per second
  103.     UPDATESCENERY '                                     update parallaxing scenery
  104.     _PUTIMAGE (40, 265), FlappyBird& '                  place game title on screen
  105.     _PUTIMAGE (350, 265), Fbird&(2, FLAPTHEBIRD%) '     place flapping bird on screen
  106.     IF BUTTON%(64, 535, StartButton&) THEN PLAYGAME '   if start button pressed play game
  107.     IF BUTTON%(248, 535, ScoreButton&) THEN SHOWSCORE ' if score button pressed show scores
  108.     IF BUTTON%(248, 480, RateButton&) THEN RATEGAME '   if rate button pressed bring up browser
  109.     _DISPLAY '                                          update screen with changes
  110. LOOP UNTIL _KEYDOWN(27) OR _EXIT '                      END MAIN GAME LOOP when ESC pressed or window closed
  111. CLEANUP '                                               clean the computer's RAM before leaving
  112. SYSTEM '                                                return to Windows desktop
  113.  
  114. '-------------------------------------
  115. '- Subroutines and Functions section -
  116. '-------------------------------------
  117.  
  118. '----------------------------------------------------------------------------------------------------------------------
  119.  
  120. FUNCTION FLAPTHEBIRD% ()
  121.  
  122.     '*
  123.     '* Returns the next index value used in Fbird&() to animate the bird's
  124.     '* flapping wings.
  125.     '*
  126.  
  127.     SHARED Birdie AS INFLIGHT
  128.  
  129.     Birdie.flapframe = Birdie.flapframe + 1 '     increment frame counter
  130.     IF Birdie.flapframe = 4 THEN '                hit limit?
  131.         Birdie.flapframe = 0 '                    yes, reset frame counter
  132.         Birdie.flap = Birdie.flap + 1 '           increment flap counter
  133.         IF Birdie.flap = 4 THEN Birdie.flap = 1 ' reset flap counter when limit hit
  134.     END IF
  135.     FLAPTHEBIRD% = Birdie.flap '                  return next index value
  136.  
  137.  
  138. '----------------------------------------------------------------------------------------------------------------------
  139.  
  140. SUB MOVEPIPES ()
  141.  
  142.     '*
  143.     '* Creates and moves the pipe images across the screen.
  144.     '*
  145.  
  146.     SHARED Pipes() AS PIPE, Pipe&(), PipeImage&, Paused%, Score%, Ding&
  147.  
  148.     DIM p% ' counter indicating which pipe being worked on
  149.  
  150.     _DEST PipeImage& '                                    work on this image
  151.     CLS , _RGBA32(0, 0, 0, 0) '                           clear image with transparent black
  152.     _DEST 0 '                                             back to work on screen
  153.     DO '                                                  BEGIN PIPE LOOP
  154.         p% = p% + 1 '                                     increment pipe counter
  155.         IF NOT Paused% THEN '                             is game paused?
  156.             Pipes(p%).x = Pipes(p%).x - 3 '               no, move pipe to the left
  157.             IF Pipes(p%).x < -250 THEN '                  hit lower limit?
  158.                 Pipes(p%).x = 500 '                       yes, move pipe all the way right
  159.                 Pipes(p%).y = -(INT(RND(1) * 384) + 12) ' generate random pipe height position
  160.             END IF
  161.             IF Pipes(p%).x = 101 THEN '                   is pipe crossing bird location?
  162.                 _SNDPLAY Ding& '                          play ding sound
  163.                 Score% = Score% + 1 '                     increment player score
  164.             END IF
  165.         END IF
  166.         IF Pipes(p%).x > -78 AND Pipes(p%).x < 432 THEN ' is pipe currently seen on screen?
  167.             _PUTIMAGE (Pipes(p%).x, Pipes(p%).y), Pipe&(0), PipeImage& ' place top pipe
  168.             _PUTIMAGE (Pipes(p%).x, Pipes(p%).y + 576), Pipe&(1), PipeImage& ' place bottom pipe
  169.         END IF
  170.     LOOP UNTIL p% = 3 '                                   END PIPE LOOP when all pipes moved
  171.     _PUTIMAGE (0, 0), PipeImage& '                        place pipe image on screen
  172.  
  173.  
  174. '----------------------------------------------------------------------------------------------------------------------
  175.  
  176. SUB FLYBIRDIE ()
  177.  
  178.     '*
  179.     '* Controls the flight of bird on screen.
  180.     '*
  181.  
  182.     SHARED Birdie AS INFLIGHT, Fbird&(), Paused%, Flap&, HitBird%, Latch%, Smack&
  183.  
  184.     DIM b% '     boolean: TRUE if left mouse button pressed
  185.     DIM Angle% ' angle of bird in flight
  186.  
  187.     IF NOT Paused% THEN '                             is game paused?
  188.         WHILE _MOUSEINPUT: WEND '                     no, get latest mouse information
  189.         b% = _MOUSEBUTTON(1) '                        get left mouse button status
  190.         IF _KEYHIT > 0 THEN b% = -1 '                 any key will also make bird flap    (added 04/29/20)
  191.         IF NOT b% THEN Latch% = FALSE '               release latch if button let go
  192.         IF NOT HitBird% THEN '                        has bird hit something?
  193.             IF NOT Latch% THEN '                      no, has left button been release?
  194.                 IF b% THEN '                          yes, was left button pressed?
  195.                     Birdie.yvel = -8 '                yes, reset bird y velocity
  196.                     _SNDPLAY Flap& '                  play flap sound
  197.                     Latch% = TRUE '                   remember mouse button pressed
  198.                 END IF
  199.             END IF
  200.         END IF
  201.         Birdie.yvel = Birdie.yvel + .5 '              bleed off some bird y velocity
  202.         Birdie.y = Birdie.y + Birdie.yvel '           add velocity to bird's y direction
  203.         IF NOT HitBird% THEN '                        has bird hit something?
  204.             IF Birdie.y < -6 OR Birdie.y > 549 THEN ' no, has bird hit top/bottom of screen?
  205.                 HitBird% = TRUE '                     yes, remeber bird hit something
  206.                 _SNDPLAY Smack& '                     play smack sound
  207.             END IF
  208.         END IF
  209.         IF Birdie.yvel < 0 THEN '                     is bird heading upward?
  210.             Birdie.angle = 1 '                        yes, set angle of bird accordingly
  211.         ELSE
  212.             Angle% = INT(Birdie.yvel * .5) + 1 '      calculate angle according to bird velocity
  213.             IF Angle% > 8 THEN Angle% = 8 '           keep angle within limits
  214.             Birdie.angle = Angle% '                   set bird angle
  215.         END IF
  216.     END IF
  217.     _PUTIMAGE (100, Birdie.y), Fbird&(Birdie.angle, FLAPTHEBIRD%) ' place bird on screen
  218.  
  219.  
  220. '----------------------------------------------------------------------------------------------------------------------
  221.  
  222. SUB UPDATESCORE ()
  223.  
  224.     '*
  225.     '* Displays player's score on screen.
  226.     '*
  227.  
  228.     SHARED Num&(), Score%
  229.  
  230.     DIM s$ ' score in string format
  231.     DIM w% ' width of score string
  232.     DIM x% ' x location of score digits
  233.     DIM p% ' position counter
  234.  
  235.     s$ = LTRIM$(RTRIM$(STR$(Score%))) ' convert score to string
  236.     w% = LEN(s$) * 23 '                 calculate width of score
  237.     x% = (432 - w%) \ 2 '               calculate x position of score
  238.     FOR p% = 1 TO LEN(s$) '             cycle through each position in score string
  239.         _PUTIMAGE (x%, 100), Num&(ASC(MID$(s$, p%, 1)) - 48, LARGE) ' place score digit on screen
  240.         x% = x% + 23 '                  move to next digit position
  241.     NEXT p%
  242.  
  243.  
  244. '----------------------------------------------------------------------------------------------------------------------
  245.  
  246. SUB READY ()
  247.  
  248.     '*
  249.     '* displays instructions to the player and waits for player to start game.
  250.     '*
  251.  
  252.     SHARED Fbird&(), Finger&, GetReady&
  253.  
  254.     DIM b% ' boolean: TRUE if left mouse button pressed
  255.  
  256.     DO '                                 BEGIN READY LOOP
  257.         _LIMIT 60 '                      60 frames per second
  258.         UPDATESCENERY '                  move parallax scenery
  259.         _PUTIMAGE (180, 350), Finger& '  place finger instructions on screen
  260.         _PUTIMAGE (85, 225), GetReady& ' place get ready image on screen
  261.         _PUTIMAGE (100, 375), Fbird&(2, FLAPTHEBIRD%) ' place bird on screen
  262.         UPDATESCORE '                    place score on screen
  263.         _DISPLAY '                       update screen with changes
  264.         WHILE _MOUSEINPUT: WEND '        get latest mouse information
  265.         b% = _MOUSEBUTTON(1) '           get status of left mouse button
  266.         IF _KEYHIT > 0 THEN b% = -1 '    any key press will also begin game           (added 04/29/20)
  267.         IF _EXIT THEN CLEANUP: SYSTEM '  leave game if user closes game window
  268.     LOOP UNTIL b% '                      END READY LOOP when left button pressed
  269.     _DELAY .2 '                          slight delay to allow mouse button release
  270.  
  271.  
  272. '----------------------------------------------------------------------------------------------------------------------
  273.  
  274. SUB PLAYGAME ()
  275.  
  276.     '*
  277.     '* Allows player to play the game.
  278.     '*
  279.  
  280.     SHARED Pipes() AS PIPE, Birdie AS INFLIGHT, PauseButton&, PlayButton&, Paused%, HitBird%, Score%
  281.  
  282.     RANDOMIZE TIMER '                                seed random number generator
  283.     Score% = 0 '                                     reset player score
  284.     Birdie.y = 0 '                                   reset bird y location
  285.     Birdie.yvel = 0 '                                reset bird y velocity
  286.     Birdie.flap = 1 '                                reset bird wing flap index
  287.     Pipes(1).x = 500 '                               reset position of first pipe
  288.     Pipes(2).x = 749 '                               reset position of second pipe
  289.     Pipes(3).x = 998 '                               reset position of third pipe
  290.     Pipes(1).y = -(INT(RND(1) * 384) + 12) '         calculate random y position of pipe 1
  291.     Pipes(2).y = -(INT(RND(1) * 384) + 12) '         calculate random y position of pipe 2
  292.     Pipes(3).y = -(INT(RND(1) * 384) + 12) '         calculate random y position of pipe 3
  293.     READY '                                          display instructions to player
  294.     DO '                                             BEGIN GAME PLAY LOOP
  295.         _LIMIT 60 '                                  60 frames per second
  296.         UPDATESCENERY '                              move parallax scenery
  297.         MOVEPIPES '                                  move pipes
  298.         UPDATESCORE '                                display player score
  299.         FLYBIRDIE '                                  move and display bird
  300.         CHECKFORHIT '                                check for bird hits
  301.         IF NOT Paused% THEN '                        is game paused?
  302.             IF BUTTON%(30, 100, PauseButton&) THEN ' no, was pause button pressed?
  303.                 Paused% = TRUE '                     yes, place game in pause state
  304.             END IF
  305.         ELSE '                                       no, game is not paused
  306.             IF BUTTON%(30, 100, PlayButton&) THEN '  was play button pressed?
  307.                 Paused% = FALSE '                    yes, take game out of pause state
  308.             END IF
  309.         END IF
  310.         _DISPLAY '                                   update screen with changes
  311.         IF _EXIT THEN CLEANUP: SYSTEM '              leave game if user closes game window
  312.     LOOP UNTIL HitBird% '                            END GAME PLAY LOOP if bird hits something
  313.     DO '                                             BEGIN BIRD DROPPING LOOP
  314.         _LIMIT 60 '                                  60 frames per second
  315.         Paused% = TRUE '                             place game in paused state
  316.         UPDATESCENERY '                              draw parallax scenery
  317.         MOVEPIPES '                                  draw pipes
  318.         Paused% = FALSE '                            take game out of pause state
  319.         FLYBIRDIE '                                  move bird on screen
  320.         _DISPLAY '                                   update screen with changes
  321.         IF _EXIT THEN CLEANUP: SYSTEM '              leave game if user closes game window
  322.     LOOP UNTIL Birdie.y >= 546 '                     END BIRD DROPPING LOOP when bird hits ground
  323.     SHOWSCORE '                                      display player's score plaque
  324.     HitBird% = FALSE '                               reset bird hit indicator
  325.  
  326.  
  327. '----------------------------------------------------------------------------------------------------------------------
  328.  
  329. SUB CHECKFORHIT ()
  330.  
  331.     '*
  332.     '* Detects if bird hits a pipe.
  333.     '*
  334.  
  335.     SHARED Pipes() AS PIPE, Birdie AS INFLIGHT, HitBird%, Smack&
  336.  
  337.     DIM p% ' pipe counter
  338.  
  339.     FOR p% = 1 TO 3 '                                      cycle through all pipe positions
  340.         IF Pipes(p%).x <= 153 AND Pipes(p%).x >= 22 THEN ' is pipe in bird territory?
  341.             IF BOXCOLLISION(105, Birdie.y + 6, 43, 41, Pipes(p%).x, Pipes(p%).y, 78, 432) THEN ' collision?
  342.                 HitBird% = TRUE '                          yes, remember bird hit pipe
  343.             END IF
  344.             IF BOXCOLLISION(105, Birdie.y + 6, 43, 41, Pipes(p%).x, Pipes(p%).y + 576, 78, 432) THEN ' collision?
  345.                 HitBird% = TRUE '                          yes, remember bird hit pipe
  346.             END IF
  347.         END IF
  348.     NEXT p%
  349.     IF HitBird% THEN _SNDPLAY Smack& '                     play smack sound if bird hit pipe
  350.  
  351.  
  352. '----------------------------------------------------------------------------------------------------------------------
  353.  
  354. SUB RATEGAME ()
  355.  
  356.     '*
  357.     '* Allows player to rate game.
  358.     '*
  359.  
  360.     SHELL "https://www.qb64.org/forum/index.php?topic=437.0" ' go to QB64 web site forum area for flappy bird
  361.  
  362.  
  363. '----------------------------------------------------------------------------------------------------------------------
  364.  
  365. SUB SHOWSCORE ()
  366.  
  367.     '*
  368.     '* Display's current and high scores on score plaque
  369.     '*
  370.  
  371.     SHARED Fbird&(), Num&(), Medal&(), FlappyBird&, GameOver&, Plaque&, OKButton&, ShareButton&
  372.     SHARED HitBird%, HighScore%, Score%, New&
  373.  
  374.     DIM Ok% '        boolean: TRUE if OK button pressed
  375.     DIM Scores%(1) ' current and high scores
  376.     DIM sc% '        current score being drawn
  377.     DIM x% '         x location of score digits
  378.     DIM p% '         digit position counter
  379.     DIM ShowNew% '   boolean: TRUE if score is a new high score
  380.     DIM s$ '         score in string format
  381.  
  382.     IF Score% > HighScore% THEN '                               is this a new high score?
  383.         OPEN "fbird.sco" FOR OUTPUT AS #1 '                     yes, open score file
  384.         PRINT #1, Score% '                                      save new high score
  385.         CLOSE #1 '                                              close score file
  386.         HighScore% = Score% '                                   remember new high score
  387.         ShowNew% = TRUE '                                       remember this is a new high score
  388.     END IF
  389.     Scores%(0) = Score% '                                       place score in array
  390.     Scores%(1) = HighScore% '                                   place high score in array
  391.     Ok% = FALSE '                                               reset OK button status indicator
  392.     DO '                                                        BEGIN SCORE LOOP
  393.         _LIMIT 60 '                                             60 frames per second
  394.         IF HitBird% THEN '                                      did bird hit something?
  395.             _PUTIMAGE (75, 200), GameOver& '                    yes, place game over image on screen
  396.         ELSE '                                                  no, bird did not hit anything
  397.             UPDATESCENERY '                                     move parallax scenery
  398.             _PUTIMAGE (40, 200), FlappyBird& '                  place flappy bird title on screen
  399.             _PUTIMAGE (350, 200), Fbird&(2, FLAPTHEBIRD%) '     place flapping bird on screen
  400.         END IF
  401.         _PUTIMAGE (46, 295), Plaque& '                          place plaque on screen
  402.         SELECT CASE HighScore% '                                what is range of high score?
  403.             CASE 25 TO 49 '                                     from 25 to 49
  404.                 _PUTIMAGE (85, 360), Medal&(SILVER, LIGHT) '    display a light silver medal
  405.             CASE 50 TO 99 '                                     from 50 to 99
  406.                 _PUTIMAGE (85, 360), Medal&(SILVER, DARK) '     display a dark silver medal
  407.             CASE 100 TO 199 '                                   from 100 to 199
  408.                 _PUTIMAGE (85, 360), Medal&(GOLD, LIGHT) '      display a light gold medal
  409.             CASE IS > 199 '                                     from 200 and beyond
  410.                 _PUTIMAGE (85, 360), Medal&(GOLD, DARK) '       display a dark gold medal
  411.         END SELECT
  412.         FOR sc% = 0 TO 1 '                                      cycle through both scores
  413.             s$ = LTRIM$(RTRIM$(STR$(Scores%(sc%)))) '           convert score to string
  414.             x% = 354 - LEN(s$) * 23 '                           calculate position of score digit
  415.             FOR p% = 1 TO LEN(s$) '                             cycle through score string
  416.                 _PUTIMAGE (x%, 346 + sc% * 64), Num&(ASC(MID$(s$, p%, 1)) - 48, LARGE) ' place digit on plaque
  417.                 x% = x% + 23 '                                  increment digit position
  418.             NEXT p%
  419.         NEXT sc%
  420.         IF ShowNew% THEN _PUTIMAGE (250, 382), New& '           display red new image if new high score
  421.         IF BUTTON%(64, 535, OKButton&) THEN Ok% = TRUE '        remember if OK button was pressed
  422.         IF BUTTON%(248, 535, ShareButton&) THEN '               was share button pressed?
  423.             SHAREPROGRAM '                                      yes, share program with others
  424.             UPDATESCENERY '                                     draw parallax scenery
  425.             MOVEPIPES '                                         draw pipes
  426.         END IF
  427.         _DISPLAY '                                              update screen with changes
  428.         IF _EXIT THEN CLEANUP: SYSTEM '                         leave game if user closes game window
  429.     LOOP UNTIL Ok% '                                            END SCORE LOOP when OK button pressed
  430.  
  431.  
  432. '----------------------------------------------------------------------------------------------------------------------
  433.  
  434. SUB SHAREPROGRAM ()
  435.  
  436.     '*
  437.     '* Allows player to share program with others
  438.     '*
  439.  
  440.     SHARED Fbird&(), FlappyBird&, OKButton&
  441.  
  442.     DIM Message& ' composed message to player's friend(s)
  443.     DIM Ok% '      boolean: TRUE if OK button pressed
  444.  
  445.     Message& = _NEWIMAGE(339, 174, 32) '                   create image to hold message to player
  446.     _CLIPBOARD$ = "I just discovered a great game! You can download it here: http:\\www.qb64sourcecode.com\fbird.exe"
  447.     _PRINTMODE _KEEPBACKGROUND '                           printed text will save background
  448.     LINE (58, 307)-(372, 453), _RGB32(219, 218, 150), BF ' clear plaque image
  449.     COLOR _RGB32(210, 170, 79) '                           compose message to player on plaque
  450.     _PRINTSTRING (66, 316), "The following message has been copied"
  451.     COLOR _RGB32(82, 55, 71)
  452.     _PRINTSTRING (65, 315), "The following message has been copied"
  453.     COLOR _RGB32(210, 170, 79)
  454.     _PRINTSTRING (66, 331), "to your computer's clipboard:"
  455.     COLOR _RGB32(82, 55, 71)
  456.     _PRINTSTRING (65, 330), "to your computer's clipboard:"
  457.     COLOR _RGB32(210, 170, 79)
  458.     _PRINTSTRING (66, 351), "'I just discovered a great game! You"
  459.     COLOR _RGB32(82, 55, 71)
  460.     _PRINTSTRING (65, 350), "'I just discovered a great game! You"
  461.     COLOR _RGB32(210, 170, 79)
  462.     _PRINTSTRING (66, 366), "can download it here:"
  463.     COLOR _RGB32(82, 55, 71)
  464.     _PRINTSTRING (65, 365), "can download it here:"
  465.     COLOR _RGB32(210, 170, 79)
  466.     _PRINTSTRING (66, 381), "www.qb64sourcecode.com\fbird.exe'"
  467.     COLOR _RGB32(82, 55, 71)
  468.     _PRINTSTRING (65, 380), "www.qb64sourcecode.com\fbird.exe'"
  469.     COLOR _RGB32(210, 170, 79)
  470.     _PRINTSTRING (66, 401), "Create an email for your friends and"
  471.     COLOR _RGB32(82, 55, 71)
  472.     _PRINTSTRING (65, 400), "Create an email for your friends and"
  473.     COLOR _RGB32(210, 170, 79)
  474.     _PRINTSTRING (66, 416), "paste this message into it! Go ahead,"
  475.     COLOR _RGB32(82, 55, 71)
  476.     _PRINTSTRING (65, 415), "paste this message into it! Go ahead,"
  477.     COLOR _RGB32(210, 170, 79)
  478.     _PRINTSTRING (66, 431), "do it now before you change your mind!"
  479.     COLOR _RGB32(82, 55, 71)
  480.     _PRINTSTRING (65, 430), "do it now before you change your mind!"
  481.     _PUTIMAGE , _DEST, Message&, (46, 295)-(384, 468) '    place message in image
  482.     DO '                                                   BEGIN SHARE LOOP
  483.         _LIMIT 60 '                                        60 frames per second
  484.         UPDATESCENERY '                                    move parallax scenery
  485.         _PUTIMAGE (40, 200), FlappyBird& '                 place flappy bird title on screen
  486.         _PUTIMAGE (350, 200), Fbird&(2, FLAPTHEBIRD%) '    place flapping bird on screen
  487.         _PUTIMAGE (46, 295), Message& '                    place message on plaque
  488.         IF BUTTON%(156, 535, OKButton&) THEN Ok% = TRUE '  remeber if OK button pressed
  489.         _DISPLAY '                                         update screen with changes
  490.         IF _EXIT THEN CLEANUP: SYSTEM '                    leave game if user closes game window
  491.     LOOP UNTIL Ok% '                                       END SHRE LOOP when OK button pressed
  492.     _FREEIMAGE Message& '                                  message image no longer needed
  493.  
  494.  
  495. '----------------------------------------------------------------------------------------------------------------------
  496.  
  497. FUNCTION BUTTON% (xpos%, ypos%, Image&)
  498.  
  499.     '*
  500.     '* Creates a button on the screen the player can click with the mouse button.
  501.     '*
  502.     '* xpos%  - x coordinate position of button on screen
  503.     '* ypos%  - y coordinate position of button on screen
  504.     '* Image& - button image
  505.     '*
  506.     '* Returns: boolean: TRUE  if button pressed
  507.     '*                   FALSE if button not pressed
  508.     '*
  509.  
  510.     DIM x% ' current mouse x coordinate
  511.     DIM y% ' current mouse y coordinate
  512.     DIM b% ' boolean: TRUE if left mouse button pressed
  513.  
  514.     _PUTIMAGE (xpos%, ypos%), Image& '                      place button image on the screen
  515.     WHILE _MOUSEINPUT: WEND '                               get latest mouse information
  516.     x% = _MOUSEX '                                          get current mouse x coordinate
  517.     y% = _MOUSEY '                                          get current mouse y coordinate
  518.     b% = _MOUSEBUTTON(1)
  519.     IF b% THEN '                                            is left mouse button pressed?
  520.         IF x% >= xpos% THEN '                               yes, is mouse x within lower limit of button?
  521.             IF x% <= xpos% + _WIDTH(Image&) THEN '          yes, is mouse x within upper limit of button?
  522.                 IF y% >= ypos% THEN '                       yes, is mouse y within lower limit of button?
  523.                     IF y% <= ypos% + _HEIGHT(Image&) THEN ' yes, is mouse y within upper limit of button?
  524.                         BUTTON% = TRUE '                    yes, remember that button was clicked on
  525.                         _DELAY .2 '                         slight delay to allow button to release
  526.                     END IF
  527.                 END IF
  528.             END IF
  529.         END IF
  530.     END IF
  531.  
  532.  
  533. '----------------------------------------------------------------------------------------------------------------------
  534.  
  535. SUB UPDATESCENERY ()
  536.  
  537.     '*
  538.     '* Updates the moving parallax scenery
  539.     '*
  540.  
  541.     SHARED Scenery() AS PARALLAX, Clean&, HazardBar&, Paused%
  542.  
  543.     DIM c% ' scenery index indicator
  544.  
  545.     _PUTIMAGE , Clean& '                                              clear screen with clean image
  546.     DO '                                                              BEGIN SCENERY LOOP
  547.         c% = c% + 1 '                                                 increment index value
  548.         IF NOT Paused% THEN '                                         is game in paused state?
  549.             Scenery(c%).frame = Scenery(c%).frame + 1 '               no, update frame counter of current scenery
  550.             IF Scenery(c%).frame = Scenery(c%).fmax THEN '            frame counter hit limit?
  551.                 Scenery(c%).frame = 0 '                               yes, reset frame counter
  552.                 Scenery(c%).x = Scenery(c%).x - 1 '                   move scenery 1 pixel to left
  553.                 IF Scenery(c%).x = -432 THEN '                        scenery hit lower limit?
  554.                     Scenery(c%).x = 0 '                               yes, reset scenery to start position
  555.                 END IF
  556.             END IF
  557.         END IF
  558.         _PUTIMAGE (Scenery(c%).x, Scenery(c%).y), Scenery(c%).image ' place current scenery on screen
  559.     LOOP UNTIL c% = 3 '                                               END SCENERY LOOP when all scenery updated
  560.     IF NOT Paused% THEN '                                             is game in paused state?
  561.         Scenery(4).x = Scenery(4).x - 3 '                             no, move hazard bar 3 pixels to left
  562.         IF Scenery(4).x = -21 THEN Scenery(4).x = 0 '                 reset to start position if lower limit hit
  563.     END IF
  564.     _PUTIMAGE (Scenery(4).x, Scenery(4).y), HazardBar& '              place hazard bar on screen
  565.  
  566.  
  567. '----------------------------------------------------------------------------------------------------------------------
  568.  
  569. SUB LOADASSETS ()
  570.  
  571.     '*
  572.     '* Loads game graphics, sounds and initial settings.
  573.     '*
  574.  
  575.     SHARED Scenery() AS PARALLAX, Birdie AS INFLIGHT, Pipes() AS PIPE, Pipe&(), Fbird&()
  576.     SHARED Num&(), Medal&(), Plaque&, FlappyBird&, GameOver&, GetReady&, Finger&
  577.     SHARED ScoreButton&, ShareButton&, StartButton&, OKButton&, RateButton&, MenuButton&
  578.     SHARED PlayButton&, PauseButton&, HazardBar&, Clouds&, City&, Bushes&, New&, Clean&
  579.     SHARED HighScore%, PipeImage&, Ding&, Flap&, Smack&
  580.  
  581.     DIM Sheet& '    sprite sheet image
  582.     DIM x% '        generic counter
  583.     DIM y% '        generic counter
  584.     DIM PipeTop& '  temporary top of pipe image
  585.     DIM PipeTube& ' temporary pipe tube image
  586.  
  587.     Ding& = _SNDOPEN("fbding.ogg", "VOL,SYNC") '         load game sounds
  588.     Flap& = _SNDOPEN("fbflap.ogg", "VOL,SYNC")
  589.     Smack& = _SNDOPEN("fbsmack.ogg", "VOL,SYNC")
  590.     Sheet& = _LOADIMAGE("fbsheet.png", 32) '             load sprite sheet
  591.     FOR y% = 0 TO 2 '                                          cycle through bird image rows
  592.         FOR x% = 0 TO 7 '                                      cycle through bird image columns
  593.             Fbird&(x% + 1, y% + 1) = _NEWIMAGE(53, 53, 32) '   create image holder then get image
  594.             _PUTIMAGE , Sheet&, Fbird&(x% + 1, y% + 1), (x% * 53, y% * 53)-(x% * 53 + 52, y% * 53 + 52)
  595.         NEXT x%
  596.     NEXT y%
  597.     FOR x% = 0 TO 9 '                                          cycle trough 9 numeral images
  598.         Num&(x%, 0) = _NEWIMAGE(21, 30, 32) '                  create image holder for big
  599.         Num&(x%, 1) = _NEWIMAGE(18, 21, 32) '                  create image holder for small
  600.         _PUTIMAGE , Sheet&, Num&(x%, 0), (x% * 21, 159)-(x% * 21 + 20, 188) ' get images
  601.         _PUTIMAGE , Sheet&, Num&(x%, 1), (x% * 18 + 210, 159)-(x% * 18 + 227, 179)
  602.     NEXT x%
  603.     Plaque& = _NEWIMAGE(339, 174, 32) '                        define remaining image sizes
  604.     FlappyBird& = _NEWIMAGE(288, 66, 32)
  605.     GameOver& = _NEWIMAGE(282, 57, 32)
  606.     GetReady& = _NEWIMAGE(261, 66, 32)
  607.     PipeTop& = _NEWIMAGE(78, 36, 32)
  608.     PipeTube& = _NEWIMAGE(78, 36, 32)
  609.     Pipe&(0) = _NEWIMAGE(78, 432, 32)
  610.     Pipe&(1) = _NEWIMAGE(78, 432, 32)
  611.     PipeImage& = _NEWIMAGE(432, 596, 32)
  612.     Medal&(0, 0) = _NEWIMAGE(66, 66, 32)
  613.     Medal&(0, 1) = _NEWIMAGE(66, 66, 32)
  614.     Medal&(1, 0) = _NEWIMAGE(66, 66, 32)
  615.     Medal&(1, 1) = _NEWIMAGE(66, 66, 32)
  616.     Finger& = _NEWIMAGE(117, 147, 32)
  617.     ScoreButton& = _NEWIMAGE(120, 42, 32)
  618.     ShareButton& = _NEWIMAGE(120, 42, 32)
  619.     StartButton& = _NEWIMAGE(120, 42, 32)
  620.     OKButton& = _NEWIMAGE(120, 42, 32)
  621.     RateButton& = _NEWIMAGE(120, 42, 32)
  622.     MenuButton& = _NEWIMAGE(120, 42, 32)
  623.     PlayButton& = _NEWIMAGE(39, 42, 32)
  624.     PauseButton& = _NEWIMAGE(39, 42, 32)
  625.     HazardBar& = _NEWIMAGE(462, 24, 32)
  626.     Clouds& = _NEWIMAGE(864, 120, 32)
  627.     City& = _NEWIMAGE(864, 57, 32)
  628.     Bushes& = _NEWIMAGE(864, 27, 32)
  629.     New& = _NEWIMAGE(48, 21, 32)
  630.     _PUTIMAGE , Sheet&, Plaque&, (0, 189)-(338, 362) '         grab images from sprite sheet
  631.     _PUTIMAGE , Sheet&, FlappyBird&, (0, 363)-(287, 428)
  632.     _PUTIMAGE , Sheet&, GameOver&, (588, 246)-(869, 302)
  633.     _PUTIMAGE , Sheet&, GetReady&, (588, 303)-(847, 368)
  634.     _PUTIMAGE , Sheet&, Medal&(0, 0), (339, 327)-(404, 392)
  635.     _PUTIMAGE , Sheet&, Medal&(0, 1), (405, 327)-(470, 392)
  636.     _PUTIMAGE , Sheet&, Medal&(1, 0), (339, 261)-(404, 326)
  637.     _PUTIMAGE , Sheet&, Medal&(1, 1), (405, 261)-(470, 326)
  638.     _PUTIMAGE , Sheet&, Finger&, (471, 246)-(587, 392)
  639.     _PUTIMAGE , Sheet&, ScoreButton&, (288, 417)-(407, 458)
  640.     _PUTIMAGE , Sheet&, ShareButton&, (408, 417)-(527, 458)
  641.     _PUTIMAGE , Sheet&, StartButton&, (528, 417)-(647, 458)
  642.     _PUTIMAGE , Sheet&, OKButton&, (424, 204)-(543, 245)
  643.     _PUTIMAGE , Sheet&, RateButton&, (544, 204)-(663, 245)
  644.     _PUTIMAGE , Sheet&, MenuButton&, (664, 204)-(783, 245)
  645.     _PUTIMAGE , Sheet&, PlayButton&, (784, 204)-(822, 245)
  646.     _PUTIMAGE , Sheet&, PauseButton&, (823, 204)-(861, 245)
  647.     _PUTIMAGE , Sheet&, HazardBar&, (288, 393)-(749, 416)
  648.     _PUTIMAGE (0, 0)-(431, 119), Sheet&, Clouds&, (424, 0)-(855, 119)
  649.     _PUTIMAGE (432, 0)-(863, 119), Sheet&, Clouds&, (424, 0)-(855, 119)
  650.     _PUTIMAGE (0, 0)-(431, 56), Sheet&, City&, (424, 120)-(855, 176)
  651.     _PUTIMAGE (432, 0)-(863, 56), Sheet&, City&, (424, 120)-(855, 176)
  652.     _PUTIMAGE (0, 0)-(431, 26), Sheet&, Bushes&, (424, 177)-(855, 203)
  653.     _PUTIMAGE (432, 0)-(863, 26), Sheet&, Bushes&, (424, 177)-(855, 203)
  654.     _PUTIMAGE , Sheet&, New&, (289, 363)-(336, 383)
  655.     _PUTIMAGE , Sheet&, PipeTop&, (339, 189)-(416, 224)
  656.     _PUTIMAGE , Sheet&, PipeTube&, (339, 225)-(416, 260)
  657.     _PUTIMAGE (0, 431)-(77, 395), PipeTop&, Pipe&(0) '         create bottom of upper tube image
  658.     _PUTIMAGE (0, 0), PipeTop&, Pipe&(1) '                     create top of lower tube image
  659.     FOR y% = 0 TO 395 STEP 36 '                                cycle through tube body of pipes
  660.         _PUTIMAGE (0, y% + 35)-(77, y%), PipeTube&, Pipe&(0) ' draw tube on upper pipe image
  661.         _PUTIMAGE (0, 36 + y%), PipeTube&, Pipe&(1) '          draw tube on lower pipe image
  662.     NEXT y%
  663.     _FREEIMAGE PipeTop& '                                      temporary image no longer needed
  664.     _FREEIMAGE PipeTube& '                                     temporary image no longer needed
  665.     _FREEIMAGE Sheet& '                                        sprite sheet no longer needed
  666.     Clean& = _NEWIMAGE(432, 768, 32) '                         create clean image holder
  667.     _DEST Clean& '                                             work on clean image
  668.     CLS , _RGB32(84, 192, 201) '                               clear image with sky blue color
  669.     LINE (0, 620)-(431, 767), _RGB32(219, 218, 150), BF '      create brown ground portion of image
  670.     LINE (0, 577)-(431, 595), _RGB32(100, 224, 117), BF '      create green grass portion of image
  671.     _DEST 0 '                                                  back to work on screen
  672.     Scenery(1).image = Clouds& '                               set scenery parallax information
  673.     Scenery(1).y = 457
  674.     Scenery(1).fmax = 8
  675.     Scenery(2).image = City&
  676.     Scenery(2).y = 510
  677.     Scenery(2).fmax = 4
  678.     Scenery(3).image = Bushes&
  679.     Scenery(3).y = 550
  680.     Scenery(3).fmax = 2
  681.     Scenery(4).image = HazardBar&
  682.     Scenery(4).y = 596
  683.     IF _FILEEXISTS("fbird.sco") THEN '                         does high score file exist?
  684.         OPEN "fbird.sco" FOR INPUT AS #1 '                     yes, open high score file
  685.         INPUT #1, HighScore% '                                 get high score from file
  686.         CLOSE #1 '                                             close high score file
  687.     END IF
  688.  
  689.  
  690. '----------------------------------------------------------------------------------------------------------------------
  691.  
  692. FUNCTION BOXCOLLISION% (Box1X%, Box1Y%, Box1Width%, Box1Height%, Box2X%, Box2Y%, Box2Width%, Box2Height%)
  693.  
  694.     '**
  695.     '** Detects if two bounding box areas are in collision
  696.     '**
  697.     '** INPUT : Box1X%      - upper left corner X location of bounding box 1
  698.     '**         Box1Y%      - upper left corner Y location of bounding box 1
  699.     '**         Box1Width%  - the width of bounding box 1
  700.     '**         Box1Height% - the height of bounding box 1
  701.     '**         Box2X%      - upper left corner X location of bounding box 2
  702.     '**         Box2Y%      - upper left corner Y location of bounding box 2
  703.     '**         Box2Width%  - the width of bounding box 2
  704.     '**         Box2Height% - the height of bounding box 2
  705.     '**
  706.     '** OUTPUT: BOXCOLLISION - 0 (FALSE) for no collision, -1 (TRUE) for collision
  707.     '**
  708.  
  709.     IF Box1X% <= Box2X% + Box2Width% - 1 THEN '              is box1 x within lower limit of box2 x?
  710.         IF Box1X% + Box1Width% - 1 >= Box2X% THEN '          yes, is box1 x within upper limit of box2 x?
  711.             IF Box1Y% <= Box2Y% + Box2Height% - 1 THEN '     yes, is box1 y within lower limit of box2 y?
  712.                 IF Box1Y% + Box1Height% - 1 >= Box2Y% THEN ' yes, is box1 y within upper limit of box2 y?
  713.                     BOXCOLLISION% = TRUE '                   yes, then a collision occured, return result
  714.                 END IF
  715.             END IF
  716.         END IF
  717.     END IF
  718.  
  719.  
  720. '----------------------------------------------------------------------------------------------------------------------
  721.  
  722. SUB CLEANUP ()
  723.  
  724.     '*
  725.     '* Removes all game assets from the computer's RAM.
  726.     '*
  727.  
  728.     SHARED Fbird&(), Pipe&(), Num&(), Medal&(), Plaque&, FlappyBird&, GameOver&, GetReady&
  729.     SHARED Finger&, ScoreButton&, ShareButton&, StartButton&, OKButton&, RateButton&
  730.     SHARED MenuButton&, PlayButton&, PauseButton&, HazardBar&, Clouds&, City&, Bushes&
  731.     SHARED New&, Clean&, PipeImage&, Ding&, Flap&, Smack&
  732.  
  733.     DIM x% '              generic counter
  734.     DIM y% '              generic counter
  735.  
  736.     _SNDCLOSE Ding& '                           remove game sounds from RAM
  737.     _SNDCLOSE Flap&
  738.     _SNDCLOSE Smack&
  739.     FOR y% = 0 TO 2 '                           cycle through bird image rows
  740.         FOR x% = 0 TO 7 '                       cycle through bird image columns
  741.             _FREEIMAGE Fbird&(x% + 1, y% + 1) ' remove bird image from RAM
  742.         NEXT x%
  743.     NEXT y%
  744.     FOR x% = 0 TO 9 '                           cycle trough 9 numeral images
  745.         _FREEIMAGE Num&(x%, 0) '                remove large numeral image from RAM
  746.         _FREEIMAGE Num&(x%, 1) '                remove small numeral image from RAM
  747.     NEXT x%
  748.     _FREEIMAGE Plaque& '                        remove all remaining images from RAM
  749.     _FREEIMAGE FlappyBird&
  750.     _FREEIMAGE GameOver&
  751.     _FREEIMAGE GetReady&
  752.     _FREEIMAGE Pipe&(0)
  753.     _FREEIMAGE Pipe&(1)
  754.     _FREEIMAGE PipeImage&
  755.     _FREEIMAGE Medal&(0, 0)
  756.     _FREEIMAGE Medal&(0, 1)
  757.     _FREEIMAGE Medal&(1, 0)
  758.     _FREEIMAGE Medal&(1, 1)
  759.     _FREEIMAGE Finger&
  760.     _FREEIMAGE ScoreButton&
  761.     _FREEIMAGE ShareButton&
  762.     _FREEIMAGE StartButton&
  763.     _FREEIMAGE OKButton&
  764.     _FREEIMAGE RateButton&
  765.     _FREEIMAGE MenuButton&
  766.     _FREEIMAGE PlayButton&
  767.     _FREEIMAGE PauseButton&
  768.     _FREEIMAGE HazardBar&
  769.     _FREEIMAGE Clouds&
  770.     _FREEIMAGE City&
  771.     _FREEIMAGE Bushes&
  772.     _FREEIMAGE New&
  773.     _FREEIMAGE Clean&
  774.  
  775.  
  776. '----------------------------------------------------------------------------------------------------------------------
  777.  
* fbding.ogg (Filesize: 8.1 KB, Downloads: 333)
* fbflap.ogg (Filesize: 4.61 KB, Downloads: 316)
fbsheet.png
* fbsheet.png (Filesize: 57.1 KB, Dimensions: 870x459, Views: 600)
* fbsmack.ogg (Filesize: 10.01 KB, Downloads: 308)

* fbird.ico (Filesize: 3.19 KB, Dimensions: 32x32, Views: 1078)
« Last Edit: April 29, 2020, 12:56:12 pm by TerryRitchie »
In order to understand recursion, one must first understand recursion.

FellippeHeitor

  • Guest
Re: Flappy Bird
« Reply #1 on: August 19, 2018, 01:59:28 am »
A classic! Thanks for reposting it here.

Nice that the "Rate" button redirects to this topic!

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: Flappy Bird
« Reply #2 on: August 19, 2018, 04:23:36 am »
Nice game! Can I ask, in what a PNG image is created for? Did you use some own image editor?

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Flappy Bird
« Reply #3 on: August 19, 2018, 08:52:58 am »
Ah! This looks familiar, right Johnno?

We had flappy flying day and night through 3 levels of pipes. Fun stuff!

Dang! tough game, I better check speed controls.

Append:
My bird has hell of headache!
« Last Edit: August 19, 2018, 09:06:02 am by bplus »

Offline Ashish

  • Forum Resident
  • Posts: 630
  • Never Give Up!
    • View Profile
Re: Flappy Bird
« Reply #4 on: August 19, 2018, 09:14:45 am »
Nice game! Graphics are also cool! :)
if (Me.success) {Me.improve()} else {Me.tryAgain()}


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

Offline TerryRitchie

  • Seasoned Forum Regular
  • Posts: 495
  • Semper Fidelis
    • View Profile
Re: Flappy Bird
« Reply #5 on: August 19, 2018, 12:10:18 pm »
Nice game! Can I ask, in what a PNG image is created for? Did you use some own image editor?

The game uses the PNG image as a sprite sheet holding all of the graphics needed for the game. I use .PNG images because of their ability to retain alpha transparency data.

I use a standard graphics program (PhotoImpact X3) to create PNG files. However, any graphics program will do, such as Photoshop, GIMP, etc..
In order to understand recursion, one must first understand recursion.

Offline TerryRitchie

  • Seasoned Forum Regular
  • Posts: 495
  • Semper Fidelis
    • View Profile
Re: Flappy Bird
« Reply #6 on: August 19, 2018, 12:19:51 pm »
Append:
My bird has hell of headache!

LOL, yes the game is too hard because the programming could use some tweaking.

For instance, collision detection should be made to be more accurate, and as Rob (Galleon) pointed out years ago it really should be using _MAPTRIANGLE to create the angles of the bird instead of separate sprites. I wrote this when hardware images were just becoming a thing in QB64 (mode 33). The game would also benefit from converting all the software images to hardware.

I cobbled the game together on a Friday night for lessons I needed for the upcoming weeks, so it was a rush job. I'm a bit rusty now in respects to QB64 so correcting these issues may be the perfect way for me to get back in the zone, so to speak. Hmmm...
In order to understand recursion, one must first understand recursion.

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Flappy Bird
« Reply #7 on: August 19, 2018, 06:16:36 pm »
The game is VERY good. I'm glad you said it was too hard... I thought it was my poor playing skills again... lol

Well done!

J
Logic is the beginning of wisdom.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Flappy Bird
« Reply #8 on: August 20, 2018, 12:23:27 am »
Some aspirin:

Find 576 change to 676  (two lines, 155 and 334)

Find -8 change to -5  (one line, 182)

Find 384) + 12 change to 184) + 112 (4 lines, 3 bunched together around 279 and 146)

Find .5 change to .3 (on line 188 only)

 
Flappy 272.PNG


From these settings, tweak higher levels of play towards original numbers.
« Last Edit: August 20, 2018, 12:29:35 am by bplus »

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Flappy Bird
« Reply #9 on: August 20, 2018, 03:49:56 am »
Cool.  I survived a little longer... Woo Hoo!!

I prefer acetylsalicylic acid, myself... fewer side effects...
Logic is the beginning of wisdom.

Offline TerryRitchie

  • Seasoned Forum Regular
  • Posts: 495
  • Semper Fidelis
    • View Profile
Re: Flappy Bird
« Reply #10 on: April 29, 2020, 12:57:31 pm »
I just updated the code and added an EXE ICO icon file. See the original post for changes/updates.
In order to understand recursion, one must first understand recursion.

Offline Dav

  • Forum Resident
  • Posts: 792
    • View Profile
Re: Flappy Bird
« Reply #11 on: April 29, 2020, 01:11:44 pm »
Cool!  I had forgotten about this one.  Thanks for re-posting it. 

- Dav

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Flappy Bird
« Reply #12 on: April 29, 2020, 01:31:59 pm »
Flappy Bird. I tried that years ago. I prefer the indoor version, where pipes are replaced by ceiling fans, but hey, thanks to "Progressives" we also have a new and improved outdoor version in the works, where ceiling fans are replaced by wind turbines. Now if I were a hobbyist, I'd modify the code even more, so the bird would only fly over a long line of parked cars. Moving the cars, to keep them clean, would be the goal. I never developed it, because I just couldn't think up an appropriate name for the game.

Pete
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/