forked from jaildesigner-jailgames/jaildoctors_dilemma
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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user