Game Development Reference
In-Depth Information
chapter 5
The Game Loop and
Graphics
Computer games come in many genres, from abstract puzzle games like Tetris to
turn-based strategy games like Civilization to fast-paced first-person shooters
like Half-Life. All these games, and all computer games, are programmed in a
similar way.
How Do Games Work?
The most important way a game communicates with the player is via the TV
screen or computer monitor. It's quite common to hear about frame-rate in
games. A good frame-rate is from 30 frames per second to 60 frames per second.
But what does frame-rate actually mean when programming a game?
A single frame is the time between screen updates. The computer program is
responsible for updating the screen with new information at least 30 times a
second. Computers are very fast; it's no problem for a computer to update the
screen this quickly.
How much time does the computer have to update each frame? If the minimum
requirement is 30 frames per second, that is 33 milliseconds per frame. The
computer has 33 milliseconds to ''think'' about what should happen in the next
frame. A computer can do a vast amount of calculation in 33 milliseconds; more
than most humans could do in a week.
All game code has a central loop called the game loop. While the game is run-
ning, the central loop is called repeatedly and as often as possible. The game loop
 
 
 
Search WWH ::




Custom Search