Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-02-21 19:06:15 +0000
committerStijn Buys <ingar@osirion.org>2008-02-21 19:06:15 +0000
commit8aa04fc836116a58f8ffd1e0c3539b9ea8a94ddf (patch)
treebb933edb3919ed67d05b098a6b97a73f01746762 /src/client/input.cc
parent41ad1e4c9e2a70d0a8811f4b035f0d3018045e61 (diff)
dedicated server, entity transfer
Diffstat (limited to 'src/client/input.cc')
-rw-r--r--src/client/input.cc40
1 files changed, 28 insertions, 12 deletions
diff --git a/src/client/input.cc b/src/client/input.cc
index e8dacd6..7193c0e 100644
--- a/src/client/input.cc
+++ b/src/client/input.cc
@@ -20,10 +20,21 @@ namespace input
{
// local offset to make turns
-float local_turn_offset;
+float local_turn;
// local thrust setting
float local_thrust;
+core::Player *localplayer() {
+ return core::game()->localplayer();
+}
+
+core::EntityControlable *localcontrol() {
+ if (core::game()->localplayer())
+ return core::game()->localplayer()->control;
+ else
+ return 0;
+}
+
void init()
{
con_print << "Initializing input..." << std::endl;
@@ -77,15 +88,20 @@ void keypressed(const SDL_keysym &keysym)
break;
case SDLK_KP4:
// TODO set core entity params
- local_turn_offset += 5;
- if (local_turn_offset > 90)
- local_turn_offset = 90;
+ local_turn += 5;
+ if (math::degrees180f(local_turn - localcontrol()->direction()) > 90)
+ local_turn = localcontrol()->direction() + 90;
+ if (local_turn > 360)
+ local_turn -= 360;
+
break;
case SDLK_KP6:
// TODO set core entity params
- local_turn_offset -= 5;
- if (local_turn_offset < -90)
- local_turn_offset = -90;
+ local_turn -= 5;
+ if (math::degrees180f(local_turn - localcontrol()->direction()) < -90)
+ local_turn = localcontrol()->direction() - 90;
+ if (local_turn < 0)
+ local_turn += 360;
break;
default:
break;
@@ -101,7 +117,7 @@ void frame(float seconds)
switch (event.type) {
case SDL_KEYUP:
- if (!console::visible() && core::application()->connected() && core::game()->localplayer()->control)
+ if (!console::visible() && core::application()->connected() && localcontrol())
// send key events to the game world
keyreleased(event.key.keysym);
break;
@@ -111,7 +127,7 @@ void frame(float seconds)
} else if (console::visible()) {
// send key events to the console
console::keypressed(event.key.keysym);
- } else if (core::application()->connected() && core::game()->localplayer()->control) {
+ } else if (core::application()->connected() && localcontrol()) {
// send key events to the game world
keypressed(event.key.keysym);
}
@@ -123,9 +139,9 @@ void frame(float seconds)
}
- if (!console::visible() && core::application()->connected() && core::game()->localplayer()->control) {
- core::game()->localplayer()->control->set_thrust(local_thrust);
- core::game()->localplayer()->control->set_direction(math::degrees360f(core::game()->localplayer()->control->direction() + local_turn_offset));
+ if (!console::visible() && core::application()->connected() && localcontrol()) {
+ localcontrol()->set_thrust(local_thrust);
+ localcontrol()->set_direction(local_turn);
}
}