/* client/client.cc This file is part of the Osirion project and is distributed under the terms and conditions of the GNU General Public License version 2 */ #include "camera.h" #include "view.h" #include "video.h" #include "input.h" #include "console.h" #include "game/game.h" #include "osirion.h" #include namespace client { // public instances Camera camera; View view; Video video; Input input; // private instance of the client console object Console clientconsole; void quit(int status) { SDL_Quit(); exit(status); } void init() { // set clientconsole as the common console object common::Console::instance = &clientconsole; // Initialize the video subsystem video.init(); if (!video.initialized) { quit(1); } // initialize input input.init(); // initialize game game::init(); } void run() { Uint32 startup = SDL_GetTicks(); while(game::initialized) { Uint32 chrono = SDL_GetTicks(); // overflow protection ~49 days if (chrono < startup) { startup = chrono; } // update the game chronometers float elapsed = (float) ( chrono - startup) / 1000.0f; game::update(elapsed); // update the video chronometers and draw video.draw(elapsed); startup = chrono; // process input input.process(); } input.shutdown(); video.shutdown(); quit(0); } } // namespace client