aboutsummaryrefslogtreecommitdiff
path: root/map.c
diff options
context:
space:
mode:
authorKirill Petrashin <kirill8201@yandex.ru>2026-04-13 11:47:45 +0300
committerKirill Petrashin <kirill8201@yandex.ru>2026-04-13 11:47:45 +0300
commit0b176d88d1ee914483b5f77a20549a69be10e8ad (patch)
treebfe9bed98abf6cd707787b25e087aa3c55af3b01 /map.c
parentc680d55078aeec96bb70218767c44bcf26bea726 (diff)
downloadastar-0b176d88d1ee914483b5f77a20549a69be10e8ad.tar.xz
Finish draw_map() optimization
Diffstat (limited to 'map.c')
-rw-r--r--map.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/map.c b/map.c
index 70ba953..40c30b5 100644
--- a/map.c
+++ b/map.c
@@ -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 */