Game Development Reference
In-Depth Information
Structure of a game program
Regardless of its destination platform or complexity, each game has a basic structure
made of three sections: initialization, the game loop, and termination. Let's describe
each one of them.
Initialization
The initialization is where you set anything that the game needs to get going, mainly
variables. You set the starting position and parameter values of the main character,
the number and starting position of enemies, collectibles and bonus, the difficulty set-
tings, activate data sharing, and run connection protocols; the list may be pretty long,
you got the idea.
The game loop
The game loop is the heart of the game, the fundamental routine that keeps going as
long as the player keeps playing. In this part of the game program, you get the input
from the player, compute the consequences of his actions, and draw the results on
screen. Then repeat.
The following script represents the basic structure of a game loop:
int main()
{
bool gameEnded=false;
while(!gameEnded)
{
HandleInput(); //Reads keyboard, mouse
or any other
//kind of input used by
the player
Update(); //Updates game logic
and, based on info
Search WWH ::




Custom Search