In this game we are going to be flying a bird above a person walking below. Our bird will drop some ‘bombs’ on the pedestrian to score points.
We can use the bird sprite and make our own cool bomb with two costumes.
I created two simple costumes that will make it look like the bomb is falling from the sky and a second circle that will make it look like it splattered on the ground.
The bird will fly from left and right, we can use the keyboard pressed events to make this work. Since we are looking at making the bird move across the screen, we will use the change X block.
Left uses a negative number and right uses a positive number.
We want our pedestrian to walk along the bottom, so we’ll need to be able to change costumes. Since we want to change costumes, we can’t use the Glide block like we may have in the past. Instead we will have to check to see if she gets to the end of the screen and restart her walking.
We want to make sure that her costume changes to make it look like she is walking:
Next, we can use the same change X block that we used to move our bird, this time it will move the pedestrian across the screen.
We first move the pedestrian into the place we want them to start walking by using the go to X and Y blocks.
We can then test to see if the pedestrian touches the edge of the game, if they do, then we can reset them to the starting position.
We might introduce a bug into our game if we move the pedestrian back to left and touching the left edge of the screen. If we really want to avoid this, we can check to see if the pedestrian is near the right hand side by checking the position.
Next we can make the pedestrian walk different speeds by introducing some random blocks.
Run and test this out, notice that the pedestrian stands still before being reset?
We can change this by adding some hide / show blocks:
Now our pedestrian is moving very smoothly.
We want our bird bomb to drop from the bird, so we need to make sure the bomb is always following the bird until we press the space key.
We also want our bomb to be hidden until it’s time to start dropping.
We will create a clone of our bomb that we will send to the ground. We can use the ‘when I start as a clone’ hat block to set this up.
Now we can make the bomb fall to the ground until it touches the edge of the screen, then we switch to the fall image and make it look like the bomb went splat. After a second we delete the clone to clear the screen.
Pedestrian hit by a bird bomb:
We can add a test to see if the pedestrian is hit by a bomb and increment a hit score. I’ve made my pedestrian change colour when they are hit.