diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/client/input.cc | 30 | ||||
-rw-r--r-- | src/game/ship.cc | 11 | ||||
-rw-r--r-- | src/game/shipmodel.cc | 6 |
3 files changed, 25 insertions, 22 deletions
diff --git a/src/client/input.cc b/src/client/input.cc index a7e67cc..0650119 100644 --- a/src/client/input.cc +++ b/src/client/input.cc @@ -22,9 +22,11 @@ namespace input { // local offset to make turns -float local_turn; +float local_turn = 0.0f; + // local thrust setting -float local_thrust; +float local_thrust = 0.0f; + // last controlled entity unsigned int last_control = 0; @@ -76,32 +78,23 @@ void keypressed(const SDL_keysym &keysym) break; case SDLK_KP_PLUS: // TODO set core entity params - local_thrust += 0.02f; + local_thrust += 0.015f; if (local_thrust > 1.0f) local_thrust = 1.0f; break; case SDLK_KP_MINUS: // TODO set core entity params - local_thrust -= 0.025f; + local_thrust -= 0.020f; if (local_thrust < 0.0f) local_thrust = 0.0f; break; case SDLK_KP4: // TODO set core entity params - local_turn += 5; - if (math::degrees180f(local_turn - core::localcontrol()->direction()) > 90) - local_turn = core::localcontrol()->direction() + 90; - if (local_turn > 360) - local_turn -= 360; - + local_turn += 0.05; break; case SDLK_KP6: // TODO set core entity params - local_turn -= 5; - if (math::degrees180f(local_turn - core::localcontrol()->direction()) < -90) - local_turn = core::localcontrol()->direction() - 90; - if (local_turn < 0) - local_turn += 360; + local_turn -= 0.05; break; default: break; @@ -112,7 +105,7 @@ void keypressed(const SDL_keysym &keysym) void frame(float seconds) { if (core::localcontrol() && (last_control != core::localcontrol()->id())) { - local_turn = core::localcontrol()->direction(); + local_turn = 0.0f; local_thrust = core::localcontrol()->thrust(); last_control = core::localcontrol()->id(); } @@ -171,6 +164,11 @@ void frame(float seconds) } if (!console::visible() && core::application()->connected() && core::localcontrol()) { + if (local_turn > 1.0f) + local_turn = 1.0f; + else if (local_turn < -1.0f) + local_turn = -1.0f; + core::localcontrol()->set_thrust(local_thrust); core::localcontrol()->set_direction(local_turn); } diff --git a/src/game/ship.cc b/src/game/ship.cc index b82b7a8..7c3d21d 100644 --- a/src/game/ship.cc +++ b/src/game/ship.cc @@ -43,9 +43,14 @@ void Ship::frame(float seconds) entity_thrust = 1.0f; // update direction - float direction_offset = degrees180f(target_direction - entity_direction); - float d = ship_shipmodel->turnspeed() * seconds * direction_offset; - entity_direction = degrees360f(entity_direction + d); + if (target_direction > 1.0f) + target_direction = 1.0f; + else if (target_direction < -1.0f) + target_direction = -1.0f; + + // turnspeed is rotations per second + float direction_offset = 360.0f * ship_shipmodel->turnspeed() * seconds * target_direction; + entity_direction = degrees360f(entity_direction + direction_offset); // update speed if (entity_speed < entity_thrust * ship_shipmodel->maxspeed()) { diff --git a/src/game/shipmodel.cc b/src/game/shipmodel.cc index f37e5b2..8e97970 100644 --- a/src/game/shipmodel.cc +++ b/src/game/shipmodel.cc @@ -15,9 +15,9 @@ std::list<ShipModel *> ShipModel::registry; ShipModel::ShipModel() { //default specifications - shipmodel_acceleration = 1.5f; - shipmodel_maxspeed = 4.0f; - shipmodel_turnspeed = 0.5f; + shipmodel_acceleration = 1.0f; + shipmodel_maxspeed = 3.0f; + shipmodel_turnspeed = 0.1f; add(this); } |