diff options
author | Stijn Buys <ingar@osirion.org> | 2008-08-24 21:36:39 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2008-08-24 21:36:39 +0000 |
commit | e6272cd7d356bbb047dcaebb03ae217235e1e13f (patch) | |
tree | 7c7c6551a2d7051d10b0c4f0c4d87554365c63de /src/client | |
parent | 9c4d134ab304794b755139e90ca6da9de73a1e9a (diff) |
afterburner/reverse/strafe
Diffstat (limited to 'src/client')
-rw-r--r-- | src/client/input.cc | 47 | ||||
-rw-r--r-- | src/client/keyboard.cc | 15 |
2 files changed, 44 insertions, 18 deletions
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); } } diff --git a/src/client/keyboard.cc b/src/client/keyboard.cc index aac6548..ae21eb1 100644 --- a/src/client/keyboard.cc +++ b/src/client/keyboard.cc @@ -49,6 +49,12 @@ Keyboard::Keyboard() add_action("+thrustup", Action::None, "increase thruster"); add_action("+thrustdown", Action::None, "decrease thruster"); + add_action("+strafeleft", Action::None, "strafe left"); + add_action("+straferight", Action::None, "strafe right"); + + add_action("+afterburner", Action::None, "afterburner"); + add_action("+reverse", Action::None, "reverse engine"); + add_action("+control", Action::None, "enable mouse control while pressed"); // ------------------ KEYS @@ -102,10 +108,10 @@ Keyboard::Keyboard() add_key("_", SDLK_UNDERSCORE, '_'); add_key("`", SDLK_BACKQUOTE, '`', "ui_console"); - add_key("a", SDLK_a, 'a'); + add_key("a", SDLK_a, 'a', "+strafeleft"); add_key("b", SDLK_b, 'b'); add_key("c", SDLK_c, 'c'); - add_key("d", SDLK_d, 'd'); + add_key("d", SDLK_d, 'd', "+straferight"); add_key("e", SDLK_e, 'e'); add_key("f", SDLK_f, 'f'); add_key("g", SDLK_g, 'g'); @@ -121,13 +127,13 @@ Keyboard::Keyboard() add_key("p", SDLK_p, 'p'); add_key("q", SDLK_q, 'q'); add_key("r", SDLK_r, 'r'); - add_key("s", SDLK_s, 's'); + add_key("s", SDLK_s, 's', "+reverse"); add_key("t", SDLK_t, 't', "ui_chat"); add_key("u", SDLK_u, 'u'); key = add_key("v", SDLK_v, 'v', "view_next"); key->assign(Key::Shift, "view_prev"); - add_key("w", SDLK_w, 'w'); + add_key("w", SDLK_w, 'w', "+afterburner"); add_key("x", SDLK_x, 'x', "target_center"); add_key("y", SDLK_y, 'y'); add_key("z", SDLK_z, 'z'); @@ -264,6 +270,7 @@ void Keyboard::save_binds() ofs << "# binds.cfg - osirion keyboard binds" << std::endl; ofs << "# this file is automaticly generated" << std::endl; + ofs << std::endl; iterator it; for (it = begin(); it != end(); it++) { |