killing tiles

This commit is contained in:
2026-04-06 22:56:59 +02:00
parent 5c40b9bbf9
commit 6be93da929
4 changed files with 31 additions and 4 deletions

View File

@@ -15,7 +15,7 @@ auto TileCollider::getTileAt(int tile_x, int tile_y) const -> Tile {
return Tile::EMPTY;
}
int value = tile_map_[tile_y * MW + tile_x];
if (value >= 0 && value <= 4) {
if (value >= 0 && value <= 5) {
return static_cast<Tile>(value);
}
return Tile::EMPTY;
@@ -220,3 +220,22 @@ auto TileCollider::checkSlopeBelow(float x, float foot_y, float w) const -> Slop
return {};
}
// --- Detección de kill tiles ---
// Devuelve true si el rectángulo del jugador solapa algún tile KILL.
auto TileCollider::touchesKillTile(float x, float y, float w, float h) const -> bool {
int top_row = toTile(static_cast<int>(y));
int bot_row = toTile(static_cast<int>(y + h - 1));
int left_col = toTile(static_cast<int>(x));
int right_col = toTile(static_cast<int>(x + w - 1));
for (int row = top_row; row <= bot_row; ++row) {
for (int col = left_col; col <= right_col; ++col) {
if (getTileAt(col, row) == Tile::KILL) {
return true;
}
}
}
return false;
}