Instructions to create Flappy Bird game on Scratch
Scratch is a programming language that allows users to create stories, animations, games, … in their own way. In this article, let’s find out How to create Flappy Bird game in Scratch. This is a game that requires control of a bird or any character with an insulation key, successfully moving through the pillars and receiving a number of points.
Instructions to create Flappy Bird game on Scratch
Select a Sprite (character)
The first thing to do is to choose a sprite, the character will move through the piers in the game, by clicking the circle Dog icon to Choose a character. Users should choose Sprite with 2 costumes to have different moving images.
To suit the game, people should choose Sprite as birds, in this guide is parrot. If you want the parrot to fly through the pillars, order Size of Sprite into 30.
Add code to create flapping motion
After selecting the character, click on the parrot icon in the lower right corner area, to ensure the addition of the code blocks to the right position.
Start with block When clicking on the blue flag from Eventcontinue to choose continuous in Control So Sprite always has Flappy movement as long as the game is taking place.
Inside continuously, set blocks If then/ if not then from Control. Press arrow button In that block and choose white key Let Sprite fly every time pressing the distance.
Use block Change y in quantity and set numbers into 20. Let the parrot look like flying, after changing y, choose the block Transfer costumes to Parrot-B in the item Display.
To make the parrot fall a bit when the player does not press the distance, place the block Change y in a quantity -5 under otherwise. To create movement looks like a parrot flying, choosing the block Switch to Parrot-A costumes.
Create pillars that Sprite will fly over
The next step, people need more pillars to fly through by creating a custom Sprite. Mouse round button Add Sprite in step 1 and select Draw.
Use Rectangular icon From the final option in the tools in the left area to draw a cylinder. Refer to the image below to create pillars from rectangles.
Everyone can use Ctrl + C Copy and Ctrl + V To paste rectangles, to ensure the same size.
To adjust the position and size of the shapes, press Arrow icon First in the left area.
Background for the end of the game
Create a new custom background that indicates the end of the game. Press the game button Choose a backdropand choose Draw.
Select T In the left area to add a written display notice to the player that the game has ended.
End of the game if the parrot touches the pillar
Click the tab code To return to the area to add the code, then click the Sprite of the pillar to add the code to it.
To make the game stop when the parrot touches the column to select the following blocks: When clicking on the blue flag > continuous > if then > Set Being in Parrot? Inside> Change background to backdrop2 > Stop it all.
Pay attention to the details to start and end the game
Click Sprite parrot to make some changes based on the new background. Add 2 blocks When the backdrop turns to backdrop2 and hidden In order for nothing to display after the game ends.
Continue to add the code below to Sprite parrot so that the parrot is displayed at the beginning of each game and set the original position.
Then repeat the two sections above for Sprite pillar so it also displays the starting position and disappears when the game ends.
Place the pillars to move on the screen
To let the pillars move on the screen, add the following code to Sprite pillar.
Create a score -calculating variable
Finally, for players to know their scores, need to add a variable code to Sprite parrot.
First move to the item Variables > Select Create one variable.
In the window to create new variables, enter Score in the box and press OK.
After completing this step, people will see a small label at the top left of the scene. Finally, import the following code blocks and Flappy Bird game has been completed.




Post Comment