The Input Loop Revisited
This is as good as time as any to review the general structure of a game and the relationship of input to the event loop. Referring to Figure 9.1, you see the generic game loop of erase, move, draw, wait, repeat. That's all there is to a video game. Of course, this is oversimplified. In the world of Win32/DirectX, we already had to add a good amount of setup, termination, and Windows event handling code to get a Windows/ DirectX application up and running. But once that's all taken care of, basically you have erase, move, draw, wait, repeat.
The question is, where does the input go? Good question. It turns out that you could actually put the input in a number of places--at the beginning of the sequence, in the middle, at the end--but most game programmers like to put it right before the move section. That way, the last input state set by the player is acted on during the next frame.
Figure 9.2 shows a more detailed game loop with input and all the sections broken down into more detail. Remember, because you're using the game console that you've been working on, you have agreed to do everything for each frame within the Game_Main() function. In essence, your whole world exists within this single function call.