diff options
Diffstat (limited to 'map.c')
| -rw-r--r-- | map.c | 20 |
1 files changed, 12 insertions, 8 deletions
@@ -215,8 +215,6 @@ Map file_plaintext_map(char *filename, size_t *width, size_t *height, Position * /* TODO: draw the start and goal with no background, allowing us to see the frontier/path/whatever's underneath. I think attr_get() will be useful */ /* TODO: only draw a portion of the map (for bigger ones) */ /* TODO: draw arrow for visited too */ -/* FIXME: clean up better maybe idk. There's a bug where parts of path may not be rendered if goal slightly above start in an empty area */ -/* FIXME: yeah there are plenty of bugs. the path just doesn't get rendered correctrly at times, even if it's calculated just fine. AND IT's SPECIFICALLY AFTER map_editor() WHAT IN THE ACTUAL FUCK AAAAAAAAAAAAAAAAAAAAAAAAAAAAA*/ void draw_map(Map map, size_t width, size_t height, Position start, Position goal, Position *cursor, Path path, char **visited, PositionPQ *frontier) { /* I think it flickers less when we do that * UPD: it was causing a bug, so I commented it out. I don't know why either */ @@ -254,12 +252,18 @@ void draw_map(Map map, size_t width, size_t height, Position start, Position goa /* Draw field */ if (map != NULL) { char c = '\0'; /* The char for the current tile */ - for (size_t i = 0; i < height; i++) { - for (size_t j = 0; j < width; j++) { + /* Rendering boundaries, used to not render stuff that's outside the screen for performance */ + /* TODO: finish this, calculate the appropriate boundaries */ + size_t top_boundary = 0, + bottom_boundary = height, + left_boundary = 0, + right_boundary = width; + for (size_t row = top_boundary; row < bottom_boundary; row++) { + for (size_t col = left_boundary; col < right_boundary; col++) { int color_pair = 0; /* The color pair of the current char */ - switch (map[i][j]) { + switch (map[row][col]) { case EMPTY: - if (visited != NULL && visited[i][j]) + if (visited != NULL && visited[row][col]) color_pair = COLOR_PAIR(VISITED_COLOR); else color_pair = COLOR_PAIR(EMPTY_COLOR); @@ -274,8 +278,8 @@ void draw_map(Map map, size_t width, size_t height, Position start, Position goa attron(color_pair); /* We draw two characters because they roughly make a square together. * It looks WAY better if we do this. */ - mvaddch(i + map_offset_y, j*2 + map_offset_x, c); - mvaddch(i + map_offset_y, j*2 + 1 + map_offset_x, c); + mvaddch(row + map_offset_y, col*2 + map_offset_x, c); + mvaddch(row + map_offset_y, col*2 + 1 + map_offset_x, c); attroff(color_pair); } } |
