From 09789179cd77ce2f626fffbc94a90ec8784b76df Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 28 Oct 2007 09:19:35 +0000 Subject: game::Ship interface changes --- src/client/camera.cc | 21 +++++++++++---------- src/client/input.cc | 8 ++++---- src/client/shipdrawer.cc | 8 ++++---- 3 files changed, 19 insertions(+), 18 deletions(-) (limited to 'src/client') diff --git a/src/client/camera.cc b/src/client/camera.cc index bc8ee3e..03eff83 100644 --- a/src/client/camera.cc +++ b/src/client/camera.cc @@ -10,7 +10,8 @@ #include "game/game.h" #include "common/functions.h" -using namespace common; +using common::degrees360f; +using common::degrees180f; namespace client { @@ -38,16 +39,16 @@ Camera::~Camera() void Camera::draw(float elapsed) { if (mode == Track) { - yaw_target = game::ship.yaw; + yaw_target = game::ship.yaw(); } // adjust yaw - float d = degreesf(yaw_current - yaw_target); - yaw_current = degreesf( yaw_current - d * elapsed) ; + float d = degrees180f(yaw_current - yaw_target); + yaw_current = degrees360f( yaw_current - d * elapsed) ; // adjust pitch target - d = degreesf(pitch_current - pitch_target); - pitch_current = degreesf( pitch_current - d *elapsed); + d = degrees180f(pitch_current - pitch_target); + pitch_current = degrees360f( pitch_current - d *elapsed); switch (mode) { case Free: @@ -68,14 +69,14 @@ void Camera::draw(float elapsed) void Camera::rotate_right() { if (mode == Free ) { - yaw_target = degreesf( yaw_target + offset_inc); + yaw_target = degrees360f( yaw_target + offset_inc); } } void Camera::rotate_left() { if (mode == Free ) { - yaw_target = degreesf( yaw_target - offset_inc); + yaw_target = degrees360f( yaw_target - offset_inc); } } @@ -100,7 +101,7 @@ void Camera::nextmode() { case Free: // switch camera to Track mode mode = Track; - yaw_target = game::ship.yaw; + yaw_target = game::ship.yaw(); yaw_current = yaw_target; pitch_target = pitch_track; pitch_current = pitch_target; @@ -108,7 +109,7 @@ void Camera::nextmode() { case Track: // switch camera to Free mode mode = Free; - yaw_target = game::ship.yaw; + yaw_target = game::ship.yaw(); yaw_current = yaw_target; pitch_target = pitch_track; pitch_current = pitch_target; diff --git a/src/client/input.cc b/src/client/input.cc index 5cafb7d..270ccb7 100644 --- a/src/client/input.cc +++ b/src/client/input.cc @@ -56,16 +56,16 @@ void Input::handle_keypressed(SDL_keysym* keysym) camera.rotate_down(); break; case SDLK_KP_PLUS: - game::ship.thrust_increase(); + game::ship.set_thrust(game::ship.thrust() + 0.08f); break; case SDLK_KP_MINUS: - game::ship.thrust_decrease(); + game::ship.set_thrust(game::ship.thrust() - 0.1f); break; case SDLK_KP4: - game::ship.turn_left(); + game::ship.set_yaw(game::ship.yaw() + 10); break; case SDLK_KP6: - game::ship.turn_right(); + game::ship.set_yaw(game::ship.yaw() - 10); break; default: break; diff --git a/src/client/shipdrawer.cc b/src/client/shipdrawer.cc index de8dee0..09f95b1 100644 --- a/src/client/shipdrawer.cc +++ b/src/client/shipdrawer.cc @@ -38,7 +38,7 @@ void ShipDrawer::draw(float elapsed) { gl::push(); - rotate(ship->yaw, 0.0f, 1.0f, 0.0f ); + rotate(ship->yaw(), 0.0f, 1.0f, 0.0f ); Vector3f tl(0.25, 0.125, 0.125); Vector3f br(-0.25, -0.125, -0.125); @@ -67,14 +67,14 @@ void ShipDrawer::draw(float elapsed) cockpit.bottomcolor = engine1.bottomcolor; cockpit.draw(); - if(ship->thrust > 0 ) { + if(ship->thrust() > 0 ) { color(1.0f,0 ,0 ); begin(Lines); vertex(-0.5f, 0, 0.185); - vertex(-0.5f-0.25f*ship->thrust, 0, 0.185); + vertex(-0.5f-0.25f*ship->thrust(), 0, 0.185); vertex(-0.5f, 0, -0.185f); - vertex(-0.5f-0.25f*ship->thrust, 0, -0.185f); + vertex(-0.5f-0.25f*ship->thrust(), 0, -0.185f); end(); } -- cgit v1.2.3