Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-02-17 18:59:52 +0000
committerStijn Buys <ingar@osirion.org>2008-02-17 18:59:52 +0000
commit982562fa19bb87a3dab352e562f386f61c171b7b (patch)
treeaeade8d5b7d3c68f5c222af1d8ecc6a734e1b43f /src/game/ship.cc
parentd198b7b8d9ff713d891f35ab173d1f428f610e7d (diff)
major rewrite of Cvar, Func and Entity
Diffstat (limited to 'src/game/ship.cc')
-rw-r--r--src/game/ship.cc38
1 files changed, 22 insertions, 16 deletions
diff --git a/src/game/ship.cc b/src/game/ship.cc
index baa97f1..e6fcaeb 100644
--- a/src/game/ship.cc
+++ b/src/game/ship.cc
@@ -17,9 +17,12 @@ using math::degrees180f;
namespace game {
-Ship::Ship() : core::EntityControlable(0)
+Ship::Ship(core::Player *owner) :
+ core::EntityControlable(owner, ship_enttype)
{
- type = ship_enttype;
+ // etnity properties
+ entity_name = "ship: <" + owner->name() + "> Micron Vector";
+ entity_owner = owner;
// ship specs
acceleration = 1.5f;
@@ -33,29 +36,32 @@ Ship::~Ship()
void Ship::frame(float seconds)
{
-
- if (target_thrust < 0) target_thrust = 0.0f;
- else if(target_thrust > 1) target_thrust = 1.0f;
+ // update thrust
+ entity_thrust = target_thrust;
+ if (entity_thrust < 0)
+ entity_thrust = 0.0f;
+ else if(entity_thrust > 1)
+ entity_thrust = 1.0f;
// update direction
- float direction_offset = degrees180f(target_direction - direction);
+ float direction_offset = degrees180f(target_direction - entity_direction);
float d = turn_speed * seconds * direction_offset;
- direction = degrees360f(direction + d);
+ entity_direction = degrees360f(entity_direction + d);
// update speed
- if (speed < target_thrust * max_speed) {
- speed += acceleration * seconds;
- if (speed > target_thrust * max_speed) {
- speed = target_thrust * max_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;
}
- } else if(speed > target_thrust * max_speed) {
- speed -= acceleration * seconds;
- if (speed < 0) speed = 0;
+ } else if(entity_speed > entity_thrust * max_speed) {
+ entity_speed -= acceleration * seconds;
+ if (entity_speed < 0) entity_speed = 0;
}
// location TODO avoid sin/cos calculations
- location.x += cosf(direction * M_PI / 180) * speed * seconds;
- location.z -= sinf(direction * M_PI / 180) * speed * seconds;
+ entity_location.x += cosf(entity_direction * M_PI / 180) * entity_speed * seconds;
+ entity_location.z -= sinf(entity_direction * M_PI / 180) * entity_speed * seconds;
}
} // namespace game