From 0b405e4f99db021a24a307067ac22f24e80b6e35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Valor=20Mart=C3=ADnez?= Date: Sat, 10 Sep 2022 18:31:28 +0200 Subject: [PATCH] Solo sube las rampas desde el principio. Las atraviesa al saltar --- source/player.cpp | 30 ++++++++++++++++++------------ source/room.cpp | 2 +- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/source/player.cpp b/source/player.cpp index f472c72..574d748 100644 --- a/source/player.cpp +++ b/source/player.cpp @@ -260,13 +260,16 @@ void Player::move() x = pos + 1; } - // Si ha tocado alguna rampa, asciende - v_line_t leftSide = {(int)x, (int)y, (int)y + h - 1}; - const int ly = room->checkLeftSlopes(&leftSide); - if (ly > -1) + // Si ha tocado alguna rampa mientras camina (sin saltar), asciende + if (state != s_jumping) { - y = ly - h; - setState(s_standing); + v_line_t leftSide = {(int)x, (int)y + h - 2, (int)y + h - 1}; + const int ly = room->checkLeftSlopes(&leftSide); + if (ly > -1) + { + y = ly - h; + setState(s_standing); + } } } @@ -293,13 +296,16 @@ void Player::move() x = pos - w; } - // Si ha tocado alguna rampa, asciende - v_line_t rightSide = {(int)x + w - 1, (int)y, (int)y + h - 1}; - const int ry = room->checkRightSlopes(&rightSide); - if (ry > -1) + // Si ha tocado alguna rampa mientras camina (sin saltar), asciende + if (state != s_jumping) { - y = ry - h; - setState(s_standing); + v_line_t rightSide = {(int)x + w - 1, (int)y + h - 2, (int)y + h - 1}; + const int ry = room->checkRightSlopes(&rightSide); + if (ry > -1) + { + y = ry - h; + setState(s_standing); + } } } diff --git a/source/room.cpp b/source/room.cpp index 18a0cb4..94942ec 100644 --- a/source/room.cpp +++ b/source/room.cpp @@ -488,7 +488,7 @@ void Room::fillMapTexture() } // LeftSlopes - if (false) + if (true) { for (auto l : leftSlopes) {