Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src/game
diff options
context:
space:
mode:
Diffstat (limited to 'src/game')
-rw-r--r--src/game/game.cc60
-rw-r--r--src/game/game.h11
2 files changed, 33 insertions, 38 deletions
diff --git a/src/game/game.cc b/src/game/game.cc
index 25f8926..f88c753 100644
--- a/src/game/game.cc
+++ b/src/game/game.cc
@@ -18,6 +18,32 @@
namespace game
{
+/// a player joins the game
+void func_join(core::Player &player, std::stringstream &args)
+{
+ Ship *ship = new Ship();
+ 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 the game" << std::endl;
+ /// TODO net broadcast
+}
+
+/// a player joins the spectators
+void func_spectate(core::Player &player, std::stringstream &args)
+{
+ con_print << player.name << " joins the spectators" << std::endl;
+ /// TODO net broadcast
+
+ if (player.controled) {
+ // player only has one ship for now
+ core::entity::remove(player.controled->id);
+ player.controled = 0;
+ }
+}
+
Game::Game()
{
}
@@ -106,7 +132,7 @@ bool Game::init()
con_print << " " << sectors[n]->label << " " << sectors[n]->name << std::endl;
*/
- star = new Star();
+ Star *star = new Star();
star->location = Vector3f(256.0f, 0.0f, 256.0f);
star->label = "star: Sabishi Hoshi";
@@ -136,6 +162,9 @@ bool Game::init()
axis->location = Vector3f(0, 0, 0);
axis->label = "axis: Origin";
+ core::func::add("join", func_join, core::func::Game);
+ core::func::add("spectate", func_spectate, core::func::Game);
+
return true;
}
@@ -143,6 +172,9 @@ void Game::shutdown()
{
con_print << "Shutting down game..." << std::endl;
+ core::func::remove("join");
+ core::func::remove("spectate");
+
// delete every sector object in the sectors vector
for (unsigned int n =0; n< sectors.size(); n++) {
delete sectors[n];
@@ -157,33 +189,7 @@ void Game::frame(float seconds)
}
-void Game::event_join(core::Player *player)
-{
- if (!player)
- return;
-
- ship = new Ship();
- 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;
-}
-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
diff --git a/src/game/game.h b/src/game/game.h
index 9c993fe..d8a6185 100644
--- a/src/game/game.h
+++ b/src/game/game.h
@@ -36,20 +36,9 @@ public:
/// execute one game grame
void frame(float seconds);
- /// a player joins the game
- void event_join(core::Player *player);
-
- /// a player leaves the game
- void event_leave(core::Player *player);
-
/// sectors in space
std::vector<Sector*> sectors;
- /// the only ship in the game
- Ship *ship;
- /// the only star in the game
- Star *star;
-
private:
std::string name;
std::string label;