2D Physics Engines is a hot topic in game development. With the help of a physics engine, we can easily create a playable game by just defining an environment and a simple rule. Taking existing games as examples, players in the Angry Birds game fly birds to destroy the enemy's castle. In Cut the Rope, candy drops into the monster's mouth to progress to the next level.
In this chapter, we will learn the following topics:
Installing the Box2D JavaScript library
Creating a static ground body in the physics world
Drawing the physics world on the Canvas
Creating a dynamic box in the physics world
Advancing the world time
Adding wheels to the game
Creating the physics car
Adding force to the car with a keyboard input
Checking a collision in the Box2D world
Adding level support to our car game
Replacing the Box2D outline drawing with graphics
Adding a final touch to make the game fun to play
The following screenshot shows what we will get by the...