From f794b9ee52293cefd6ac73fdf0d2a01c5388f057 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Thu, 31 Jan 2008 18:22:44 +0000 Subject: modular system works now --- src/client/client.cc | 62 +++++++++++++++++++++++++++++++++------------------- 1 file changed, 39 insertions(+), 23 deletions(-) (limited to 'src/client/client.cc') diff --git a/src/client/client.cc b/src/client/client.cc index a94219b..7a718a3 100644 --- a/src/client/client.cc +++ b/src/client/client.cc @@ -4,27 +4,30 @@ the terms and conditions of the GNU General Public License version 2 */ -#include "client/camera.h" -#include "client/view.h" -#include "client/video.h" -#include "client/input.h" -#include "client/console.h" - +// project headers +#include "client/client.h" #include "game/game.h" +#include "core/core.h" #include "common/common.h" +// SDL headers #include +// C++ headers +#include + namespace client { // public instances -Camera camera; -View view; -Video video; -Input input; +Camera camera; +View view; +Video video; +Input input; // private instance of the client console object -Console clientconsole; +Console console_instance; +// private instance of the game object +game::Game game_instance; void quit(int status) { @@ -34,6 +37,11 @@ void quit(int status) void init() { + // core initializes all the modules + core::init(); + + con_debug << "Initializing client..." << std::endl; + // Initialize the video subsystem video.init(); if (!video.initialized) { @@ -42,36 +50,44 @@ void init() // initialize input input.init(); - - // initialize game - game::init(); } void run() { - Uint32 startup = SDL_GetTicks(); - while(game::initialized) { - Uint32 chrono = SDL_GetTicks(); + Uint32 chrono = SDL_GetTicks(); + + while(true) { + Uint32 current = SDL_GetTicks(); // overflow protection ~49 days - if (chrono < startup) { - startup = chrono; + if (current < chrono) { + chrono = current; } // update the game chronometers - float elapsed = (float) ( chrono - startup) / 1000.0f; - game::update(elapsed); + float elapsed = (float) ( current - chrono) / 1000.0f; + chrono = current; + + core::frame(elapsed); // update the video chronometers and draw video.draw(elapsed); - startup = chrono; - + // process input input.process(); } +} + +void shutdown() +{ + con_debug << "Shutting down client..." << std::endl; input.shutdown(); + video.shutdown(); + + core::shutdown(); + quit(0); } -- cgit v1.2.3