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 savage soul of game is up at once
The pack full-opening various, the shrill horn
Resounded from the hills, the neighing steed
Wild for the chase, and the loud hunters shout
Oer a weak, harmless, flying creature, all
Mixed in mad tumult and discordant joy.”
—James Thomson (17001748)
“A structure becomes architectural, and not sculptural, when its elements no longer have their justification in nature.”
—Guillaume Apollinaire (18801918)