From 1f95c377b2abfaa454b1f2298af10956d95ad941 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Wed, 13 Feb 2008 00:40:59 +0000 Subject: split client from game module --- src/game/game.cc | 50 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 14 deletions(-) (limited to 'src/game/game.cc') diff --git a/src/game/game.cc b/src/game/game.cc index 51bb565..25f8926 100644 --- a/src/game/game.cc +++ b/src/game/game.cc @@ -4,20 +4,28 @@ the terms of the GNU General Public License version 2 */ -// project headers +#include + #include "game/game.h" #include "game/sector.h" #include "game/ship.h" #include "game/star.h" -#include "filesystem/filesystem.h" +#include "core/entity.h" #include "sys/sys.h" - -// C++ headers -#include +#include "math/mathlib.h" +#include "filesystem/filesystem.h" namespace game { +Game::Game() +{ +} + +Game::~Game() +{ +} + bool Game::init() { using math::Vector3f; @@ -102,11 +110,6 @@ bool Game::init() star->location = Vector3f(256.0f, 0.0f, 256.0f); star->label = "star: Sabishi Hoshi"; - - ship = new Ship(); - ship->location = Vector3f(0,0,0); - ship->label = "ship: Micron Vector"; - core::Entity *cube = new core::Entity(core::entity::Solid & core::entity::Static); cube->core_shape = core::entity::Cube; cube->core_color = Color(0.0f, 0.8f, 0.0f); @@ -151,7 +154,7 @@ void Game::shutdown() void Game::frame(float seconds) { - ship->update(seconds); + } void Game::event_join(core::Player *player) @@ -160,8 +163,27 @@ void Game::event_join(core::Player *player) return; ship = new Ship(); - ship->location = Vector3f(0,0,0); - ship->label = "ship: Micron Vector"; + ship->location = math::Vector3f(0,0,0); + ship->label = "ship: <"+player->name+"> Micron Vector"; + ship->owner = player; + + player->controled = ship; + + con_print << player->name << " joins" << std::endl; } -}; // namespace game +void Game::event_leave(core::Player *player) +{ + if (!player) + return; + + con_print << player->name << " leaves" << std::endl; + + if (player->controled) { + // player only has one ship for now + core::entity::remove(player->controled->id); + } +} + +} // namespace game + -- cgit v1.2.3