From e6272cd7d356bbb047dcaebb03ae217235e1e13f Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 24 Aug 2008 21:36:39 +0000 Subject: afterburner/reverse/strafe --- src/client/input.cc | 47 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 14 deletions(-) (limited to 'src/client/input.cc') diff --git a/src/client/input.cc b/src/client/input.cc index d898b78..75fa0f3 100644 --- a/src/client/input.cc +++ b/src/client/input.cc @@ -48,6 +48,8 @@ float local_direction = 0.0f; float local_pitch = 0.0f; float local_thrust = 0.0f; float local_roll = 0.0f; +float local_strafe = 0.0f; +float local_afterburner = 0.0f; // last controlled entity unsigned int last_control = 0; @@ -379,6 +381,18 @@ void action_press(Key const *key, std::string const &action) } else if (action.compare("+rollright") == 0) { local_roll = -1.0f; + } else if (action.compare("+strafeleft") == 0) { + local_strafe = 1.0f; + + } else if (action.compare("+straferight") == 0) { + local_strafe = -1.0f; + + } else if (action.compare("+afterburner") == 0) { + local_afterburner = 1.0f; + + } else if (action.compare("+reverse") == 0) { + local_afterburner = -1.0f; + /* -- camera control ------------------------------ */ } else if (action.compare("+camleft") == 0) { render::Camera::set_direction(1.0f); @@ -440,6 +454,18 @@ void action_release(Key *key, std::string const &action) } else if (action.compare("+rollright") == 0) { local_roll = 0.0f; + } else if (action.compare("+strafeleft") == 0) { + local_strafe = 0.0f; + + } else if (action.compare("+straferight") == 0) { + local_strafe = 0.0f; + + } else if (action.compare("+afterburner") == 0) { + local_afterburner = 0.0f; + + } else if (action.compare("+reverse") == 0) { + local_afterburner = 0.0f; + /* -- camera control ------------------------------ */ } else if (action.compare("+camleft") == 0) { render::Camera::set_direction(0.0f); @@ -610,6 +636,9 @@ void reset() local_direction = 0.0f; local_pitch = 0.0f; local_roll = 0.0f; + local_strafe = 0.0f; + local_afterburner = 0.0f; + if (core::localcontrol()) { local_thrust = core::localcontrol()->thrust(); last_control = core::localcontrol()->id(); @@ -645,20 +674,7 @@ void frame(float seconds) { /* -- detect localcontrol() changes --------------- */ if (core::localcontrol() && (last_control != core::localcontrol()->id())) { - - local_direction = 0.0f; - local_pitch = 0.0f; - local_roll = 0.0f; - local_thrust = core::localcontrol()->thrust(); - last_control = core::localcontrol()->id(); - mouse_pitch = 0.0f; - mouse_direction = 0.0f; - mouse_x = video::width / 2; - mouse_y = video::height / 2; - render::Camera::reset(); - mouse_control_override = false; - targets::reset(); - render::reset(); + reset(); } if (core::localcontrol() && (core::localcontrol()->eventstate() != core::Entity::Normal)) { @@ -839,6 +855,7 @@ void frame(float seconds) math::clamp(local_pitch, -1.0f, 1.0f); math::clamp(local_roll, -1.0f, 1.0f); math::clamp(local_thrust, 0.0f, 1.0f); + if (local_thrust < 0.01f) local_thrust = 0.0f; else if (local_thrust > 0.99f) @@ -848,6 +865,8 @@ void frame(float seconds) core::localcontrol()->set_direction(local_direction); core::localcontrol()->set_pitch(local_pitch / render::Camera::aspect() ); core::localcontrol()->set_roll(local_roll); + core::localcontrol()->set_strafe(local_strafe); + core::localcontrol()->set_afterburner(local_afterburner); } } -- cgit v1.2.3