Game Development Reference
In-Depth Information
Modifying the Orientation Class
We have added a SaveState() and LoadState() function to the Orientation class. These follow
the format of the examples in the preceding Listings 6-45 and 6-46. In order to save space,
I have decided not to include the code here. Please download the code for this chapter from
apress.com .
Modifying the Physics Class
We have added a SaveState() and LoadState() function to the Physics class. These follow the
format of the examples in the preceding Listings 6-45 and 6-46. In order to save space, I have
decided not to include the code here. Please download the code for this chapter from apress.com .
Modifying the Object3d Class
We have added in a SaveObjectState() and LoadObjectState() function to the Object3d class.
These follow the format of the examples in the preceding Listings 6-45 and 6-46. In order to save
space, I have decided not to include the code here. Please download the code for this chapter from
apress.com .
Hands-on Example: Saving Persistent Data
In this section, I cover a hands-on example in which we save the state of the two cubes' orientation
and physics state. We also save the score and health items on the HUD. New code is added, so that
the health value rolls over back to 100 when reaching 0. This makes it easier to see it being saved
when the program is exited or the orientation of the screen changes.
Modifying the MyGLRenderer Class
The MyGLRenderer class has to be modified.
The state of the two colliding cubes are saved using the SaveCubes() function. (See Listing 6-47.)
Listing 6-47. Saving the Two Cubes' State
void SaveCubes()
{
m_Cube.SaveObjectState("Cube1Data");
m_Cube2.SaveObjectState("Cube2Data");
}
The state of the two colliding cubes is loaded back in, using the LoadCubes() function.
(See Listing 6-48.)
 
Search WWH ::




Custom Search