/* 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 */ // 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; // private instance of the client console object Console console_instance; // private instance of the game object game::Game game_instance; void quit(int status) { SDL_Quit(); exit(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) { quit(1); } // initialize input input.init(); } void run() { Uint32 chrono = SDL_GetTicks(); while(true) { Uint32 current = SDL_GetTicks(); // overflow protection ~49 days if (current < chrono) { chrono = current; } // update the game chronometers float elapsed = (float) ( current - chrono) / 1000.0f; chrono = current; core::frame(elapsed); // update the video chronometers and draw video.draw(elapsed); // process input input.process(); } } void shutdown() { con_debug << "Shutting down client..." << std::endl; input.shutdown(); video.shutdown(); core::shutdown(); quit(0); } } // namespace client