- Calcula el percentatge de cobertura

This commit is contained in:
2023-11-22 16:41:36 +01:00
parent c5e722fabc
commit 2becdd1835

13
main.c
View File

@@ -60,7 +60,7 @@ void draw_player()
void put_pix()
{
if (pixels[player_x+player_y*200]==COLOR_WHITE) return;
last_x = player_x; last_y = player_y;
pixels[player_x+player_y*200] = COLOR_DARKRED;
SDL_SetRenderTarget(ren, tex);
@@ -106,6 +106,15 @@ void fill_sector(int fill)
}
}
int get_percent()
{
int claimed = 0;
for (int y=0;y<200;++y)
for (int x=0;x<200;++x)
if (pixels[x+y*200]!=0) claimed++;
return (claimed*100)/(200*200);
}
void close_sector()
{
SDL_SetRenderTarget(ren, tex);
@@ -128,6 +137,8 @@ void close_sector()
if (sector2>sector1) fill_sector(254); else fill_sector(255);
}
printf("%i...\n", get_percent());
SDL_SetRenderTarget(ren, NULL);
}