diff --git a/source/map.cpp b/source/map.cpp index 7d9596a..efcb211 100644 --- a/source/map.cpp +++ b/source/map.cpp @@ -185,6 +185,7 @@ void Map::fillMapTexture() SDL_RenderClear(renderer); const int tile_size = 16; + const int tileset_width_in_tiles = 16; const int map_width_in_tiles = 20; const int map_height_in_tiles = 13; @@ -193,8 +194,8 @@ void Map::fillMapTexture() for (int y = 0; y < map_height_in_tiles; y++) for (int x = 0; x < map_width_in_tiles; x++) { - clip.x = ((tilemap[(y * map_width_in_tiles) + x] - 1) % 16) * tile_size; - clip.y = ((tilemap[(y * map_width_in_tiles) + x] - 1) / 16) * tile_size; + clip.x = ((tilemap[(y * map_width_in_tiles) + x] - 1) % tileset_width_in_tiles) * tile_size; + clip.y = ((tilemap[(y * map_width_in_tiles) + x] - 1) / tileset_width_in_tiles) * tile_size; texture_tile->render(renderer, x * tile_size, y * tile_size, &clip); }