Hack Flappy Bird on the DIY Gamer Kit
by techwillsaveus in Circuits > Arduino
2612 Views, 6 Favorites, 0 Comments
Hack Flappy Bird on the DIY Gamer Kit
![Hack your games!](/proxy/?url=https://content.instructables.com/F1Q/JDBB/IDFSFPMN/F1QJDBBIDFSFPMN.jpg&filename=Hack your games!)
This tutorial will show you how to play around with and change the settings of the Flappy Bird game that is included in the DIY Gamer library.
For this tutorial, you'll need a Gamer and a USB cable. Make sure you've installed the Gamer library and that you've set it up correctly with Arduino. You can find the instructions here.
Open and Upload Flappy Bird
![001 Open Flappy Bird.png](/proxy/?url=https://content.instructables.com/FBB/0BWA/ID7UVTT6/FBB0BWAID7UVTT6.png&filename=001 Open Flappy Bird.png)
The first thing we need to do is open up the Flappy Bird sketch included within the library. Go to File > Examples > Gamer > FlappyBird. The sketch will open up, and you'll notice that it's got quite a few comments to help you figure out what's going on.
Go ahead and upload the sketch with the Upload button (the second button on the top left corner of the Arduino window).
It's a good idea for you to get familiar with it and play around. Get a feel for it. How do you find the difficulty of the game? Try and get a good high score!
Change the Bird's Flying Speed
![002 Bird Flying Speed.png](/proxy/?url=https://content.instructables.com/FIF/GKIE/ID7UVTT9/FIFGKIEID7UVTT9.png&filename=002 Bird Flying Speed.png)
What to change how fast the bird flies? change the flyingSpeed variable located at the top.
This number in represents how long the the delay is between each step in milliseconds, meaning the larger you make the number, the slower the bird will be.
int flyingSpeed = 150;
Tip: flyingSpeed = random(1000); will generate a random speed every game, who know how fast it will be!
Change the Gap in the Wall
![003 Gap Size.png](/proxy/?url=https://content.instructables.com/FCC/541S/ID7UVTTC/FCC541SID7UVTTC.png&filename=003 Gap Size.png)
To change the gap, change the number initialised to int gapSize . The bigger the number, the wider the gap
int gapSize = 3;
Change the Thickness of the Wall
![004 Thickness.png](/proxy/?url=https://content.instructables.com/F1N/P7RD/ID7UVTTD/F1NP7RDID7UVTTD.png&filename=004 Thickness.png)
To change the thickness of the wall, change the number initialised to int wallThickness . The bigger the number, the thicker the Wall.
int wallThickness = 2;
Play With Gravity
![005 Gravity.png](/proxy/?url=https://content.instructables.com/FAT/4LI2/ID7UVTTE/FAT4LI2ID7UVTTE.png&filename=005 Gravity.png)
Increase the gravity affecting your Flappy Bird's flight by increasing int gravity. Be warned, it becomes hard very quickly!
int gravity = 1;
Look Through the Functions in the Main Loop
![006 Loop.png](/proxy/?url=https://content.instructables.com/F4S/CLCA/ID7UVTTF/F4SCLCAID7UVTTF.png&filename=006 Loop.png)
The main loop is where everything happens in your game. This is surrounded by the boolean isPlaying. Making sure only certain things happen when in game play and others when not.
gamer.clear(); moveWall(); drawWall(); updateBird(); detectCollision(); recordScore(); drawBird(); gamer.updateDisplay(); delay(flyingSpeed);
gamer.clear() : Clears previous screen, ready for new frame
moveWall() : moves wall one step from right to left
drawWall() : creates new wall
detectCollision() : checks if bird has hit the wall
recordScore() : updates score if bird has passed the wall
drawBird() : moves bird one step from left to right
gamer.updateDisplay() : prints newly determined frame based on all above functions
delay(flyingSpeed) : refresh rate of screen