Game Development Reference
In-Depth Information
The game loop
Every game needs a loop. This is what keeps it going. Otherwise the program will just end,
and we will not be able to see much. Here is what a typical game loop looks like:
A typical game loop has three main stages:
• Input handling
• The update frame
• The render frame
Input handling in SFML can be done either through capturing events, which have been dis-
patched by the window, or by directly querying input devices for their current state. Both
methods have different uses. For example, we might want to close the window on a button
press event, or to move our main character to the right as long as a certain key is pressed
(direct key query).
We reach the update frame stage after we capture and use our events. This is the stage
where we want to advance our game logic and update our world state.
Search WWH ::




Custom Search