1 / 8

General Game Programming Approach

General Game Programming Approach. 1. Event-driven Programming (1/3). The program is event-driven Messages = events So as all windows system (for example : X window) We need a loop to check all incoming events The Loop Check all incoming events (messages) Handle the events

Download Presentation

General Game Programming Approach

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. General Game Programming Approach 1

  2. Event-driven Programming (1/3) • The program is event-driven • Messages = events • So as all windows system (for example : X window) • We need a loop to check all incoming events • The Loop • Check all incoming events (messages) • Handle the events • Check timing and do something in regular • Incoming Events • Interrupts • System requests

  3. Event-driven Programming (2/3) • Timers (do something in regular timing) • The sub-system to handle timing • Must be precise to at least 1 ms or less • 30fps = 1/30 second = 33.333… ms • On win32 platform, we can use “performance counter” instead of the win32’s “WM_TIMER” message • For windows9x, WM_TIMER = 18.2 fps (maximum) • Events • Input devices • Mouse • Keyboard • Something coming from network • System requests • Re-draw • Losing/getting the input focus • …

  4. Event-driven Programming (3/3) • Therefore, we have two types of jobs: • In regular • Timers callbacks • By requests • Input device callbacks • Same as a game main program • A game is an interactive application • A game is time-bound • Rendering in 30fps or 60fps • Motion data in 30fps • Game running in 30fps • …

  5. Game Loop (1/2) Loop y Check game over Exit the loop n Peek player input Implement timer callback Rendering Single Player

  6. Game Loop (2/2) Loop y Check game over Exit n Peek user input Receive messages From network Timer callbacks To network Send messages Rendering Network Client

  7. Jobs in Regular (Typically) • Check Win/Loose • Check Quit • Objects Moving … • Play Character’s Motion to Next Frame • Play Animation to Next Frame • Models • Textures • … • Perform Some Game Calculation • Perform Geometry Calculation • LOD • Perform AI “Thinking” • Perform Collision Detection • Perform the 3D Rendering • …

  8. Jobs By Request (Typically) • Mouse Input • Press/release the mouse button • Drag • Double-click • Move • Keyboard Input • Hotkey • Typing • Gamepad • Same as the hotkey • Network • System

More Related