afinaments
This commit is contained in:
@@ -204,11 +204,22 @@ void Player::updateVelocity(float delta_time) {
|
||||
}
|
||||
} else {
|
||||
if (target != 0.0F) {
|
||||
// Reset al cambiar de dirección: un giro breve también para en seco.
|
||||
if (vx_ != 0.0F && ((target > 0.0F) != (vx_ > 0.0F))) {
|
||||
walk_time_ = 0.0F;
|
||||
}
|
||||
vx_ = target;
|
||||
walk_time_ += delta_time;
|
||||
} else if (walk_time_ < WALK_INERTIA_THRESHOLD) {
|
||||
// Tap corto: parada seca, sin inercia (permite pasos finos).
|
||||
vx_ = 0.0F;
|
||||
walk_time_ = 0.0F;
|
||||
} else if (vx_ > 0.0F) {
|
||||
vx_ = std::max(vx_ - STEP, 0.0F);
|
||||
if (vx_ == 0.0F) { walk_time_ = 0.0F; }
|
||||
} else if (vx_ < 0.0F) {
|
||||
vx_ = std::min(vx_ + STEP, 0.0F);
|
||||
if (vx_ == 0.0F) { walk_time_ = 0.0F; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -551,6 +562,7 @@ void Player::transitionToState(State state) {
|
||||
case State::ON_AIR:
|
||||
last_grounded_position_ = static_cast<int>(y_);
|
||||
current_carrier_ = nullptr; // Perder carry al despegar
|
||||
walk_time_ = 0.0F; // Al aterrizar volverá a contar desde 0
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ class Player {
|
||||
// --- Constantes de física ---
|
||||
static constexpr float HORIZONTAL_VELOCITY = 75.0F;
|
||||
static constexpr float HORIZONTAL_ACCEL = 500.0F;
|
||||
static constexpr float WALK_INERTIA_THRESHOLD = 0.16F;
|
||||
static constexpr float MAX_VY = 160.0F;
|
||||
static constexpr float JUMP_VELOCITY = -178.5F;
|
||||
static constexpr float GRAVITY_FORCE = 360.0F;
|
||||
@@ -98,6 +99,7 @@ class Player {
|
||||
float y_ = 0.0F;
|
||||
float vx_ = 0.0F;
|
||||
float vy_ = 0.0F;
|
||||
float walk_time_ = 0.0F;
|
||||
|
||||
Direction wanna_go_ = Direction::NONE;
|
||||
bool wanna_jump_ = false;
|
||||
|
||||
Reference in New Issue
Block a user