who needs textures?

This commit is contained in:
kdx 2023-03-19 04:57:16 +00:00
parent 2fd531436f
commit c44b040a90
1 changed files with 19 additions and 6 deletions

View File

@ -40,7 +40,7 @@ int
map_get(int x, int y)
{
if (x < 0 || y < 0 || x >= map_width() || y >= map_height())
return 0;
return 1;
return maps[map_id][x + y * map_width()];
}
@ -48,17 +48,30 @@ int
map_get_px(int x, int y)
{
if (x < 0 || y < 0)
return 0;
return 1;
return map_get(x / TSIZE, y / TSIZE);
}
static void
draw_outline(int x, int y)
{
const int left = (map_get(x - 1, y) == 1);
const int right = (map_get(x + 1, y) == 1);
const int up = (map_get(x, y - 1) == 1);
const int down = (map_get(x, y + 1) == 1);
x *= TSIZE;
y *= TSIZE;
if (!left) LZY_DrawRect(x, y, 1, TSIZE);
if (!right) LZY_DrawRect(x + TSIZE - 1, y, 1, TSIZE);
if (!up) LZY_DrawRect(x, y, TSIZE, 1);
if (!down) LZY_DrawRect(x, y + TSIZE - 1, TSIZE, 1);
}
void
map_draw(void)
{
for (int y = 0; y < map_height(); y++)
for (int x = 0; x < map_width(); x++)
if (maps[map_id][x + y * map_width()] == 1) {
LZY_DrawSetColor(BLACK);
LZY_DrawTile(2, x * 16, y * 16);
}
if (map_get(x, y) == 1)
draw_outline(x, y);
}