diff --git a/main.cpp b/main.cpp index 17b5b7b..fb580e3 100644 --- a/main.cpp +++ b/main.cpp @@ -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() { current_sector = 0; @@ -189,7 +203,7 @@ void drawColumn(sector &s, int screen_column, int start, int end, float a_inc, v } 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); 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}; @@ -436,16 +450,21 @@ int main(int argc, char *argv[]) } // Draw map walls - for (auto &w : s.walls) { - 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); + int sec = 0; + 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 vec2 lookat; lookat.x = position.x + SDL_cosf(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); - putp(int(position.x/8),int(position.y/8),7); + map::line(position.x, position.y, lookat.x, lookat.y, 1); + map::putp(position.x, position.y, 7); // Send to texture and render Uint32 *pixels;