diff options
Diffstat (limited to 'src/client')
-rw-r--r-- | src/client/Makefile.am | 4 | ||||
-rw-r--r-- | src/client/client.cc | 62 | ||||
-rw-r--r-- | src/client/client.h | 19 | ||||
-rw-r--r-- | src/client/input.cc | 6 | ||||
-rw-r--r-- | src/client/main.cc | 5 | ||||
-rw-r--r-- | src/client/stardrawer.h | 2 |
6 files changed, 60 insertions, 38 deletions
diff --git a/src/client/Makefile.am b/src/client/Makefile.am index 6298936..f8542e2 100644 --- a/src/client/Makefile.am +++ b/src/client/Makefile.am @@ -2,8 +2,10 @@ METASOURCES = AUTO bin_PROGRAMS = osirion -osirion_LDADD = $(top_builddir)/src/common/libcommon.la \ +osirion_LDADD = $(top_builddir)/src/math/libmath.la \ + $(top_builddir)/src/common/libcommon.la \ $(top_builddir)/src/filesystem/libfilesystem.la \ + $(top_builddir)/src/core/libcore.la \ $(top_builddir)/src/game/libgame.la \ $(top_builddir)/src/gl/libgl.la osirion_SOURCES = camera.cc client.cc console.cc hud.cc input.cc main.cc \ 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); } diff --git a/src/client/client.h b/src/client/client.h index e3ff380..a25643c 100644 --- a/src/client/client.h +++ b/src/client/client.h @@ -7,22 +7,23 @@ #ifndef __INCLUDED_CLIENT_H__ #define __INCLUDED_CLIENT_H__ -#include "camera.h" -#include "view.h" -#include "input.h" -#include "video.h" -#include "console.h" +#include "client/console.h" +#include "client/camera.h" +#include "client/view.h" +#include "client/input.h" +#include "client/video.h" /// client-side functions to render and control the gameworld -/*! - * the client namespace contains the necessary functions to - * accept input, send it to the game and render the result +/** The client namespace contains the necessary functions to + * accept input, send it to the game and renders the result */ namespace client { /// initialize the client extern void init(); - /// run the client(); + /// run the client extern void run(); + /// shutdown the client + extern void shutdown(); /// global Video object extern Video video; diff --git a/src/client/input.cc b/src/client/input.cc index 7d26a2b..b18339e 100644 --- a/src/client/input.cc +++ b/src/client/input.cc @@ -43,7 +43,7 @@ void Input::handle_keypressed(SDL_keysym* keysym) { switch( keysym->sym ) { case SDLK_ESCAPE: - game::shutdown(); + client::shutdown(); break; case SDLK_LEFT: camera.rotate_left(); @@ -88,8 +88,8 @@ void Input::process() handle_keyreleased( &event.key.keysym ); break; case SDL_QUIT: - game::shutdown(); - break; + client::shutdown(); + break; } } diff --git a/src/client/main.cc b/src/client/main.cc index e8486ca..7c5f7b7 100644 --- a/src/client/main.cc +++ b/src/client/main.cc @@ -3,10 +3,13 @@ the terms and conditions of the GNU General Public License version 2 */ -#include "client.h" +#include "client/client.h" int main( int argc, char *argv[] ) { client::init(); + client::run(); + + client::shutdown(); } diff --git a/src/client/stardrawer.h b/src/client/stardrawer.h index 354da6a..6042659 100644 --- a/src/client/stardrawer.h +++ b/src/client/stardrawer.h @@ -6,7 +6,7 @@ #ifndef __INCLUDED_STARDRAWER_H__ #define __INCLUDED_STARDRAWER_H__ -#include "gl/sphere.h" +#include "gl/gllib.h" #include "game/star.h" namespace client { |