Flappy Bird

Scratch English # 1

We are making Flappy bird in Scratch
If you do not know Flappy bird, check out https://flappybird.io/

Create a new scratch project by going to https://scratch.mit.edu/ and press "Create"
Create button

Draw a Flappybird

Create a new project and start by deleting the cat. Cat sprite with trashicon

Then we press the Paint button. Dropdown with Paint

Then we enter drawing mode for a new sprite. Here we choose the Circle tool. Circle tool

You can choose a different color by pressing the Fill tool and pulling the sliders. Sliders that change color

A Flappybird really just consist of a bunch of circles. Start by making a circle for its body with an oblong purple circle. Drawing the body of our sprite

Then we create a white circle as its wing, and a white circle for its eyes. Figur med vinge og øje

Use the Brush tool to make a dot for its eye. Brush tool

Make an orange circle for its beak. Done flappybird

Pay attention to the fact that we are in costume mode. You cannot make block code until you enter the other mode, by pressing the tab. Costume mode

Make Flappybird Gravity and Jump

We will pull blocks from the code page on the left, to make gravity. Pull “When FLAG clicked” in to start a new sequence of code. This sequence will be responsible for our gravity behaviour. In the sequence we will use a “forever” and a “change y by” block to make our sprite fall downwards. Codeblocks

To make our gravity realistic, we need it to accelerate towards the ground. We do this by using variables to alter the speed. Make a new variable by pressing “Make a Variable” and name it “upspeed”. Make a variabel knap

For our block sequence, pull a change variable block into forever, so that the upspeed will be smaller in every iteration of the forever loop. Then we change our y position with the upspeed. Changed blocksequence

Now our gravity works! The negative upspeed means we fall towards the ground.

To get our sprite back to start, we need to make a new block sequence in charge of it. Pull in a new “When FLAG clicked” and put in a “go to x, y” and set it to 0 for both values. This will reset our position. Second blocksequence

Also reset our upspeed variable to 0. Changed second blocksequence

Now we create a third block sequence in charge of jumping. We use the “When space pressed” block to start the code. We pull in a “Set variable” block and give it a value of 10, this means our sprite will go upwards until gravity makes its speed negative again. Third blocksequence

Our code should now look like this. Our code

Draw an obstacle

Press on new sprite and press paint. Dropdown with paint

Choose a green color and a black border. Chosen colors

Obstacles in Flappybird is really just a bunch of rectangles made to look like pipes. Use the Rectangle tool. A green square

Draw more rectangles so we have a pipe obstacle. An obstacle

You can exit drawing mode by pressing the code tab. Code and costume tabs

Move Obstacle

First we create a new block sequence that will make our obstacle start in the right side. Your x position should be around 250. Start block sequence

Then we make another block sequence that moves our obstacle towards the left. This is the negative x-direction. Moving block sequence

Lastly we make a block sequence that moves our obstacle back to the right when it hits the left side. Resetting block sequence

Now our code should look like this. Completed code

Lose by hitting obstacle

Make sure our sprites are named in a way that makes sense. You can change a name by pressing and writing in the Sprite field. Sprite overview

Make a new block sequence on the flappybird sprite. Use a “forever”, an “if”, and then use “touching” and choose pipe, or whatever you named the obstacle. If this is true, we stop everyhing. Lose by touching block sequence

De basale elementer i flappybird er nu færdigt! og vi kan spille spillet. The basic elements of flappybird is now done! We can play the game. Completed game


Our obstacle code should look like this. Completed obstacle code

Our flappybird code should look like this. Completed flappybird code