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/console.cc5
-rw-r--r--src/client/draw.cc1
-rw-r--r--src/client/input.cc40
-rw-r--r--src/client/view.cc2
4 files changed, 33 insertions, 15 deletions
diff --git a/src/client/console.cc b/src/client/console.cc
index 492d909..9c7c6ca 100644
--- a/src/client/console.cc
+++ b/src/client/console.cc
@@ -120,8 +120,9 @@ void draw()
// draw version below the bottom of the console
gl::enable(GL_TEXTURE_2D);
gl::color(0.0f, 1.0f, 0.0f, 0.5f);
- std:: string version = std::string("The Osirion Project ");
- version.append(VERSION);
+ std::string version(core::name());
+ version += ' ';
+ version.append(core::version());
draw_text(video::width-CHARWIDTH*(version.size()+1), video::height*con_height-CHARHEIGHT-4, version);
gl::disable(GL_TEXTURE_2D);
diff --git a/src/client/draw.cc b/src/client/draw.cc
index 72a67c2..60726b0 100644
--- a/src/client/draw.cc
+++ b/src/client/draw.cc
@@ -215,6 +215,7 @@ void draw_world(float seconds)
break;
case core::Entity::Controlable:
draw_ship(static_cast<core::EntityControlable *> ((*it).second));
+ break;
default:
break;
}
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);
}
}
diff --git a/src/client/view.cc b/src/client/view.cc
index 0c8e26b..1a40c4a 100644
--- a/src/client/view.cc
+++ b/src/client/view.cc
@@ -118,7 +118,7 @@ void draw_status()
// print the version number in the upper right corner
gl::color(0.0f, 1.0f, 0.0f, 1.0f);
std::string version("ver. ");
- version.append(VERSION);
+ version.append(core::version());
draw_text(video::width-(version.size()+1)*CHARWIDTH, 4, version);
gl::disable(GL_TEXTURE_2D);