Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src/game
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-03-09 11:04:35 +0000
committerStijn Buys <ingar@osirion.org>2008-03-09 11:04:35 +0000
commit912ebb62d5e8602a196a59887ef4d41cf0d6edbf (patch)
tree248fa306aa28762108e900de8d7c8b655a603fef /src/game
parent07c0040f3433cc637fecbb712fb3b6f5ad1ab5de (diff)
fixed sphere black hole, added basic HUD with speed and direction indicator, basic shaped entities readable from world.ini
Diffstat (limited to 'src/game')
-rw-r--r--src/game/game.cc167
1 files changed, 52 insertions, 115 deletions
diff --git a/src/game/game.cc b/src/game/game.cc
index 96c382e..ff42817 100644
--- a/src/game/game.cc
+++ b/src/game/game.cc
@@ -127,73 +127,57 @@ void Game::init()
Star *star = 0;
core::Entity *entity = 0;
- std::string tmp;
while (f.getline()) {
if (f.got_key()) {
if (f.section().compare("star") == 0) {
-
- if (f.got_key_string("name", tmp)) {
- star->entity_name = tmp;
-
- } else if (f.got_key_string("model", tmp)) {
- star->entity_modelname = tmp;
-
- } else if (f.got_key_string("location", tmp)) {
- std::istringstream is(tmp);
- float x, y, z;
- if ((is >> x) && (is >> y) && (is >> z)) {
- star->entity_location = math::Vector3f(x,y,z);
- }
-
- } else if (f.got_key_string("color", tmp)) {
- std::istringstream is(tmp);
- float r, g, b;
- if ((is >> r) && (is >> g) && (is >> b)) {
- star->entity_color = math::Color(r, g, b);
- }
- } else
+ if (f.got_key_string("name", star->entity_name))
+ continue;
+ else if (f.got_key_string("model", star->entity_modelname))
+ continue;
+ else if (f.got_key_vector3f("location", star->entity_location ))
+ continue;
+ else if (f.got_key_color("color", star->entity_color))
+ continue;
+ else
con_warn << f.name() << " unknown key '" << f.key() << "' at line " << f.line() << std::endl;
} else if (f.section().compare("entity") == 0) {
- if (f.got_key_string("name", tmp)) {
- entity->entity_name = tmp;
-
- } else if (f.got_key_string("model", tmp)) {
- entity->entity_modelname = tmp;
-
- } else if (f.got_key_string("direction", tmp)) {
- std::istringstream is(tmp);
- float a;
- if (is >> a) {
- entity->entity_direction = math::degrees360f(a);
- }
-
- } else if (f.got_key_string("location", tmp)) {
- std::istringstream is(tmp);
- float x, y, z;
- if ((is >> x) && (is >> y) && (is >> z)) {
- entity->entity_location = math::Vector3f(x,y,z);
- }
-
- } else if (f.got_key_string("color", tmp)) {
- std::istringstream is(tmp);
- float r, g, b;
- if ((is >> r) && (is >> g) && (is >> b)) {
- entity->entity_color = math::Color(r, g, b);
+ std::string shapename;
+
+ if (f.got_key_string("shape", shapename)) {
+ if (shapename.compare("axis") == 0) {
+ entity->entity_shape = core::Entity::Axis;
+ } else if (shapename.compare("cube") == 0) {
+ entity->entity_shape = core::Entity::Cube;
+ } else if (shapename.compare("diamond") == 0) {
+ entity->entity_shape = core::Entity::Diamond;
+ } else if (shapename.compare("sphere") == 0) {
+ entity->entity_shape = core::Entity::Sphere;
+ } else {
+ con_warn << f.name() << " unknown shape '" << shapename << "' at line " << f.line() << std::endl;
}
-
- } else {
+ continue;
+ } else if (f.got_key_string("name", entity->entity_name))
+ continue;
+ else if (f.got_key_string("model", entity->entity_modelname))
+ continue;
+ else if (f.got_key_angle("direction", entity->entity_direction))
+ continue;
+ else if (f.got_key_angle("radius", entity->entity_radius))
+ continue;
+ else if (f.got_key_vector3f("location", entity->entity_location))
+ continue;
+ else if (f.got_key_color("color", entity->entity_color))
+ continue;
+ else
con_warn << f.name() << " unknown key '" << f.key() << "' at line " << f.line() << std::endl;
- }
}
} else if (f.got_section("star")) {
- //con_debug << "[star] section" << std::endl;
star = new Star();
} else if (f.got_section("entity")) {
- //con_debug << "[entity] section" << std::endl;
entity = new core::Entity();
} else if (f.got_section()) {
@@ -202,6 +186,7 @@ void Game::init()
}
f.close();
+/*
// the green cube
core::Entity *cube = new core::Entity(core::Entity::Solid & core::Entity::Static);
cube->entity_shape = core::Entity::Cube;
@@ -233,37 +218,7 @@ void Game::init()
axis->entity_color = Color(1.0f, 1.0f, 0.0f);
axis->entity_location = Vector3f(0, 0, 0);
axis->entity_name = "axis: Origin";
-
- /*
-
- // the star
- Star *star = new Star();
- star->entity_location = Vector3f(256.0f, -256.0f, 0.0f);
- star->entity_name = "star: Sabishi Hoshi";
-
- // Canasta
- cube = new core::Entity(core::Entity::Solid & core::Entity::Static);
- cube->entity_shape = core::Entity::Diamond;
- cube->entity_color = Color(0.5f, 1.0f, 5.0f);
- cube->entity_location = Vector3f(16.0f, 20.0f, 0.0f);
- cube->entity_name = "wreck: Canasta";
- cube->entity_modelname = "ships/canasta";
-
- // Micron Vector
- cube = new core::Entity(core::Entity::Solid & core::Entity::Static);
- cube->entity_shape = core::Entity::Diamond;
- cube->entity_color = Color(0.5f, 1.0f, 5.0f);
- cube->entity_location = Vector3f(17.0f, 21.0f, 0.0f);
- cube->entity_name = "wreck: Micron Vector";
- cube->entity_modelname = "ships/micron_vector";
-
- // Alexandria
- core::Entity *alexandria = new core::Entity(core::Entity::Solid & core::Entity::Static);
- alexandria->entity_location = Vector3f(0.0f, -64.0f, 0.0f);
- alexandria->entity_name = "station: Alexandria";
- alexandria->entity_modelname = "stations/alexandria";
- */
-
+*/
// read ship model specifications
f.open("ships");
if (!f.is_open())
@@ -276,40 +231,22 @@ void Game::init()
if (f.got_key()) {
if (f.section() == "ship") {
- if (f.got_key_string("name", tmp)) {
- shipmodel->shipmodel_name = tmp;
-
- } else if (f.got_key_string("model", tmp)) {
- shipmodel->shipmodel_modelname = tmp;
-
- } else if (f.got_key_string("default", tmp)) {
-
+ if (f.got_key_string("name",shipmodel->shipmodel_name)) {
+ continue;
+ } else if (f.got_key_string("model", shipmodel->shipmodel_modelname)) {
+ continue;
+ } else if (f.got_key("default")) {
default_shipmodel = shipmodel;
-
- } else if (f.got_key_string("acceleration", tmp)) {
- std::istringstream is(tmp);
- float a;
- if (is >> a) {
- shipmodel->shipmodel_acceleration = a;
- }
-
- } else if (f.got_key_string("maxspeed", tmp)) {
- std::istringstream is(tmp);
- float ms;
- if (is >> ms) {
- shipmodel->shipmodel_maxspeed = ms;
- }
-
- } else if (f.got_key_string("turnspeed", tmp)) {
-
- std::istringstream is(tmp);
- float ts;
- if (is >> ts) {
- shipmodel->shipmodel_turnspeed = ts;
- }
-
- } else
+ continue;
+ } else if (f.got_key_float("acceleration", shipmodel->shipmodel_acceleration)) {
+ continue;
+ } else if (f.got_key_float("maxspeed", shipmodel->shipmodel_maxspeed)) {
+ continue;
+ } else if (f.got_key_float("turnspeed", shipmodel->shipmodel_turnspeed)) {
+ continue;
+ } else {
con_warn << f.name() << " unknown key '" << f.key() << "' at line " << f.line() << std::endl;
+ }
}
} else if (f.got_section("ship")) {
shipmodel = new ShipModel();