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/example')
-rw-r--r--src/game/example/spectator.cc15
-rw-r--r--src/game/example/spectator.h2
2 files changed, 11 insertions, 6 deletions
diff --git a/src/game/example/spectator.cc b/src/game/example/spectator.cc
index 5fc7fc6..9ca9497 100644
--- a/src/game/example/spectator.cc
+++ b/src/game/example/spectator.cc
@@ -33,7 +33,7 @@ Spectator::~Spectator()
{
}
-void Spectator::frame(float elapsed)
+void Spectator::frame(const unsigned long elapsed)
{
// only update if necessary
if (!entity_speed && ! target_thrust && !target_direction && !target_pitch && !target_roll && !target_strafe && !target_afterburner)
@@ -41,9 +41,11 @@ void Spectator::frame(float elapsed)
// assign thrust value from input
entity_thrust = target_thrust;
+
+ const float seconds = (float) elapsed / 1000.0f;
// rotate according to input
- float rotation = g_spectatorrotation->value() * elapsed;
+ float rotation = g_spectatorrotation->value() * seconds;
get_axis().change_direction(target_direction * rotation);
get_axis().change_pitch(target_pitch * rotation);
get_axis().change_roll(target_roll * rotation);
@@ -54,14 +56,17 @@ void Spectator::frame(float elapsed)
// assign new location
if (entity_speed)
- get_location() += axis().forward() * entity_speed * elapsed;
+ get_location() += axis().forward() * entity_speed * seconds;
if (target_afterburner)
- get_location() += axis().forward() * maxspeed * target_afterburner * elapsed;
+ get_location() += axis().forward() * maxspeed * target_afterburner * seconds;
if (target_strafe)
- get_location() += axis().left() * maxspeed * target_strafe * elapsed;
+ get_location() += axis().left() * maxspeed * target_strafe * seconds;
+ if (target_vstrafe)
+ get_location() += axis().up() * maxspeed * target_vstrafe * seconds;
+
// set dirty flag
set_dirty();
}
diff --git a/src/game/example/spectator.h b/src/game/example/spectator.h
index 57f223b..bd141b2 100644
--- a/src/game/example/spectator.h
+++ b/src/game/example/spectator.h
@@ -21,7 +21,7 @@ public:
~Spectator();
/// update the ship state
- virtual void frame(float elapsed);
+ virtual void frame(const unsigned long elapsed);
static core::Cvar *g_spectatorspeed;
static core::Cvar *g_spectatorrotation;