Newtonian gravity is way cool. So, cool that I will show you how you can make your own HTML5 canvas game simulating gravity. Don’t worry it won’t be hard. I will write down every step which is needed for our game.
It should be noted, that HTML5 is not a really new technology, but the canvas might still not work everywhere as expected (blame IE).
The game that we will write, needs a way to represent forces: velocity, acceleration and etc. The tool that we need is vectors.
I won’t really get into the vector basics, you must already be familiar with the easy stuff:
- vector addition (therefore substitution)
- multiplication (and division)
- scaling (multipling a vector with a scalar number)
We will need some more than that, but this is the basics.