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>2008-01-31 18:22:44 +0000
committerStijn Buys <ingar@osirion.org>2008-01-31 18:22:44 +0000
commitf794b9ee52293cefd6ac73fdf0d2a01c5388f057 (patch)
tree2838d7ee11ae49e2e519ad604ba41f7071fb8288 /src/client/client.cc
parent1ddff2045848da5136e9e8131e335ac7626b8f68 (diff)
modular system works now
Diffstat (limited to 'src/client/client.cc')
-rw-r--r--src/client/client.cc62
1 files changed, 39 insertions, 23 deletions
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 <SDL/SDL.h>
+// C++ headers
+#include <cmath>
+
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);
}