developers, developers!

This commit is contained in:
2026-04-06 15:17:19 +02:00
parent 4c5e1e5470
commit fccc27fca0
10 changed files with 55 additions and 67 deletions

View File

@@ -64,7 +64,9 @@ void Player::handleInput() {
wanna_go_ = Direction::NONE;
}
wanna_jump_ = Input::get()->checkAction(InputAction::JUMP);
const bool JUMP_PRESSED = Input::get()->checkAction(InputAction::JUMP);
wanna_jump_ = JUMP_PRESSED && !jump_held_; // Solo en el flanco de pulsación
jump_held_ = JUMP_PRESSED;
wanna_down_ = Input::get()->checkAction(InputAction::DOWN);
}
@@ -416,7 +418,7 @@ void Player::switchBorders() {
void Player::applyGravity(float delta_time) {
if (state_ == State::ON_AIR) {
// Si está subiendo y ha soltado el botón de salto, gravedad aumentada para cortar el salto
const float GRAVITY = (vy_ < 0.0F && !wanna_jump_)
const float GRAVITY = (vy_ < 0.0F && !jump_held_)
? GRAVITY_FORCE * LOW_JUMP_GRAVITY_MULT
: GRAVITY_FORCE;
vy_ += GRAVITY * delta_time;
@@ -582,15 +584,26 @@ void Player::setColor(Uint8 color) {
// Actualiza los puntos de colisión
void Player::updateColliderPoints() {
const SDL_FRect RECT = getRect();
collider_points_[0] = {.x = RECT.x, .y = RECT.y};
collider_points_[1] = {.x = RECT.x + 7, .y = RECT.y};
collider_points_[2] = {.x = RECT.x + 7, .y = RECT.y + 7};
collider_points_[3] = {.x = RECT.x, .y = RECT.y + 7};
collider_points_[4] = {.x = RECT.x, .y = RECT.y + 8};
collider_points_[5] = {.x = RECT.x + 7, .y = RECT.y + 8};
collider_points_[6] = {.x = RECT.x + 7, .y = RECT.y + 15};
collider_points_[7] = {.x = RECT.x, .y = RECT.y + 15};
// 3 columnas × 4 filas: garantiza que cada tile de 8×8 que solape el jugador tenga al menos un punto
const float L = x_;
const float M = x_ + (WIDTH / 2);
const float R = x_ + WIDTH - 1;
const float Y0 = y_;
const float Y1 = y_ + 8;
const float Y2 = y_ + 16;
const float Y3 = y_ + HEIGHT - 1;
collider_points_[0] = {.x = L, .y = Y0};
collider_points_[1] = {.x = M, .y = Y0};
collider_points_[2] = {.x = R, .y = Y0};
collider_points_[3] = {.x = L, .y = Y1};
collider_points_[4] = {.x = M, .y = Y1};
collider_points_[5] = {.x = R, .y = Y1};
collider_points_[6] = {.x = L, .y = Y2};
collider_points_[7] = {.x = M, .y = Y2};
collider_points_[8] = {.x = R, .y = Y2};
collider_points_[9] = {.x = L, .y = Y3};
collider_points_[10] = {.x = M, .y = Y3};
collider_points_[11] = {.x = R, .y = Y3};
}
// Actualiza los puntos de los pies