Flappy Bird

by jacob_hartman in Craft > Digital Graphics

664 Views, 3 Favorites, 0 Comments

Flappy Bird

Screen Shot 2021-05-06 at 9.02.53 AM.png

How to make a fun Flappy bird game in Scratch.

Supplies

Charged computer

Screen Shot 2021-05-06 at 8.58.21 AM.png
Screen Shot 2021-05-10 at 9.31.34 AM.png

For the first step you want to pick a back drop and a sprite. Next, you want to click on the sprite and start coding. To start the code you want to put a when (green flag is clicked). the reason why you want this first is because what ever is under that will do its job when the green flag is clicked. Then you want to make a variable called score. You want to put (set score to 0) and (set gravity to 0) under (green flag is clicked). These blocks of code mean that the score and the gravity will reset every time you lose, meaning you have to restart the game. You then want to add a (go to x: -15 y: 9), ( Forever loop), and (change gravity by -1). This block of code means that when you lose the game and ant to play again that the sprite will always start in the same place ass last time. Also, this code is making the sprite fall. Next you want to add (if touching Unknown then Broadcast game) and if touching unknown 2 then broadcast game). The unknown and unknown 2 is my lava and the spiret can not touch the lava. If the sprite touches the lava then you lose the game. When it says (Broadcast game) that means that once you hit the lava then and end game screen will show up.

Screen Shot 2021-05-06 at 8.58.37 AM.png

Next, you want make it so that the sprite can go up and not just fall so it can get over the lava. you want to add (When green flag is clicked) (forever loop) and put (If key space pressed then) into the (forever loop). Next, add (set gravity to 8) and (wait until not key space pressed). This code is saying that when you press the space bar then the sprite will go up. The last line of code is making it so you can not hold down the space bar. You have to click the space bar for the sprite to move up.

Screen Shot 2021-05-06 at 8.58.54 AM.png

The next step is to create the pillars that the sprite will have to go over. You want to add these code lines (when green flag is clicked), (forever loop), (create clone of myself), and (wait 2.5 seconds). This line of code is saying that a pillar will spawn every 2.5 seconds.

Screen Shot 2021-05-06 at 8.59.02 AM.png
Screen Shot 2021-05-10 at 9.25.48 AM.png

Now, you want add some more code for the pillars. The code you want to add is (When I Start the clone) (show)(go to x: 240 y: pick random 100 to -100), (forever loop), (repeat until x position < -240), (Change x by -5), and (delete this clone). These lines of code are making the pillars different highest each time they spawn in the game, and making them disappear one the spiret passes the pillar.

Screen Shot 2021-05-06 at 8.59.12 AM.png
Screen Shot 2021-05-10 at 9.17.55 AM.png

This step will show you how to make the score bored work. The codings blacks needed are (When I start as a clone), (forever loop), (if x position < -240 then), (change score by 1), and ( wait 1 second). These lines are saying once the spiret is infront of the pillar then the the score will change by 1.

Screen Shot 2021-05-06 at 8.59.55 AM.png
Screen Shot 2021-05-10 at 9.13.48 AM.png

Finally, you want to add an end game when you hit the lava. You want to click the spiret and then hit custom. You then want to fill the screen with black paint and and then type "game over" in white. Once this is done, you want to put some code blocks down. The code blocks are (when I receive game), (show), (stop all), (when green flag is clicked), and (hide). This code is saying that when you hit the lava you want to stop all and show your End game page. It is also saying that when you click the green flag that it will hide so you can start over in your game.