killing tiles
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user