Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/client')
-rw-r--r--src/client/input.cc30
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);
}