Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/ship.cc')
-rw-r--r--src/game/ship.cc33
1 files changed, 11 insertions, 22 deletions
diff --git a/src/game/ship.cc b/src/game/ship.cc
index 19cccbe..5edbd7d 100644
--- a/src/game/ship.cc
+++ b/src/game/ship.cc
@@ -17,25 +17,14 @@ using math::degrees180f;
namespace game {
-Ship::Ship(core::Player *owner, std::string const & model) :
+Ship::Ship(core::Player *owner, ShipModel *shipmodel) :
core::EntityControlable(owner, ship_enttype)
{
// entity properties
entity_owner = owner;
-
- // ship model
- if (model.size()) {
- entity_modelname = "ships/" + model;
- entity_name = model + ": <" + owner->name() + ">";
- } else {
- entity_modelname = "ships/micron_vector";
- entity_name = "micron_vector: <" + owner->name() + ">";
- }
-
- // ship specs
- acceleration = 1.5f;
- max_speed = 4.0f;
- turn_speed = 0.5f;
+ entity_modelname = "ships/" + shipmodel->modelname();
+ entity_name = shipmodel->name() + ": <" + owner->name() + ">";
+ ship_shipmodel = shipmodel;
}
Ship::~Ship()
@@ -53,17 +42,17 @@ void Ship::frame(float seconds)
// update direction
float direction_offset = degrees180f(target_direction - entity_direction);
- float d = turn_speed * seconds * direction_offset;
+ float d = ship_shipmodel->turnspeed() * seconds * direction_offset;
entity_direction = degrees360f(entity_direction + d);
// update speed
- if (entity_speed < entity_thrust * max_speed) {
- entity_speed += acceleration * seconds;
- if (entity_speed > entity_thrust * max_speed) {
- entity_speed = entity_thrust * max_speed;
+ if (entity_speed < entity_thrust * ship_shipmodel->maxspeed()) {
+ entity_speed += ship_shipmodel->acceleration() * seconds;
+ if (entity_speed > entity_thrust * ship_shipmodel->maxspeed()) {
+ entity_speed = entity_thrust * ship_shipmodel->maxspeed();
}
- } else if(entity_speed > entity_thrust * max_speed) {
- entity_speed -= acceleration * seconds;
+ } else if(entity_speed > entity_thrust * ship_shipmodel->maxspeed()) {
+ entity_speed -= ship_shipmodel->acceleration() * seconds;
if (entity_speed < 0) entity_speed = 0;
}