Game Development Reference
In-Depth Information
Physics
Physics is closely tied in with collision detection since collision detection is integral to
the physics of your game. If two objects collide, we need to detect this so that we can
make them behave realistically. It will look pretty silly if they both just stopped in their
tracks upon colliding, or just kept going as though they were both ghosts.
Physics is a very complicated subject and relies heavily on mathematics. It is essen-
tially just the use of mathematics to calculate the movement of objects in our game
world. Of course, you can tweak your physics a bit if you want in order to achieve
different effects. For example, you might make your physics work a little differently if
your game has a cartoon-styled world as opposed to a realistic world.
The bounding boxes that we talked about in the previous section are generally inside
the physics system of a game since that's where they are used. The physics system
in a game is generally responsible for simulating the physics of objects in the game
world. It is also common to give objects a sleep state or idle state, as it is often called.
When the object is in this state, the physics system will ignore the object, and not do
any physics simulation for it. This allows you to have physics turned off for a given
object until it's needed. This can bring huge performance benefits because physics,
being full of mathematics, can be relatively slow to run. The performance benefits in-
crease when you have more objects that are in this state (since they aren't moving
or doing anything anyway), and so, you're effectively saving the physics system from
doing a lot of unnecessary work. After all, there is no point in wasting time running the
physics code on an object that is not moving or doing anything.
Search WWH ::




Custom Search