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.am3
-rw-r--r--src/game/game.cc8
-rw-r--r--src/game/game.h5
-rw-r--r--src/game/shared.h18
-rw-r--r--src/game/ship.cc3
-rw-r--r--src/game/ship.h6
-rw-r--r--src/game/star.cc11
-rw-r--r--src/game/star.h4
8 files changed, 43 insertions, 15 deletions
diff --git a/src/game/Makefile.am b/src/game/Makefile.am
index f86c814..584981a 100644
--- a/src/game/Makefile.am
+++ b/src/game/Makefile.am
@@ -5,4 +5,5 @@ libgame_la_LDFLAGS = -avoid-version
libgame_la_SOURCES = game.cc sector.cc ship.cc shipspecs.cc star.cc
noinst_LTLIBRARIES = libgame.la
-noinst_HEADERS = game.h player.h sector.h ship.h shipspecs.h star.h world.h
+noinst_HEADERS = game.h player.h sector.h shared.h ship.h shipspecs.h star.h \
+ world.h
diff --git a/src/game/game.cc b/src/game/game.cc
index f9c7aa4..f8b8596 100644
--- a/src/game/game.cc
+++ b/src/game/game.cc
@@ -97,8 +97,10 @@ bool Game::init()
con_print << " " << sectors[n]->label << " " << sectors[n]->name << std::endl;
*/
- star.location = Vector3f(256.0f, 0.0f, 256.0f);
- ship.location = Vector3f(0,0,0);
+ ship = new Ship();
+ star = new Star();
+ star->location = Vector3f(256.0f, 0.0f, 256.0f);
+ ship->location = Vector3f(0,0,0);
return true;
}
@@ -117,7 +119,7 @@ void Game::shutdown()
void Game::frame(float seconds)
{
- ship.update(seconds);
+ ship->update(seconds);
}
}; // namespace game
diff --git a/src/game/game.h b/src/game/game.h
index f9c6667..bceb62d 100644
--- a/src/game/game.h
+++ b/src/game/game.h
@@ -35,10 +35,11 @@ public:
/// sectors in space
std::vector<Sector*> sectors;
+
/// the only ship in the game
- Ship ship;
+ Ship *ship;
/// the only star in the game
- Star star;
+ Star *star;
private:
std::string name;
diff --git a/src/game/shared.h b/src/game/shared.h
new file mode 100644
index 0000000..5c04309
--- /dev/null
+++ b/src/game/shared.h
@@ -0,0 +1,18 @@
+/*
+ game/game.h
+ This file is part of the Osirion project and is distributed under
+ the terms of the GNU General Public License version 2
+*/
+
+#ifndef __INCLUDED_GAME_SHARED_H__
+#define __INCLUDED_GAME_SHARED_H__
+
+namespace game
+{
+ // entity type constants
+ const unsigned int ship_enttype = 1;
+ const unsigned int star_enttype = 2;
+
+}
+
+#endif
diff --git a/src/game/ship.cc b/src/game/ship.cc
index fc18375..9252f1d 100644
--- a/src/game/ship.cc
+++ b/src/game/ship.cc
@@ -5,6 +5,7 @@
*/
// project headers
+#include "game/shared.h"
#include "game/ship.h"
#include "math/mathlib.h"
@@ -16,7 +17,7 @@ using math::degrees180f;
namespace game {
-Ship::Ship()
+Ship::Ship() : core::Entity(ship_enttype)
{
speed = 0;
yaw_current = 0;
diff --git a/src/game/ship.h b/src/game/ship.h
index d420f67..f83c41e 100644
--- a/src/game/ship.h
+++ b/src/game/ship.h
@@ -8,11 +8,12 @@
#define __INCLUDED_GAME_SHIP_H__
// project headers
+#include "core/entity.h"
#include "math/vector3f.h"
namespace game {
-class Ship
+class Ship : public core::Entity
{
public:
Ship();
@@ -21,8 +22,6 @@ public:
/// update the ship state
void update(float elapsed);
- /// location of the ship in space
- math::Vector3f location;
/// speed vector in units/second
float speed;
@@ -44,6 +43,7 @@ public:
/// yaw turn speed
float yaw_speed;
+ static const unsigned int type_id=1;
private:
/// current yaw, angle in XZ plane, 0-360
float yaw_current;
diff --git a/src/game/star.cc b/src/game/star.cc
index 924bb96..a8b5e87 100644
--- a/src/game/star.cc
+++ b/src/game/star.cc
@@ -1,11 +1,16 @@
+/*
+ game/star.cc
+ This file is part of the Osirion project and is distributed under
+ the terms of the GNU General Public License version 2.
+*/
+#include "game/shared.h"
+#include "game/star.h"
-#include "star.h"
namespace game {
-Star::Star() :
- location(0,0,0),
+Star::Star() : core::Entity(star_enttype),
color(1,1,1,1)
{
radius = 48;
diff --git a/src/game/star.h b/src/game/star.h
index 70ce2aa..7a087d0 100644
--- a/src/game/star.h
+++ b/src/game/star.h
@@ -8,6 +8,7 @@
#define __INCLUDED_GAME_STAR_H__
// project headers
+#include "core/entity.h"
#include "math/mathlib.h"
// C++ headers
@@ -16,12 +17,11 @@
namespace game {
/// a star, that shines so bright
-class Star {
+class Star : public core::Entity {
public:
Star();
~Star();
- math::Vector3f location;
math::Color color;
float radius;