diff options
author | Stijn Buys <ingar@osirion.org> | 2008-08-06 21:03:54 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2008-08-06 21:03:54 +0000 |
commit | 1525e4ecb2f6450b4467b8787d1283a34ca75e68 (patch) | |
tree | b672558c41f56c63e0f0fc1f58d17ddb8c8f0f32 /src | |
parent | 8d45578fcda02132d24af6065b8cf3b48a37c49c (diff) |
joystick throttle/thruster control
Diffstat (limited to 'src')
-rw-r--r-- | src/client/input.cc | 9 | ||||
-rw-r--r-- | src/client/targets.cc | 6 |
2 files changed, 12 insertions, 3 deletions
diff --git a/src/client/input.cc b/src/client/input.cc index fce83dc..7812d7e 100644 --- a/src/client/input.cc +++ b/src/client/input.cc @@ -588,6 +588,15 @@ void axis_event(int axis, int value) local_roll *= -1; break; + + case 3: // throttle + if (value >= 0) { + local_thrust = (float) value / 32767.0f; + } else { + local_thrust = (float) value / 32768.0f; + } + + local_thrust = -0.5f * local_thrust + 0.5f; } } diff --git a/src/client/targets.cc b/src/client/targets.cc index c0b8e77..1fc7ec9 100644 --- a/src/client/targets.cc +++ b/src/client/targets.cc @@ -386,7 +386,7 @@ void draw_entity_target(core::Entity *entity, bool is_active_target) std::stringstream strdistance; float d = math::distance(core::localcontrol()->location(), entity->state()->location()) - entity->radius() - core::localcontrol()->radius(); if (d > 0 ) { - if (d > 100) { + if (d > 100.0f) { strdistance << roundf(d * 0.1f) << "km"; } else { strdistance << roundf(d * 100.0f) << "m"; @@ -400,10 +400,10 @@ void draw_entity_target(core::Entity *entity, bool is_active_target) render::Text::setcolor('N'); } render::Text::draw(cx-aux::text_length(entity->name()) * render::Text::fontwidth()*0.5f, - cy-r-4- render::Text::fontheight(), entity->name()); + cy-r-4-render::Text::fontheight(), entity->name()); render::Text::draw(cx - aux::text_length(strdistance.str()) * render::Text::fontwidth() * 0.5f, - cy - render::Text::fontheight() * 0.5f, strdistance); + cy+r+4, strdistance); } } |