- Pintat del minimap centrat

- El minimap pintat tots els sectors
- El sector actual se pinta de diferent color en el minimap
This commit is contained in:
2025-09-26 17:02:10 +02:00
parent 9ba4751170
commit 3b3e44e931

View File

@@ -114,6 +114,20 @@ void line(int x1, int y1, int x2, int y2, Uint8 color)
} }
namespace map
{
void putp(int x, int y, Uint8 color)
{
::putp(160+(x/8), 120+(y/8), color);
}
void line(int x1, int y1, int x2, int y2, Uint8 color)
{
::line(160+(x1/8), 120+(y1/8), 160+(x2/8), 120+(y2/8), color);
}
}
void createMap() void createMap()
{ {
current_sector = 0; current_sector = 0;
@@ -189,7 +203,7 @@ void drawColumn(sector &s, int screen_column, int start, int end, float a_inc, v
} }
if (w) if (w)
{ {
putp(int(result.x/8),int(result.y/8),6); map::putp(result.x, result.y, 6);
dist *= SDL_cosf(a_inc*DEG_TO_RAD); dist *= SDL_cosf(a_inc*DEG_TO_RAD);
const vec2 AB = {s.verts[w->v2].x-s.verts[w->v1].x, s.verts[w->v2].y-s.verts[w->v1].y}; const vec2 AB = {s.verts[w->v2].x-s.verts[w->v1].x, s.verts[w->v2].y-s.verts[w->v1].y};
const vec2 AP = {result.x-s.verts[w->v1].x, result.y-s.verts[w->v1].y}; const vec2 AP = {result.x-s.verts[w->v1].x, result.y-s.verts[w->v1].y};
@@ -436,16 +450,21 @@ int main(int argc, char *argv[])
} }
// Draw map walls // Draw map walls
for (auto &w : s.walls) { int sec = 0;
line(s.verts[w.v1].x/8, s.verts[w.v1].y/8, s.verts[w.v2].x/8, s.verts[w.v2].y/8, 4); for (auto &s : sectors)
{
for (auto &w : s.walls) {
map::line(s.verts[w.v1].x, s.verts[w.v1].y, s.verts[w.v2].x, s.verts[w.v2].y, sec==current_sector?3:4);
}
sec++;
} }
// Draw map hero // Draw map hero
vec2 lookat; vec2 lookat;
lookat.x = position.x + SDL_cosf(orientation*DEG_TO_RAD)*4; lookat.x = position.x + SDL_cosf(orientation*DEG_TO_RAD)*4;
lookat.y = position.y + SDL_sinf(orientation*DEG_TO_RAD)*4; lookat.y = position.y + SDL_sinf(orientation*DEG_TO_RAD)*4;
line(position.x/8, position.y/8, lookat.x/8, lookat.y/8, 1); map::line(position.x, position.y, lookat.x, lookat.y, 1);
putp(int(position.x/8),int(position.y/8),7); map::putp(position.x, position.y, 7);
// Send to texture and render // Send to texture and render
Uint32 *pixels; Uint32 *pixels;