collision map

This commit is contained in:
2026-04-06 20:27:35 +02:00
parent ef04500a44
commit 98715ef3a7
36 changed files with 489 additions and 297 deletions

View File

@@ -591,16 +591,16 @@ void Player::updateColliderPoints() {
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_[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};
}
@@ -680,15 +680,24 @@ void Player::updateVelocity(float delta_time) {
target = HORIZONTAL_VELOCITY * room_->getConveyorBeltDirection();
} else {
switch (wanna_go_) {
case Direction::LEFT: target = -HORIZONTAL_VELOCITY; break;
case Direction::RIGHT: target = HORIZONTAL_VELOCITY; break;
default: target = 0.0F; break;
case Direction::LEFT:
target = -HORIZONTAL_VELOCITY;
break;
case Direction::RIGHT:
target = HORIZONTAL_VELOCITY;
break;
default:
target = 0.0F;
break;
}
}
// Orientación del sprite según la dirección deseada (sin cambiar cuando target=0)
if (target > 0.0F) { sprite_->setFlip(Flip::RIGHT); }
else if (target < 0.0F) { sprite_->setFlip(Flip::LEFT); }
if (target > 0.0F) {
sprite_->setFlip(Flip::RIGHT);
} else if (target < 0.0F) {
sprite_->setFlip(Flip::LEFT);
}
// Inercia:
// - En el aire: inercia completa (arranque y frenada graduales)

View File

@@ -33,12 +33,12 @@ class Player {
};
// --- Constantes de física (públicas para permitir cálculos en structs) ---
static constexpr float HORIZONTAL_VELOCITY = 60.0F; // Velocidad horizontal objetivo en pixels/segundo
static constexpr float HORIZONTAL_ACCEL = 500.0F; // Aceleración/deceleración horizontal en pixels/segundo² (inercia ligera)
static constexpr float MAX_VY = 160.0F; // Velocidad vertical máxima en pixels/segundo
static constexpr float JUMP_VELOCITY = -178.5F; // Velocidad inicial del salto en pixels/segundo
static constexpr float GRAVITY_FORCE = 360.0F; // Fuerza de gravedad en pixels/segundo²
static constexpr float LOW_JUMP_GRAVITY_MULT = 3.0F; // Multiplicador de gravedad al soltar el botón de salto (salto variable)
static constexpr float HORIZONTAL_VELOCITY = 60.0F; // Velocidad horizontal objetivo en pixels/segundo
static constexpr float HORIZONTAL_ACCEL = 500.0F; // Aceleración/deceleración horizontal en pixels/segundo² (inercia ligera)
static constexpr float MAX_VY = 160.0F; // Velocidad vertical máxima en pixels/segundo
static constexpr float JUMP_VELOCITY = -178.5F; // Velocidad inicial del salto en pixels/segundo
static constexpr float GRAVITY_FORCE = 360.0F; // Fuerza de gravedad en pixels/segundo²
static constexpr float LOW_JUMP_GRAVITY_MULT = 3.0F; // Multiplicador de gravedad al soltar el botón de salto (salto variable)
struct SpawnData {
float x = 0;
@@ -181,9 +181,9 @@ class Player {
void placeSprite(); // Coloca el sprite en la posición del jugador
// --- Funciones de finalización ---
void animate(float delta_time); // Establece la animación del jugador
auto handleBorders() -> Room::Border; // Comprueba si se halla en alguno de los cuatro bordes
auto handleKillingTiles() -> bool; // Comprueba que el jugador no toque ningun tile de los que matan
void updateVelocity(float delta_time); // Calcula la velocidad en x con inercia ligera
void markAsDead(); // Marca al jugador como muerto
void animate(float delta_time); // Establece la animación del jugador
auto handleBorders() -> Room::Border; // Comprueba si se halla en alguno de los cuatro bordes
auto handleKillingTiles() -> bool; // Comprueba que el jugador no toque ningun tile de los que matan
void updateVelocity(float delta_time); // Calcula la velocidad en x con inercia ligera
void markAsDead(); // Marca al jugador como muerto
};