diff options
author | Stijn Buys <ingar@osirion.org> | 2008-04-06 14:45:46 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2008-04-06 14:45:46 +0000 |
commit | f36e9bd8190c377836463bdeaf553671d34e8e98 (patch) | |
tree | 69dbd90d9a2b779780478bd471e2c44efde45eb8 /src/client | |
parent | 7b5a6b820d5acef36d402bd5a52d783ec68d33c7 (diff) |
new target_direction model
Diffstat (limited to 'src/client')
-rw-r--r-- | src/client/input.cc | 30 |
1 files changed, 14 insertions, 16 deletions
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); } |