feat(map): afegeix Map::isPaintable(col, row)

This commit is contained in:
JailDesigner committed 2026-04-23 13:15:08 +02:00
1 parent 48ff1839bc
commit 00eb696859
2 files changed
+23

No files matched your search

+17
View File
@@ -106,6 +106,23 @@ namespace Map {
return box.x >= static_cast<float>(playfield_x) && box.y >= static_cast<float>(playfield_y) && box.x + box.w <= static_cast<float>(playfield_x + playfield_w) && box.y + box.h <= static_cast<float>(playfield_y + playfield_h);
}
auto isPaintable(int col, int row) -> bool {
// Construïm la caixa píxel del tile a partir de l'origen del tilemap.
// El grid és 16-alineat respecte a `tilemap_origin_*`; per a un tile
// (col,row) la cantonada superior-esquerra cau a:
// x = tilemap_origin_x + col * tile_size
// y = tilemap_origin_y + row * tile_size
const SDL_FRect BOX{
.x = static_cast<float>(tilemap_origin_x + (col * tile_size)),
.y = static_cast<float>(tilemap_origin_y + (row * tile_size)),
.w = static_cast<float>(tile_size),
.h = static_cast<float>(tile_size),
};
if (!insidePlayfield(BOX)) { return false; }
if (collides(BOX)) { return false; }
return true;
}
auto makeInfo() -> Info {
return {
.playfield_x = playfield_x,