feat: changed camera rotation speed

This commit is contained in:
Sara 2024-03-19 13:24:11 +01:00
parent d456634061
commit 988bd53159

View file

@ -68,17 +68,18 @@ void TunnelsPlayer::process_mouse_location(double delta_time) {
void TunnelsPlayer::process_camera_rotation(double delta_time) {
Vector3 rotation = this->get_global_rotation();
float const y_multiplier = std::max(TunnelsPlayer::ROTATION_Y_MIN_INFLUENCE, this->mouse_location.y); // the influence of the mouse's y position on the rotation speed
// 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);
// rotate the camera when the mouse is close to the edge of the screen
if(this->mouse_location.x < TunnelsPlayer::ROTATION_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)};
// rotate based on delta time and use a curve to make the rotation zone feel more natural
rotation.y += delta_time * TunnelsPlayer::ROTATION_SPEED * camera_rotation_ramp->sample(normalized) * y_multiplier;
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)};
rotation.y -= delta_time * TunnelsPlayer::ROTATION_SPEED * camera_rotation_ramp->sample(normalized) * y_multiplier;
rotation.y -= delta_time * double(TunnelsPlayer::ROTATION_SPEED * camera_rotation_ramp->sample(normalized) * y_multiplier);
}
// wrap rotation to avoid going into invalid numbers
@ -156,7 +157,7 @@ Ref<Curve> TunnelsPlayer::get_camera_rotation_ramp() const {
return this->camera_rotation_ramp;
}
float const TunnelsPlayer::ROTATION_SPEED{6.f};
float const TunnelsPlayer::ROTATION_SPEED{0.5f};
float const TunnelsPlayer::ROTATION_Y_MIN_INFLUENCE{7.f};
float const TunnelsPlayer::ROTATION_MARGIN{0.4f};
}