From cc0f8899c8033dc2cd9ab74bd20c1bbba696ff1d Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Thu, 5 Mar 2026 10:29:51 +0100 Subject: [PATCH] map drawing: drawing tiles correctly if they are visible now --- src/r_assets.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/r_assets.c b/src/r_assets.c index 02ba142..ce0d9a5 100644 --- a/src/r_assets.c +++ b/src/r_assets.c @@ -52,11 +52,18 @@ void r_draw_solid_isometric_tile(i32 x, i32 y, r_color color) { u32 j = 0; r_color final_color; struct u_vec2 t = u_tile_to_screen(x, y); - struct u_vec2 te = u_tile_to_screen(x+1, y+1); + struct u_vec2 tt = u_tile_to_screen(x+1, y+1); + struct u_vec2 tl = u_tile_to_screen(x+2, y); + struct u_vec2 tb = u_tile_to_screen(x+2, y-2); - /* do not draw if tile is not visible at all */ + /* do not draw if tile is not visible at all + * also include a few points outside the camera to avoid tiles + * popping in + */ if (!t_camera_is_visible_screen(&t_main_camera, t.x, t.y) - && !t_camera_is_visible_screen(&t_main_camera, te.x, te.y)) { + && !t_camera_is_visible_screen(&t_main_camera, tt.x, tt.y) + && !t_camera_is_visible_screen(&t_main_camera, tb.x, tb.y) + && !t_camera_is_visible_screen(&t_main_camera, tl.x, tl.y)) { return; } t = u_screen_to_camera(&t_main_camera, t); -- 2.30.2