Game Development Reference
In-Depth Information
Engage thrusters
To simulate gravity, you could use a realisic mathemaical formula. But it can be hard
to figure out, and in a simple game, it often isn't needed. We are going to create a
good-looking parabola trajectory with just a simple calculaion and some trickery.
To simulate the pull of gravity, we are going to use the built-in imer variable. This imer will
start couning seconds when the game is started, but we can reset it to start couning again.
We will be using the increasing number as a constantly increasing pull, which will eventually
start dragging the cannonball downwards.
The steps to create the trajectory are as follows:
1. We select the cannonball sprite to add to its scripts.
2. Ater the move () steps command, add a change y by () block. This will cause the
cannonball to verically move a bit ater taking its steps.
3. Place a () * () (muliplicaion) operator in the box.
4. Then put the imer variable in one of the operator slots.
5. In the other slot, fill in a number manually. Try a few numbers, just for the fun of it,
and see what happens.
In my opinion, the number -5 has the best result. But if you disagree, you're free
to choose another number. Just make sure that the number is negaive, because a
posiive number will cause the cannonball to loat ever faster upwards.
6. To reset the imer ater the cannonball has hit something, add a reset imer block at
the start of the loop.
 
Search WWH ::




Custom Search