#### Overview of this book

Raspberry Pi Projects for Kids Second Edition
Credits
www.PacktPub.com
Preface
Free Chapter
Getting Started with Raspberry Pi
Animating with Scratch
Making Your Own Angry Birds Game
Creating Random Insults
Making an Interactive Map of your City
Building Beats with Sonic Pi
Index

The next thing for us to do is to give our character a more interesting flight path. The game would be too easy (and no fun) if we just flew in a straight line through all the obstacles.

### Gravity

First, let's add some gravity. Gravity has the effect of pulling objects down toward the ground. How can we model gravity in our game? The answer lies in the way we split our speed into both x speed and y speed. Gravity will only affect y speed, our speed in the up-down direction, so we can leave x speed as it is. Since the y coordinate increases as we move up but gravity pulls us down, we want gravity to keep subtracting a small amount from y speed. Add the following code block inside the forever block of your second script:

Try out the game now. You should arc through the air until you hit one of the edges of the screen. You may tweak the number in this code block if you wish; a higher negative number will give you stronger gravity. What happens if the number is positive?

Next...