Game Development Versus Polling

Another key difference between game development and typical application development is the concept of polling versus registering for events. Many nongame applications are written solely for events driven by users. For example, if you were writing a widget-naming module for some system, you might build a screen that asks the user for the name of a widget and that has OK and Cancel buttons. Regardless of the language in which the application is written, typically it won't do anything until the user presses the OK or the Cancel button. When the user hits either button, the system will fire an event that the application will catch. That is, the application will only wake up and do something when the user tells it to do so by sending it an event indicating that the one of those buttons has been pressed.

In contrast, game development is driven by polling for events, rather than waiting to hear that an event has taken place. Instead of the system telling the game that the user has moved the mouse, for example, your game will have to ask the system if the mouse has moved. In the meantime, the application is always performing actions, regardless of user input.

Let's say you develop a game where a wizard named Jimmy (yes, there's a big market for Jimmy the Wizard games...) tries to escape from the clutches of an evil pelican warlord (that's right, pelican warlords—scary stuff!). You'll have to account for user events such as the player moving Jimmy to the left ...

Get Learning XNA 3.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.