aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 */