diff options
| author | Kirill Petrashin <kirill8201@yandex.ru> | 2026-04-13 11:47:45 +0300 |
|---|---|---|
| committer | Kirill Petrashin <kirill8201@yandex.ru> | 2026-04-13 11:47:45 +0300 |
| commit | 0b176d88d1ee914483b5f77a20549a69be10e8ad (patch) | |
| tree | bfe9bed98abf6cd707787b25e087aa3c55af3b01 | |
| parent | c680d55078aeec96bb70218767c44bcf26bea726 (diff) | |
| download | astar-0b176d88d1ee914483b5f77a20549a69be10e8ad.tar.xz | |
Finish draw_map() optimization
| -rw-r--r-- | map.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -253,11 +253,14 @@ void draw_map(Map map, size_t width, size_t height, Position start, Position goa if (map != NULL) { char c = '\0'; /* The char for the current tile */ /* 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; + if (map_offset_y < 0) top_boundary = -map_offset_y; + if (map_offset_x < 0) left_boundary = -(map_offset_x / 2); + if (top_boundary + LINES < height) bottom_boundary = top_boundary + LINES; + if (left_boundary + COLS/2 < height) right_boundary = left_boundary + COLS/2 + 1; 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 */ |
