feat: player now has different control characteristics when in Tactics Mode
This commit is contained in:
parent
83e0b16133
commit
fd726c03b9
|
@ -2,6 +2,7 @@
|
|||
#include "character_actor.hpp"
|
||||
#include "character_data.hpp"
|
||||
#include "goal_marker.hpp"
|
||||
#include "godot_cpp/variant/callable_method_pointer.hpp"
|
||||
#include "godot_cpp/variant/utility_functions.hpp"
|
||||
#include "planner.hpp"
|
||||
#include "tunnels_game_mode.hpp"
|
||||
|
@ -81,15 +82,16 @@ void TunnelsPlayer::process_camera_rotation(double delta_time) {
|
|||
Vector3 rotation = this->get_global_rotation();
|
||||
// the influence of the mouse's y position on the rotation speed
|
||||
float const y_multiplier = std::max(TunnelsPlayer::ROTATION_Y_MIN_INFLUENCE, this->mouse_location.y);
|
||||
float const margin = TunnelsPlayer::ROTATION_MARGIN * (this->state == State::Tactics ? TunnelsPlayer::ROTATION_MARGIN_TACTICS_MUL : 1.f);
|
||||
// rotate the camera when the mouse is close to the edge of the screen
|
||||
if(this->mouse_location.x < TunnelsPlayer::ROTATION_MARGIN) {
|
||||
if(this->mouse_location.x < margin) {
|
||||
// normalized measurement of how far into the rotation margin the mouse is
|
||||
float const normalized{1.f - (this->mouse_location.x / TunnelsPlayer::ROTATION_MARGIN)};
|
||||
float const normalized{1.f - (this->mouse_location.x / margin)};
|
||||
// rotate based on delta time and use a curve to make the rotation zone feel more natural
|
||||
rotation.y += delta_time * double(TunnelsPlayer::ROTATION_SPEED * camera_rotation_ramp->sample(normalized) * y_multiplier);
|
||||
}
|
||||
if(this->mouse_location.x > 1.f - TunnelsPlayer::ROTATION_MARGIN) {
|
||||
float const normalized{((this->mouse_location.x - (1.f - TunnelsPlayer::ROTATION_MARGIN)) / TunnelsPlayer::ROTATION_MARGIN)};
|
||||
if(this->mouse_location.x > 1.f - margin) {
|
||||
float const normalized{((this->mouse_location.x - (1.f - margin)) / margin)};
|
||||
rotation.y -= delta_time * double(TunnelsPlayer::ROTATION_SPEED * camera_rotation_ramp->sample(normalized) * y_multiplier);
|
||||
}
|
||||
|
||||
|
@ -247,5 +249,6 @@ CharacterActor *TunnelsPlayer::get_character() const {
|
|||
float const TunnelsPlayer::ROTATION_SPEED{0.5f};
|
||||
float const TunnelsPlayer::ROTATION_Y_MIN_INFLUENCE{7.f};
|
||||
float const TunnelsPlayer::ROTATION_MARGIN{0.4f};
|
||||
float const TunnelsPlayer::TACTICS_MOVEMENT_SPEED{20.f};
|
||||
float const TunnelsPlayer::ROTATION_MARGIN_TACTICS_MUL{0.6f};
|
||||
float const TunnelsPlayer::TACTICS_MOVEMENT_SPEED{10.f};
|
||||
}
|
||||
|
|
|
@ -62,6 +62,7 @@ private:
|
|||
|
||||
static float const ROTATION_SPEED;
|
||||
static float const ROTATION_Y_MIN_INFLUENCE;
|
||||
static float const ROTATION_MARGIN_TACTICS_MUL;
|
||||
static float const ROTATION_MARGIN;
|
||||
static float const TACTICS_MOVEMENT_SPEED;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue