Game Structure
The central component of any game, from a programming standpoint, is the game loop. The game loop allows the game to run smoothly regardless of a user's input or lack thereof.
Most traditional software programs respond to user input and do nothing without it. For example, a word processor formats words and text as a user types. If the user doesn't type anything, the word processor does nothing. Some functions may take a long time to complete, but all are initiated by a user telling the program to do something.
Games, on the other hand, must continue to operate regardless of a user's input. The game loop allows this. A highly simplified game loop, in pseudocode, might look something like this:
while( user doesn't exit ) check for user input run AI move enemies resolve collisions draw graphics play sounds end whileThe game loop may be refined and modified as game development progresses, but most games are based on this basic idea.
Game loops differ depending on the platform they are developed for. For example, games written for DOS and most consoles can dominate and exploit available processing resources without restraint. However, game for a modern PC operating system such as Microsoft Windows must operate within the constraints of the process scheduler. Some modern games run multiple threads so that, for example, the computation of character AI can be decoupled from the generation of smooth motion within the game. This has the disadvantage of (slightly) increased overhead, but the game may run more smoothly and efficiently on hyper-threading or multicore processors and on multiprocessor platforms. With the computer industry's focus on CPUs with more cores that can execute more threads, this is becoming increasingly important. Consoles like the Xbox 360 and PlayStation 3 already have more than one core per processor, and execute more than one thread per core.
Read more about this topic: Game Programming
Famous quotes containing the words game and/or structure:
“The indispensable ingredient of any game worth its salt is that the children themselves play it and, if not its sole authors, share in its creation. Watching TVs ersatz battles is not the same thing at all. Children act out their emotions, they dont talk them out and they dont watch them out. Their imagination and their muscles need each other.”
—Leontine Young (20th century)
“Science is intimately integrated with the whole social structure and cultural tradition. They mutually support one otheronly in certain types of society can science flourish, and conversely without a continuous and healthy development and application of science such a society cannot function properly.”
—Talcott Parsons (19021979)