Game Development Reference
In-Depth Information
The CreateTankRoutes() function creates an array of routes and returns these routes in the
TankRoutes array, along with the number of routes in the array. (See Listing 10-46.)
Listing 10-46. Creating a List of Tank Routes
int CreateTankRoutes(Route[] TankRoutes)
{
int NumberRoutes = 6;
TankRoutes[0] = CreateTankRoute1();
TankRoutes[1] = CreateTankRoute2();
TankRoutes[2] = CreateTankRoute3();
TankRoutes[3] = CreateTankRoute4();
TankRoutes[4] = CreateTankRoute5();
TankRoutes[5] = CreateTankRoute6();
return NumberRoutes;
}
The CreateGamePlayController() function creates an array of tank routes that the game controller
uses in assigning paths to the enemy tanks and then creates the actual GamePlay Controller.
(See Listing 10-47.)
Listing 10-47. Creating the GamePlay Controller
void CreateGamePlayController(Context iContext)
{
int MaxNumberRoutes = 10;
// Tanks
int NumberTankRoutes = 0;
Route[] TankRoutes = new Route[MaxNumberRoutes];
NumberTankRoutes = CreateTankRoutes(TankRoutes);
m_GamePlayController = new GamePlayController(iContext, m_ArenaObjectsSet, m_TankFleet,
m_Grid, NumberTankRoutes, TankRoutes);
}
Next, the code that updated and rendered the game elements that were in the onDrawFrame()
function have been separated into code in UpdateScene() and RenderScene() . This is needed to
implement the additional new code that helps run the game at a constant set frame rate and game
speed that I will discuss later in this section.
The UpdateScene() function updates the elements of the game in terms of their position, orientation,
status, etc. Some elements, such as the main menu, high score table, high score entry menu, and
game over graphic, are only updated when the game is in a certain state and then after updating
returns and does not update the rest of the elements. (See Listing 10-48.)
 
Search WWH ::




Custom Search