From f36e9bd8190c377836463bdeaf553671d34e8e98 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 6 Apr 2008 14:45:46 +0000 Subject: new target_direction model --- src/client/input.cc | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) (limited to 'src/client') diff --git a/src/client/input.cc b/src/client/input.cc index a7e67cc..0650119 100644 --- a/src/client/input.cc +++ b/src/client/input.cc @@ -22,9 +22,11 @@ namespace input { // local offset to make turns -float local_turn; +float local_turn = 0.0f; + // local thrust setting -float local_thrust; +float local_thrust = 0.0f; + // last controlled entity unsigned int last_control = 0; @@ -76,32 +78,23 @@ void keypressed(const SDL_keysym &keysym) break; case SDLK_KP_PLUS: // TODO set core entity params - local_thrust += 0.02f; + local_thrust += 0.015f; if (local_thrust > 1.0f) local_thrust = 1.0f; break; case SDLK_KP_MINUS: // TODO set core entity params - local_thrust -= 0.025f; + local_thrust -= 0.020f; if (local_thrust < 0.0f) local_thrust = 0.0f; break; case SDLK_KP4: // TODO set core entity params - local_turn += 5; - if (math::degrees180f(local_turn - core::localcontrol()->direction()) > 90) - local_turn = core::localcontrol()->direction() + 90; - if (local_turn > 360) - local_turn -= 360; - + local_turn += 0.05; break; case SDLK_KP6: // TODO set core entity params - local_turn -= 5; - if (math::degrees180f(local_turn - core::localcontrol()->direction()) < -90) - local_turn = core::localcontrol()->direction() - 90; - if (local_turn < 0) - local_turn += 360; + local_turn -= 0.05; break; default: break; @@ -112,7 +105,7 @@ void keypressed(const SDL_keysym &keysym) void frame(float seconds) { if (core::localcontrol() && (last_control != core::localcontrol()->id())) { - local_turn = core::localcontrol()->direction(); + local_turn = 0.0f; local_thrust = core::localcontrol()->thrust(); last_control = core::localcontrol()->id(); } @@ -171,6 +164,11 @@ void frame(float seconds) } if (!console::visible() && core::application()->connected() && core::localcontrol()) { + if (local_turn > 1.0f) + local_turn = 1.0f; + else if (local_turn < -1.0f) + local_turn = -1.0f; + core::localcontrol()->set_thrust(local_thrust); core::localcontrol()->set_direction(local_turn); } -- cgit v1.2.3