Project 265: Gravity Dodger

6. Define project variables

Instead of just using traditional motion blocks, we're going to simulate our movements with physics. Can you figure out which variables we will need to create for our hero & enemy?
Starting point file for this challenge

Your goal

Steps

1. Create hero variables

Take a look at the picture below, you should see that the arrow grows bigger the faster we move Left or Right.   This is a representation of  Velocity, or speed with a direction.   When I hold a key in our game the speed changes,  so we can say the keys affect the acceleration of the character.  We need to create a local variable that just applies to this "hero" Sprite to keep track of this speed.  We'll call our variable "X Speed".  

2. Create Enemy Variables

Take a look at the picture below, you should see that one of the arrows gets bigger the faster we fall.   Just like the last picture this is a speed.  We need to create a local variable that just applies to the "enemy" Sprite to keep track of this speed.  We'll call our variable "Y Speed". 

3. Create Enemy Force Variable

What other about the tiny arrow in the picture? That was a representation of Gravity!  It is the force that pulls things down while they are in the air, and keeps us on the surface of Earth.  Gravity is constantly changing the "Y Speed" of the object falling, it was why the arrow is getting bigger and bigger the further that the ball falls.  Make sure you make a "Gravity" variable and that it is local to the "Enemy" sprite.

4. Create time variable

We also want to know how long our hero survives before being destroyed by the enemy. Do you think that we should create a global or local variable?

5. Check you Have 4 Variable

Switch between sprites and check that you have four variables.   Make sure that Gravity and Y Speed are local to just the enemy.  Otherwise the clones will behave weird.

6. Delete This

Since variables store information, we are going to want to change them to a certain number. Think about what we might change our project variables (Time, X Acceleration, Y Speed & Gravity) to.