Understanding the physics engine
When building a physics-based game, it requires a different way of thinking about how you go about creating things. So far, we have focused on applying movement to an instance by either teleporting it via the X/Y coordinates, or by changing the speed
, vspeed
, and hspeed
variables. When we use the physics engine, these properties are ignored. Instead, the system itself deals with movement by applying a force onto the instance. That instance will react to the force based on its own properties and will act accordingly.
Additionally, the direction of the world coordinates is not the same in physics world. Zero degrees in the GameMaker standard physics world indicates a direction of right, whereas in the Box2D physics world, zero degrees indicates up, as can be seen in the following diagram:
To fully understand how the Box2D physics engine works, we need to take a look at the following four components that it is comprised of:
The physics world
Fixtures
Joints
Forces...