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/Makefile.am4
-rw-r--r--src/game/game.cc60
-rw-r--r--src/game/game.h1
-rw-r--r--src/game/navpoint.cc27
-rw-r--r--src/game/navpoint.h27
-rw-r--r--src/game/planet.cc4
-rw-r--r--src/game/ship.cc35
-rw-r--r--src/game/star.cc2
8 files changed, 138 insertions, 22 deletions
diff --git a/src/game/Makefile.am b/src/game/Makefile.am
index 394e209..17bd6d3 100644
--- a/src/game/Makefile.am
+++ b/src/game/Makefile.am
@@ -2,7 +2,7 @@ INCLUDES = -I$(top_srcdir)/src
METASOURCES = AUTO
libgame_la_LDFLAGS = -avoid-version
-libgame_la_SOURCES = game.cc planet.cc ship.cc shipmodel.cc star.cc
+libgame_la_SOURCES = game.cc navpoint.cc planet.cc ship.cc shipmodel.cc star.cc
noinst_LTLIBRARIES = libgame.la
-noinst_HEADERS = game.h planet.h ship.h shipmodel.h star.h
+noinst_HEADERS = game.h navpoint.h planet.h ship.h shipmodel.h star.h
diff --git a/src/game/game.cc b/src/game/game.cc
index e469a31..f35670a 100644
--- a/src/game/game.cc
+++ b/src/game/game.cc
@@ -11,6 +11,7 @@
#include "filesystem/filesystem.h"
#include "filesystem/inifile.h"
#include "game/game.h"
+#include "game/navpoint.h"
#include "game/planet.h"
#include "game/ship.h"
#include "game/star.h"
@@ -311,6 +312,7 @@ bool Game::load_zone(core::Zone *zone)
Planet *planet = 0;
Star *star = 0;
+ NavPoint *navpoint = 0;
core::Entity *entity = 0;
float direction;
@@ -344,34 +346,63 @@ bool Game::load_zone(core::Zone *zone)
aux::to_label(strval);
star->entity_label.assign(strval);
continue;
- } else if (zoneini.got_key_string("name", star->entity_name))
+ } else if (zoneini.got_key_string("name", star->entity_name)) {
continue;
- else if (zoneini.got_key_vector3f("location", star->entity_location ))
+ } else if (zoneini.got_key_vector3f("location", star->entity_location )) {
continue;
- else if (zoneini.got_key_color("color", star->entity_color))
+ } else if (zoneini.got_key_color("color", star->entity_color)) {
continue;
- else if (zoneini.got_key_angle("radius", star->entity_radius))
+ } else if (zoneini.got_key_angle("radius", star->entity_radius)) {
continue;
- else
+ } else if (zoneini.got_key_angle("direction", direction)) {
+ planet->axis().change_direction(direction);
+ continue;
+ } else if (zoneini.got_key_string("texture", planet->entity_texture)) {
+ continue;
+ } else if (zoneini.got_key_angle("pitch", pitch)) {
+ planet->axis().change_pitch(pitch);
+ continue;
+ } else {
con_warn << zoneini.name() << " unknown key '" << zoneini.key() << "' at line " << zoneini.line() << std::endl;
-
+ }
+ } else if (zoneini.section().compare("navpoint") == 0) {
+ if (zoneini.got_key_string("label", strval)) {
+ aux::to_label(strval);
+ navpoint->entity_label.assign(strval);
+ continue;
+ } else if (zoneini.got_key_string("name", navpoint->entity_name)) {
+ continue;
+ } else if (zoneini.got_key_vector3f("location", navpoint->entity_location )) {
+ continue;
+ } else {
+ con_warn << zoneini.name() << " unknown key '" << zoneini.key() << "' at line " << zoneini.line() << std::endl;
+ }
} else if (zoneini.section().compare("planet") == 0) {
if (zoneini.got_key_string("label", strval)) {
aux::to_label(strval);
planet->entity_label.assign(strval);
continue;
- } else if (zoneini.got_key_string("name", planet->entity_name))
+ } else if (zoneini.got_key_string("name", planet->entity_name)) {
continue;
- else if (zoneini.got_key_string("texture", planet->entity_texture))
+ } else if (zoneini.got_key_string("texture", planet->entity_texture)) {
continue;
- else if (zoneini.got_key_vector3f("location", planet->entity_location ))
+ } else if (zoneini.got_key_vector3f("location", planet->entity_location )) {
+ continue;
+ } else if (zoneini.got_key_color("color", planet->entity_color)) {
+ continue;
+ } else if (zoneini.got_key_angle("radius", planet->entity_radius)) {
+ continue;
+ } else if (zoneini.got_key_angle("direction", direction)) {
+ planet->axis().change_direction(direction);
continue;
- else if (zoneini.got_key_color("color", planet->entity_color))
+ } else if (zoneini.got_key_angle("pitch", pitch)) {
+ planet->axis().change_pitch(pitch);
continue;
- else if (zoneini.got_key_angle("radius", planet->entity_radius))
+ } else if (zoneini.got_key_float("rotationspeed", planet->entity_rotationspeed)) {
continue;
- else
+ } else {
con_warn << zoneini.name() << " unknown key '" << zoneini.key() << "' at line " << zoneini.line() << std::endl;
+ }
} else if (zoneini.section().compare("entity") == 0) {
std::string shapename;
@@ -425,6 +456,11 @@ bool Game::load_zone(core::Zone *zone)
star->set_zone(zone);
count ++;
+ } else if (zoneini.got_section("navpoint")) {
+ navpoint = new NavPoint();
+ navpoint->set_zone(zone);
+ count ++;
+
} else if (zoneini.got_section("planet")) {
planet = new Planet();
planet->set_zone(zone);
diff --git a/src/game/game.h b/src/game/game.h
index 2ad977f..36f7321 100644
--- a/src/game/game.h
+++ b/src/game/game.h
@@ -27,6 +27,7 @@ namespace game
const unsigned int ship_enttype = 256;
const unsigned int star_enttype = 257;
const unsigned int planet_enttype = 258;
+const unsigned int navpoint_enttype = 259;
class Game : public core::Module {
public:
diff --git a/src/game/navpoint.cc b/src/game/navpoint.cc
new file mode 100644
index 0000000..24e87ca
--- /dev/null
+++ b/src/game/navpoint.cc
@@ -0,0 +1,27 @@
+/*
+ game/navpoint.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 "game/navpoint.h"
+#include "game/game.h"
+
+namespace game
+{
+
+NavPoint::NavPoint() : core::Entity(core::Entity::Static | core::Entity::Bright)
+{
+ entity_shape = core::Entity::Diamond;
+ entity_color.assign(1.0f, 1.0f);
+ entity_color_second.assign(0.6f, 1.0f);
+ entity_radius = 0.25f;
+
+ entity_moduletypeid = navpoint_enttype;
+}
+
+NavPoint::~NavPoint()
+{
+}
+
+}
diff --git a/src/game/navpoint.h b/src/game/navpoint.h
new file mode 100644
index 0000000..ef60267
--- /dev/null
+++ b/src/game/navpoint.h
@@ -0,0 +1,27 @@
+/*
+ game/navpoint.h
+ This file is part of the Osirion project and is distributed under
+ the terms and conditions of the GNU General Public License version 2
+*/
+
+#ifndef __INCLUDED_GAME_NAVPOINT_H__
+#define __INCLUDED_GAME_NAVPOINT_H__
+
+#include "core/entity.h"
+#include "math/mathlib.h"
+
+#include <string>
+
+namespace game {
+
+/// a navigation point
+class NavPoint : public core::Entity {
+public:
+ NavPoint();
+ ~NavPoint();
+};
+
+}
+
+#endif // __INCLUDED_GAME_NAVPOINT_H__
+
diff --git a/src/game/planet.cc b/src/game/planet.cc
index 91055b7..80e4922 100644
--- a/src/game/planet.cc
+++ b/src/game/planet.cc
@@ -13,9 +13,11 @@ namespace game {
Planet::Planet() : core::EntityGlobe(core::Entity::Static | core::Entity::Solid)
{
entity_color = math::Color(1,1,1,1); // white
- entity_radius = 32; // 32 game units
+ entity_radius = 64; // 64 game units
entity_moduletypeid = planet_enttype;
+
+ entity_rotationspeed = 1.0f;
}
Planet::~Planet()
diff --git a/src/game/ship.cc b/src/game/ship.cc
index 8492b68..f8a1143 100644
--- a/src/game/ship.cc
+++ b/src/game/ship.cc
@@ -7,6 +7,7 @@
// project headers
#include "auxiliary/functions.h"
#include "core/gameserver.h"
+#include "core/entity.h"
#include "game/game.h"
#include "game/ship.h"
#include "math/mathlib.h"
@@ -56,7 +57,7 @@ void Ship::impulse()
{
if (ship_impulse) {
ship_impulse = false;
-
+ entity_eventstate = core::Entity::Normal;
} else {
if (ship_jumpdrive_activated) {
ship_jumpdrive_activated = 0;
@@ -64,8 +65,10 @@ void Ship::impulse()
ship_countdown = 0;
}
+ entity_eventstate = core::Entity::Impulse;
ship_impulse = true;
}
+ entity_dirty = true;
}
void Ship::jump(std::string const &args)
@@ -80,6 +83,7 @@ void Ship::jump(std::string const &args)
ship_jumpdrive_activated = 0;
ship_jumptargetzone = 0;
ship_countdown = 0;
+ entity_eventstate = core::Entity::Normal;
return;
}
@@ -112,13 +116,16 @@ void Ship::jump(std::string const &args)
}
ship_jumpdrive_activated = core::server()->time();
- ship_countdown = 5;
+ ship_countdown = 10;
ship_impulse = false;
std::stringstream msg("");
- msg << "Hyperspace drive activated. Jumping in " << ship_countdown << "...";
+ msg << "Initializing hyperspace jump drive...";
core::server()->send(owner(), msg.str());
+ entity_eventstate = core::Entity::JumpInitiate;
+ entity_timer = ship_countdown; // countdown to jump, in seconds
+ entity_dirty = true;
}
void Ship::frame(float seconds)
@@ -144,6 +151,8 @@ void Ship::frame(float seconds)
if (ship_jumpdrive_activated + 1.0f <= core::server()->time()) {
ship_countdown -= 1.0f;
+ entity_timer = ship_countdown;
+
if (ship_countdown <= 0) {
core::server()->send(owner(), "Jumping to '" + ship_jumptargetzone->name() + '\'');
set_zone(ship_jumptargetzone);
@@ -151,12 +160,17 @@ void Ship::frame(float seconds)
owner()->set_zone(ship_jumptargetzone);
ship_jumpdrive_activated = 0;
ship_jumptargetzone = 0;
+ entity_dirty = true;
+ entity_eventstate = core::Entity::Jump;
return;
} else {
- std::stringstream msg("");
- msg << ship_countdown << "...";
- core::server()->send(owner(), msg.str());
+ if (ship_countdown <= 5) {
+ std::stringstream msg("");
+ msg << ship_countdown << "...";
+ core::server()->send(owner(), msg.str());
+ }
ship_jumpdrive_activated = core::server()->time();
+ entity_dirty = true;
}
}
@@ -166,6 +180,15 @@ void Ship::frame(float seconds)
target_roll = 0;
target_direction = 0;
+ } else if (entity_eventstate == core::Entity::Jump) {
+ // FIXME jump location and axis
+ math::Axis default_axis;
+ entity_axis.assign(default_axis);
+ entity_dirty = true;
+
+ // FIXME 5 second cooldown
+ entity_eventstate = core::Entity::Normal;
+
} else if (ship_impulse) {
// clamp input values
diff --git a/src/game/star.cc b/src/game/star.cc
index 367054f..fd0c57b 100644
--- a/src/game/star.cc
+++ b/src/game/star.cc
@@ -13,7 +13,7 @@ namespace game {
Star::Star() : core::EntityGlobe(core::Entity::Static | core::Entity::Solid | core::Entity::Bright)
{
entity_color = math::Color(1,1,1,1); // white
- entity_radius = 48; // 48 game units
+ entity_radius = 96; // 96 game units
entity_moduletypeid = star_enttype;
}