Terminados los tiles atravesables

This commit is contained in:
2022-08-20 09:15:51 +02:00
parent 8765049b69
commit 7e93b3150f
6 changed files with 102 additions and 58 deletions

View File

@@ -226,13 +226,13 @@ void Map::render()
t_tile_map Map::getTile(SDL_Point p)
{
const int tile = tilemap[((p.y / tile_size) * map_width) + (p.x / tile_size)];
const int png_width = 16 * 2;
const int png_width = 32;
if (tile >= 0 && tile < 4 * 2 * png_width)
if (tile >= 0 && tile < 8 * png_width)
{
return nothing;
}
else if (tile >= (4 * 2 * png_width) && tile < 8 * 2 * png_width)
else if (tile >= (8 * png_width) && tile < 16 * png_width)
{
return wall;
}
@@ -246,4 +246,10 @@ t_tile_map Map::getTile(SDL_Point p)
int Map::getTileSize()
{
return tile_size;
}
// Devuelve el indice del tile correspondiente a un punto del mapa
int Map::getTileIndex(SDL_Point p)
{
return tilemap[((p.y / tile_size) * map_width) + (p.x / tile_size)];
}