Ya pinta correctamente la habitación

This commit is contained in:
2022-07-03 11:04:48 +02:00
parent 0a24af663f
commit 7d0262a30e
2 changed files with 8 additions and 4 deletions

View File

@@ -177,12 +177,16 @@ void Room::fillMapTexture()
SDL_SetRenderDrawColor(renderer, 0x00, 0x00, 0x00, 0x00);
SDL_RenderClear(renderer);
// Los tilesets son de 20x20 tiles. El primer tile es el 1. Cuentan hacia la derecha y hacia abajo
printf("Filling map\n");
SDL_Rect clip = {0, 0, 8, 8};
for (int y = 0; y < 16; y++)
for (int x = 0; x < 32; x++)
{
clip.x = tilemap[(y * 16) + x] * 8;
clip.y = tilemap[(y * 16) + x] * 8;
{
clip.x = ((tilemap[(y * 32) + x] - 1) % 20) * 8;
clip.y = ((tilemap[(y * 32) + x] - 1) / 20) * 8;
printf("tilemap [%i] = %i | x = %i | y = %i\n", ((y * 32) + x), tilemap[(y * 32) + x], clip.x, clip.y);
texture->render(renderer, x * 8, y * 8, &clip);
}