how to code flappy bird on scratch

4. Make a background for the end of the game

Additionally, let’s create a brand-new custom background to signify the game’s conclusion. To add a background, hover over the circle in the bottom right corner, just like we did when we created the custom sprite, and choose the option that looks like a paintbrush, third from the top. Use the second column’s “text” option to inform the user that the game has ended.

how to code flappy bird on scratch

Flappy Bird Basic Code Lots of people have tried to make a flappy bird game, but have struggled with the code. Here is a basic code that you can use- but make sure to give credit to me if you do use it. For the bird:

Last edited by EmmaGymnast (Tháng 1. 28, 2017 19:06:05)

6. Take care of details for starting and ending the game

Now that we have a new backdrop, let’s revisit the parrot code and make some adjustments. “When backdrop switches to backdrop2” is the new Event block that we wish to add. The “hide” Looks block should then be attached since we don’t want anything to show up after the game is over.

We need to add a little more code in between the “when green flag clicked” and “forever” blocks that we previously added. The “show” Looks block is what we need first since it ensures that the parrot appears at the beginning of every game. Then we want another Looks block “switch backdrop to backdrop1”. By doing this, the game’s ending backdrop will be eliminated.

Afterwards we want the “go to x/y” Motion block. This will set the starting location of the parrot. Make sure the parrot begins on the left side of the screen and somewhere in the middle vertically; the precise coordinates don’t matter. We set x to -190 and y to 30.

how to code flappy bird on scratch

how to code flappy bird on scratch

Click on that sprite to add more blocks to the pillars; the remaining code will add more features. When the game is over, we want the pillars to vanish, just like with the parrot. The blocks “when backdrop switches to backdrop2” and “hide” can be used to accomplish this.

Place the “show” Looks block between the previously added “when green flag clicked” and “forever” blocks to display the pillars when the game launches.

how to code flappy bird on scratch

how to code flappy bird on scratch

FAQ

What code does Flappy Bird use?

Flappy Bird is so ridiculously simple that you could implement in any language capable of displaying graphics. So that includes Python, C#, Java and on an on all the way up to C++ and down to assembly.