Chapter 9. Building a Physics Car Game with Box2D and Canvas

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 ...

Get HTML5 Game Development by Example : Beginner's Guide - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.