Jumping Bird

In this project, we're going to learn how to create a jumping bird game.

Notes for teachers: Give students 5 mins to play and familiarize them with the game.

1) Set up the stage, using the Preset if you want to use the same sprites in this example.

2) Lets code our "Angry bird"!

Using "When__key pressed" under events. when "left arrow" is pressed, turn bird up by 1 degree

Using "When__key pressed" under events. when "right arrow" is pressed, turn bird down by 1 degree

Create a variable called "launchSpeed". (You will see how launch speed has been used later in the game)

Using "When__key pressed" under events. when "up arrow" is pressed, adding '0.1' to launchSpeed until it reaches 20

Using "When__key pressed" under events. when "down arrow" is pressed, subtracting '0.1' to launchSpeed until it reaches 1

3) After setting our launchSpeed, make bird "repeatedly" moving forward until it "touching edge".

After the bird "touched the edge", bring the bird to the original place and get ready for next launch.

4) Create a variable called "numPigs", which means "number of pigs", since ""number of pigs" is too long, we use "numPigs" instead.

Using numPigs variable and combination with "repeat" block, create same amount of pig clones as set in "numPigs". Hide the original pig.

"When start a a clone", make clones show at any "random x and random y" position at right side of the screen(so they wouldn't show up at the left side of cactus).

Use "pick random" and "set size to" block to make clones have different size.

Use "pick random" and "set color effect to" block to make clones have different colors as well.

5) Lets make the game work!!!

As we can see, our game is not quite working yet. We need to couple of things before it starts working.

First, let code up our pigs, so that when bird touches a clone, our "number of Pigs" go down by one.(Hint:try "wait until" block under control.)

If number of pigs reaches 0, broadcast a message "Game over", we will use this message for later.

But you see, now brings another question, the bird can go straight through the tree, which is not what we want.

Do you know how to fix it?

6) Now we fix the problem at the step 5, we face a new problem, is that bird cannot reach the other side of cactus.

We are solving this problem by mimic Gravity!

7) Code up "Game over" and make the game complete! Count how many launches you have used.

8) Bonus step: play with gravity.