HTML and CSS Reference
In-Depth Information
Objective complete - mini debriefing
We have deined our irst physical world with one staic object and one dynamic object that
falls to the botom.
A staic object is an object that is not afected by gravity and any other forces. On the other
hand, a dynamic object is affected by all the forces.
Defining gravity
In reality, we have gravity on every planet. It's the same in the Box2D world. We need to
deine gravity for the world. This is a ball-shooing game, so we will follow the rules of
gravity on Earth. We use 0 for the x-axis and 9.8 for the y-axis.
It is worth noing that we do not need to use the 9.8 value. For instance, we can set
a smaller gravity value to simulate other planets in spaceâ€”maybe even the moon; or,
we can set the gravity to zero to create a top-down view of the ice hockey game, where
we apply force to the puck and benefit from the collision.
Debug draw
The physics engine focuses purely on the mathemaical calculaion. It doesn't care about
how the world will be presented finally, but it does provide a visual method in order to
make the debugging easier.
This debug draw is very useful before we use our graphics to represent the world.
We won't use the debug draw in producion. Actually, we can decide how we want to
visualize this physics world. So far in this topic, we have learned two ways to visualize
the game. The first way is by using the DOM objects and the second one is by using the
canvas drawing method. We will visualize the world with our graphics in later tasks.
Understanding body definition and fixture definition
In order to deine objects in the physics world, we need two deiniions: a body deiniion
and ixture deiniion.
The body is in charge of the physical properies, such as its posiion in the world, taking
and applying force, moving speed, and the angular speed when rotaing.
We use ixtures to handle the shape of the object. The ixture deiniion also deines the
properies on how the object interacts with others while colliding, such as fricion and
resituion.

Search WWH ::

Custom Search