From edba97cfc784b6958f5aea1790492dedd35060ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Valor=20Mart=C3=ADnez?= Date: Wed, 6 Jul 2022 09:10:11 +0200 Subject: [PATCH] =?UTF-8?q?Preparandose=20para=20a=C3=B1adir=20gravedad=20?= =?UTF-8?q?y=20colisiones=20y=20pasarle=20el=20mapa=20al=20jugador?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/room.cpp | 17 ++++++++++++++++- source/room.h | 2 ++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/source/room.cpp b/source/room.cpp index 34b5509..e5f295a 100644 --- a/source/room.cpp +++ b/source/room.cpp @@ -301,9 +301,24 @@ std::string Room::getRoom(int border) case BORDER_LEFT: return room_left; break; - + default: break; } return ""; } + +// Dice si el tile al que pertenece el pixel es sólido o no +bool Room::isSolid(int x, int y) +{ + int tile = ((y / 8) * 32) + (x / 8); + if (tile < 512) + { + if (tilemap[tile] != 0) + { + return true; + } + } + + return false; +} diff --git a/source/room.h b/source/room.h index e3a1c23..4f20c21 100644 --- a/source/room.h +++ b/source/room.h @@ -81,6 +81,8 @@ public: // Devuelve la cadena del fichero de la habitación contigua segun el borde std::string getRoom(int border); + // Dice si el tile al que pertenece el pixel es sólido o no + bool isSolid(int x, int y); }; #endif