Hello! I will Teach you how to make a Flappy game on Scratch!
What you’ll need
- A computer, so you can do it 🙂
- Offline Scratch or/and a Scratch account, Click here to go to Scratch!
- A MIND, so you know what you’re doing.
- Internet, so you can follow this Tutorial.
Now lets get started!
1.Make a new Project and delete the Cat.
2. Make a new sprite for the player
3. Make sure you have 3 costumes: Alive, Flap and Dead
4. Draw your background with 3 costumes: Menu, Playing & Retry.
5. Make the Pole Sprite and make sure it has two costumes like this, one up and one down
6. Now Who said this was an art class? We are now about to start coding! First in the Stage, add a “when start clicked” block and a “switch costume” block after. Set the costume to menu.
7. Make three variables: IsDead, Score & Velocity. Set IsDead to NO and Score to 0. We don’t have to worry about velocity yet. Add these two blocks after the costume block.
8.Add a “wait until” block and set the Boolean with “key space pressed”. Add a costume block and switch it to Playing. Put a “broadcast and wait” block and set it to broadcast ‘game’. Add these after the variables.
9. Your stage code should look like this.
10. Now go into the flappy sprite or ‘sprite 1’ and add these blocks: “when i receive game”, “set size to (200)%” and “show”.
11. Add a “when start clicked” and “hide” block with it. Add the “go to” block you see below to the end of the “show” block.
12. Add the code below so the flappy bird can check if it wants to flap.
13. Now that the birdie broadcasts flap. insert the code below. it is:
when i receive [Flap],
set [Velocity] to [10],
repeat until <<touching color> or <touching [Sprite2]?>>{
change [Velocity] by (-1),
change y by (Velocity),
}[].
, equals next line, or if this is confusing just look at the picture below.
14. Now go to the Pole sprite and add “when start clicked” and “hide”. Also add the code below.
15. Make sure your code from the last step now looks like below!
16. Go back in sprite 1 or the flappy sprite and add this after the “key space pressed” “broadcast flap” or look at the picture below.
17. Now to make it look like its flapping add this code before the “change velocity by -1”.
18. Test out your game. So far it will let you play if you press your space and flap if pressed space, but when you hit the ground or pole the game stops. 😦
19. Add this code to your pole sprite.
20. OMG its step 20!!!! Add a “clear graphic effects” block after the “show” in the “when i receive” block.
21. In the stage. Add the following code.
21.5. Now save and call it a good name! If you’re offline and don’t have a scratch account or if you’re not a Scratcher yet, skip the last few steps otherwise you may continue.
22. Go online into your scratch account then open your project or make a new one and upload it.
23. Now make a new variable called highscore and set it as a cloud variable.
24. Add the following code in the stage.
25. Now play with your friends and family and see who can go the highest. You can also add some other code like music and maybe the poles could go faster each time, Its up to you.
Farewell Scratchers! Check out my profile!