Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2007-10-22 17:44:54 +0000
committerStijn Buys <ingar@osirion.org>2007-10-22 17:44:54 +0000
commit8a4aa60b830467d81f8029c194bec5b2e74ceb17 (patch)
treea32662287892a41ffa7fd55ab2d80f6040dedfb9 /src/client/client.cc
parentaa33bc22ec4cd14e200ba9e09c43e884a2101a74 (diff)
basic system console (new files)
Diffstat (limited to 'src/client/client.cc')
-rw-r--r--src/client/client.cc80
1 files changed, 80 insertions, 0 deletions
diff --git a/src/client/client.cc b/src/client/client.cc
new file mode 100644
index 0000000..14e6bb5
--- /dev/null
+++ b/src/client/client.cc
@@ -0,0 +1,80 @@
+/*
+ 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 <SDL/SDL.h>
+
+namespace client {
+
+Camera camera;
+View view;
+Video video;
+Input input;
+
+void quit(int status)
+{
+ SDL_Quit();
+ exit(status);
+}
+
+void init()
+{
+ // initialize console
+ Console clientconsole;
+ common::Console::instance = &clientconsole;
+
+ conmesg << "Project::OSiRiON " << OSIRION_VERSION << std::endl;
+
+ // 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