HTML and CSS Reference
In-Depth Information
The following screenshot shows a player shooing the ball towards the hoop, with a
power indicator:
Why is it awesome?
When we build games without a physics engine, we create our own game loop and
reposiion each game object in every frame. For instance, if we move a character to
the right, we manage the posiion and movement speed ourselves.
Imagine that we are coding a ball-throwing logic now. We need to keep track of several
variables. We have to calculate the x and y velocity based on the ime and force applied.
We also need to take the gravity into account; not to menion the diferent angles and
materials we need to consider while calculaing the bounce between the two objects.
Now, let's think of a physical world. We just defined how objects interact and all the collisions
that happen automaically. It is similar to a real-world game; we focus on deining the rule and
the world will handle everything else. Take basketball as an example. We define the height
of the hoop, size of the ball, and distance of the three-point line. Then, the players just need
to throw the ball. We never worry about the flying parabola and the bouncing on the board.
Our space takes care of them by using the physics laws.
This is exactly what happens in the simulated physics world; it allows us to apply the physics
properies to game objects. The objects are afected by the gravity and we can apply forces
to them, making them collide with each other.
Search WWH ::

Custom Search