Okay, as requested, here is a bad summary of Game Coding Complete's architecture.
You have three separate systems, that communicate via a message system that is controlled by the Game Application Layer.
Game Application Layer
Game Logic Layer
*Game View is actually a list of Game View interface objects that can be local players, AI agents, or networked players.
Example of message system:
"A" Button is pressed on keyboard
Human View checks for button presses, translates button press to game message "Apply Emergency Brake" and sends it
Game Logic receives message and changes the state of the player's car, sending a message back to the Human View: "Car State: E-Brake On"
Human View responds to the message by maybe changing the visual representation of the car to have its tires lay down rubber or something
---Game Application Layer---
Connection and disconnection of devices like keyboards and mice
The main loop (AppLayer->Run();)
Init & Shutdown
---Game Logic Layer---
**you may have different implementations of the Game Logic that you swap in and out depending on whether the player is in server or client mode, single player or multiplayer, whatever**
Game State & Data Structures
*Send messages such as "time bomb created" so Game View can play a ticking sound and make a visual representation of it and so AI agents can run from it, etc
**Processes are anything that needs to run every loop; this is essentially your Update() function (they are esentially threads, but in a cooperative multitasking environment rather than this mutex locking, time-wasting jazz)
***Takes the messages from the Game View and does something with them inside the Game Logic, like applying the E-Brake and then sending a message back to the Game View so it knows to lay down the rubber trails
---Game View (Human)---
^- the scene
^- FLIC anims
Process Manager** (yet again!)
*Should be obvious what this does...
**For button animations, little graphical tricks, anything that needs to have the equivalent of an Update() function
---Game View (AI agent)---
In addition, you may have a "Remote Game View" derived class that gets messages from a server game logic instead of a local game logic. If you need me to explain that in detail, ask me to.
That's the basic setup, here's the execution of it.
//entry point for the file
int main(int argc, char *argv)
|2||//This is actually a bit hackish because I just quickly adapted it from DirectX,|
|3||//but the basic setup ought to be the same|
|6|| while (m_bIsRunning)|
|8|| while (m_LogicTime == 0)|
|12|| float renderTime = 0.0;|
|13|| while (m_LogicTime > 0)|
|15|| Update(m_TotalTime, m_LogicTime);|
|17|| //done this way in case TimerHandler() is called during Update()|
|18|| m_LogicTime -= m_TimerResolution;|
|19|| renderTime += m_TimerResolution;|
|21|| Render(m_TotalTime, renderTime);|
There's a ton more to this architecture, but I'm not about to type up 900 pages.