fix: hack per a poder entrar en huecos de dos tiles d'altura al saltar
fix: calcul incorrecte del offset dels tiles que maten
This commit is contained in:
@@ -100,7 +100,7 @@ namespace Game {
|
||||
|
||||
namespace Room {
|
||||
#ifdef _DEBUG
|
||||
constexpr const char* INITIAL = "51.yaml"; // Habitación de inicio en debug
|
||||
constexpr const char* INITIAL = "03.yaml"; // Habitación de inicio en debug
|
||||
#else
|
||||
constexpr const char* INITIAL = "03.yaml"; // Habitación de inicio en release
|
||||
#endif
|
||||
@@ -108,8 +108,8 @@ namespace Room {
|
||||
|
||||
namespace Player {
|
||||
#ifdef _DEBUG
|
||||
constexpr int SPAWN_X = 28 * Tile::SIZE; // Posición X inicial en debug
|
||||
constexpr int SPAWN_Y = 10 * Tile::SIZE; // Posición Y inicial en debug
|
||||
constexpr int SPAWN_X = 26 * Tile::SIZE; // Posición X inicial en debug
|
||||
constexpr int SPAWN_Y = 13 * Tile::SIZE; // Posición Y inicial en debug
|
||||
constexpr SDL_FlipMode SPAWN_FLIP = Flip::LEFT; // Orientación inicial en debug
|
||||
#else
|
||||
constexpr int SPAWN_X = 25 * Tile::SIZE; // Posición X inicial en release
|
||||
|
||||
@@ -47,6 +47,7 @@ void Player::update(float delta_time) {
|
||||
handleInput();
|
||||
updateState(delta_time);
|
||||
move(delta_time);
|
||||
handleKillingTiles(); // Los collider_points_ están actualizados por syncSpriteAndCollider() dentro de move()
|
||||
animate(delta_time);
|
||||
border_ = handleBorders();
|
||||
}
|
||||
@@ -349,7 +350,10 @@ void Player::moveJumping(float delta_time) {
|
||||
handleLandingFromAir(DISPLACEMENT_Y, PROJECTION);
|
||||
} else {
|
||||
// Comprueba la colisión con las superficies y las cintas transportadoras (sin rampas)
|
||||
const float POS = std::max(room_->checkTopSurfaces(PROJECTION), room_->checkAutoSurfaces(PROJECTION));
|
||||
// Extendemos 1px hacia arriba para detectar suelos traversados ligeramente al
|
||||
// entrar horizontalmente (consecuencia del margen h=HEIGHT-1 en la proyección horizontal)
|
||||
const SDL_FRect ADJ = {PROJECTION.x, PROJECTION.y - 1.0F, PROJECTION.w, PROJECTION.h + 1.0F};
|
||||
const float POS = std::max(room_->checkTopSurfaces(ADJ), room_->checkAutoSurfaces(ADJ));
|
||||
if (POS != Collision::NONE) {
|
||||
// Si hay colisión lo mueve hasta donde no colisiona y pasa a estar sobre la superficie
|
||||
y_ = POS - HEIGHT;
|
||||
@@ -868,14 +872,14 @@ auto Player::getProjection(Direction direction, float displacement) -> SDL_FRect
|
||||
.x = x_ + displacement,
|
||||
.y = y_,
|
||||
.w = std::ceil(std::fabs(displacement)), // Para evitar que tenga una anchura de 0 pixels
|
||||
.h = HEIGHT};
|
||||
.h = HEIGHT - 1}; // -1 para dar ventana de 2px en aperturas de altura exacta
|
||||
|
||||
case Direction::RIGHT:
|
||||
return {
|
||||
.x = x_ + WIDTH,
|
||||
.y = y_,
|
||||
.w = std::ceil(displacement), // Para evitar que tenga una anchura de 0 pixels
|
||||
.h = HEIGHT};
|
||||
.h = HEIGHT - 1}; // -1 para dar ventana de 2px en aperturas de altura exacta
|
||||
|
||||
case Direction::UP:
|
||||
return {
|
||||
|
||||
@@ -29,7 +29,9 @@ void CollisionMap::initializeSurfaces() {
|
||||
|
||||
// Devuelve el tipo de tile que hay en ese pixel
|
||||
auto CollisionMap::getTile(SDL_FPoint point) const -> Tile {
|
||||
const int POS = ((point.y / TILE_SIZE) * MAP_WIDTH) + (point.x / TILE_SIZE);
|
||||
const int row = static_cast<int>(point.y / TILE_SIZE);
|
||||
const int col = static_cast<int>(point.x / TILE_SIZE);
|
||||
const int POS = row * MAP_WIDTH + col;
|
||||
return getTile(POS);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user