mirror of
https://github.com/zhenyan121/Cubed.git
synced 2026-04-10 06:14:07 +08:00
ui: enhance handling feel for smoother controls
This commit is contained in:
@@ -12,8 +12,8 @@ class World;
|
|||||||
|
|
||||||
class Player {
|
class Player {
|
||||||
private:
|
private:
|
||||||
constexpr static float ACCELERATION = 30.0f;
|
constexpr static float ACCELERATION = 25.0f;
|
||||||
constexpr static float DECELERATION = 50.0f;
|
constexpr static float DECELERATION = 40.0f;
|
||||||
float m_yaw = 0.0f;
|
float m_yaw = 0.0f;
|
||||||
float m_pitch = 0.0f;
|
float m_pitch = 0.0f;
|
||||||
|
|
||||||
|
|||||||
@@ -197,26 +197,20 @@ void Player::update(float delta_time) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool should_ceil = true;
|
|
||||||
static float down_speed = 0.0f;
|
static float down_speed = 0.0f;
|
||||||
|
|
||||||
if (!m_world.is_block(glm::floor(m_player_pos)) && !m_move_state.up) {
|
if (!m_world.is_block(glm::floor(m_player_pos)) && !m_move_state.up) {
|
||||||
should_ceil = true;
|
|
||||||
down_speed += 25 * delta_time;
|
down_speed += 25 * delta_time;
|
||||||
if (down_speed > 20.0f) {
|
if (down_speed > 20.0f) {
|
||||||
down_speed = 20.0f;
|
down_speed = 20.0f;
|
||||||
}
|
}
|
||||||
m_player_pos -= glm::vec3(0.0f, 1.0f, 0.0f) * down_speed * delta_time;
|
m_player_pos -= glm::vec3(0.0f, 1.0f, 0.0f) * down_speed * delta_time;
|
||||||
} else {
|
} else {
|
||||||
if (should_ceil && m_world.is_block(glm::floor(glm::vec3(m_player_pos.x, m_player_pos.y, m_player_pos.z)))) {
|
|
||||||
should_ceil = false;
|
|
||||||
m_player_pos.y = std::floor(m_player_pos.y + 1.0f);
|
|
||||||
}
|
|
||||||
down_speed = 0.0f;
|
down_speed = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_player_pos.y < -50.0f) {
|
if (m_player_pos.y < -50.0f) {
|
||||||
m_player_pos = glm::vec3(0.0f, 15.0f, 0.0f);
|
m_player_pos = glm::vec3(0.0f, 16.0f, 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user