Table of Contents

Make Flappy Bird Game Using Human Body Detection Extension in PictoBlox

Flappy Bird Game Using Human Body Detection
Project Description
Learn how to make your own version of Flappy Birds using PictoBlox’s Human Body Detection extension in this video tutorial. Control the bird with your nose!

Introduction

I’m sure many of you might be familiar with Flappy Birds – if not the game, then at least the viral Instagram filter in which you control the bird using your nose. That is exactly what we are going to make in this video. 

We’re going to make our version of the flappy bird game using PictoBlox’s Human Body Detection extension in which we will control the bird using our nose.

Prerequisites

You’ll need the following things to make the make Flappy Bird Game:

  1. A laptop or a computer with a camera.
  2. The latest version of PictoBlox, which you can download from here.
  3. A good Internet connection.

Setting Up the Project

Let’s begin by setting up the project.

  1. Open PictoBlox
  2. Click on the board button and select evive.select evive as board
  3. Click on the Add extension button.
  4. Choose the Human Body Detection Extension and wait for a little while till the models get loaded.Human Body Detection Extension

Setting Up the Stage for the Flappy Bird Game

In this video, we will mainly focus on writing the script to control the bird with the nose. We have already written the script to set up the stage and project. You can download the script from the link given here.

  1. Once you have downloaded the script, go to PictoBlox.
  2. Choose the File option to open up the downloaded script.

Once you open the script, you will notice a lot of sprites and their scripts.

We will briefly understand them and go back to writing our main script.

Logo of the flappy bird Sprite

The logo appears every time we start the game by clicking on the green flag. With the start of the game, the score is set to 0.flappy bird logo

The Bird Sprite

This sprite is the hero of our game, we will discuss the scripts into this sprite in the later part of the project.bird sprite

The Floor Sprites

The next two sprites are for the floor and the scripts written in them make them move continuously.floor sprite

Start Button Sprite

Upon clicking the start button, the game starts and the pipe hurdles start moving.Start button sprite

Pipe Hurdles Sprites

The next three are the pipe sprites. On clicking the green flag, these sprites should be hidden. As soon as the game begins, they should begin to move in continuously by changing the Y position randomly.Pipe Sprite

Score Sprite

The next two sprites show the score of the player. As soon as the bird crosses the hurdle of pipe the score should increase by changing the next costume. We have used two numbers of sprites to show the score in two-digits. You may notice that we have used numbers as costumes, you can simply display the score in the variable too.number sprite

Game Over Sprite

The next sprite if the game over sprite that should appear as soon as our bird touches any of the pipe sprites.game over sprite

Title Sprite

This is an optional sprite to make the stage look better. You can name the game or add the title sprite according to your choice.title sprite

Writing the Script for the Flappy Bird’s Bird Sprite

Now, let’s come back to our main bird sprite.

Making the Bird Move

Firstly, we will first set up the bird sprite as soon as the game begins.

  1. Thus, drag and drop when I receive () block from the Events palette and choose begin game from the drop-down.
    Making the Flappy Bird Script in Scratch
  2. Now to make the bird move forward, place point in direction () block from the Motion palette.
  3. From the Looks palette, place show block.
  4. Also, to bring the bird to the front layer, place go to () layer block below the show block. Choose front from the drop-down.Script for Flappy Bird in Scratch
  5. Now, set the initial position of the bird to x as 0 and y as 0 using the go to x () y () block from the Motion palette.Script for Flappy Bird in Scratch
  6. Now, to make the bird look like it is flying, place a forever block from the Controls palette.
  7. Next, place the next costume block from the Looks palette into the forever block.
  8. To make the costume change visible, place the wait () block from the Controls palette, and write 0.05 into the space given.
    Making the Flappy Bird Script in Scratch
  9. The final script will look like this:Making the Flappy Bird Script in Scratch

Controlling the Bird Using Nose

Now, let’s make another script in the bird sprite to control it using our nose whenever we click on the Start button.

  1. Drag and drop when I receive () block from Controls palette, choose game from the drop-down.Control Flappy Bird with Nose
  2. To turn on the video feed, from the Human Body Detection palette, drag and drop turn on video on stage with () % transparency block replace 0 with 25.Control Flappy Bird with Nose
  3. To continuously detect the position of the nose. Drag and drop forever block from the Controls palette.
  4. Drag and drop the analyse image for human pose from () block and choose camera from the drop-down.Control Flappy Bird with Nose2
  5. And set the y position of the bird as the y position of the nose. Drag and drop the set y to () block from the Looks palette.
  6. Into the input, place Y position of () of person () block from the human body detection palette. Choose nose from the first drop-down and from the second.Control Flappy Bird with Nose
  7. The complete script will look like this:
    Control Flappy Bird with Nose

Script when the Bird touched the Pipes

Now, what happens when it touches the sprite. Thus, let’s make a small script for the same.

  1. Duplicate the above hat block and remove all the blocks below it.
  2. Place a forever block from the controls palette.
  3. Place an if arm from the Controls palette.
  4. Place touching color () ? reporter block from the Sensing palette into the if arm picks the color of the pipe’s border as using the color picker option.Color Picker Option
  5. If it touches the pipe, the bird should stop moving a.k.a all the scripts of the bird should stop. Thus from the controls palette place stop all into the if arm.Control Flappy Bird with Nose

With this our script is complete. Click on the green flag and start playing.

Conclusion

This project helped you understand how to control the Flappy Birds game with your nose using Pictoblox’s Human Body Detection extension. We set up the stage with various sprites, wrote the script for the bird sprite to make it move, another script for controlling the bird with our nose, and made a script for when the bird touches a pipe. By the end of the project, our Flappy Bird game was complete and ready for you to play.

Beat my score and share your video with us in our Facebook community here.

Project Downloads - Code and Files

Code LabelCode File
Setting Up Flappy Bird Project and Stagehttps://ai.thestempedia.com/wp-content/uploads/2023/05/Flappy-Bird_Stage-2.zip

Explore Related Projects by STEMpedia

Learn how to make a self-driving car using PictoBlox and the Recognition Card Extension. Create a stage resembling a street and program John the instructor to guide the user through selecting lanes and recognizing number cards.
Learn how to create a virtual doctor using Natural Language Processing (NLP) in PictoBlox. Train the text data for diseases and build a text classifier.
Learn how to make a face recognition-based attendance system using micro: bit in PictoBlox AI. Track attendance by scanning faces and storing data in Excel.

Explore Community Projects