diff options
Diffstat (limited to 'src/client/main.cc')
-rw-r--r-- | src/client/main.cc | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/src/client/main.cc b/src/client/main.cc new file mode 100644 index 0000000..66e0fa3 --- /dev/null +++ b/src/client/main.cc @@ -0,0 +1,65 @@ +/* main.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 +*/ + +// SDL headers +#include <SDL/SDL.h> + +// C++ headers +#include <iostream> + +// project headers +#include "common/osirion.h" +#include "game/game.h" + +#include "input.h" +#include "video.h" + +void quit(int exit_code) +{ + SDL_Quit(); + exit(exit_code); +} + +int main( int argc, char *argv[] ) +{ + std::cout << "The Osirion project " << OSIRION_VERSION << std::endl; + + // Initialize the video subsystem + video::init(); + if (!video::initialized) { + quit(1); + } + + // initialize input + input::init(); + + // initialize game + game::init(); + + 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(); + } + + video::shutdown(); + + quit(0); +} |