Game Development Reference
In-Depth Information
Animation engine
Smooth animation is a key factor in making a game look good and fun to play. If the animation is choppy or
delayed or contains unaesthetic artifacts, the player is going to run out of patience fast, leave, and never
return—even if the game concept is amazing in every other respect.
Animation in CycleBlob occurs in several objects:
The bikes move across the grid
A wall is constructed in real-time behind the bikes
The camera follows the player's bike
When a bike crashes, there's a short “crash” animation that features circles and sparks
Rotating bonus objects appear and disappear on the grid
A rotating “lives” count appears in the upper-left corner of the screen
To make the animation as smooth as possible, every one of these objects gets updated in every displayed
frame. In this section, I'll delve into the details of the bike movement to demonstrate how this is done. The
animation of the other objects is performed using very similar methods.
As mentioned earlier, the bikes move on the edges of the quad mesh on which the grid model is based. At
any point in time, the game maintains the exact position on the grid of every bike in the game using the
following three parameters:
A: The index of the grid vertex just behind the bike
B: The index of the grid vertex just in front of the bike
T: A float value between 0 and 1 that indicates how far between these vertices the bike is. If the
bike is a third of the way between A and B, then this value would be 0.33. If the bike is just about
to reach vertex B, this value is something like 0.95.
These three parameters are enough to display the bike anywhere it is capable of reaching on the grid.
Updating the bike animation comes down to maintaining these values up-to-date and displaying the result.
At the beginning of the game, every bike is assigned a random initial starting point vertex and a random
initial heading. This defines the first A and B the bikes starts with. T is initialized to 0 to mean that the bike
stands on A, its starting-point vertex.
With each animation step, the game does the following to maintain the animation parameters A, B, and T:
Advance T according to the bike speed.
If T reaches a value greater than 1, it means that it passed over vertex B to the edge after it. The
game uses the grid mesh data to find the index of the next vertex and makes the transition to a
new edge. A is updated to the value of B and B is updated to the value of the new vertex index. T
is subtracted by 1 since the bike is now between the two new vertices.
 
Search WWH ::




Custom Search