Game Programming‎ > ‎FlappyBird‎ > ‎

Flappy Bird - Gravity Control

Advanced Enhancements for Flappy Bird

1. Adding a Gravity Control for the columns

       1.   Add a “slider” button, add a label field with contents "Gravity", This will control the birdVerticalSpeed

                 

                2. Set the name to "Gravity" and the start/stop values to 1 and 10

                         
                                                

                      3. Right-click the slider and add the following script to it:

on scrollbarDrag x

     global gravity

     put x into gravity   
 scrollbarDrag


or if you already have it as a variable - birdVerticalSpeed, use that


on scrollbarDrag x

     global birdSpeed

     put x into birdSpeed   
 scrollbarDrag


                 2. On the card script at the top, add the global variable for gravity

local birdDirection                     // up = -1 down = 1

local gameRunning

             global gravity

or change your variable - birdVerticalSpeed from local to global

local birdDirection                     // up = -1 down = 1

global birdSpeed

local gameRunning

           

          3. In the preOpenStack handler add the following line:

put 4 into gravity

or 

put 4 into birdSpeed


            4.    In the “moveCols” handler:

                        Change the number (4) to the variable (gravity)

 

Comments