map drawing: drawing tiles correctly if they are visible now
authorLukas Krickl <lukas@krickl.dev>
Thu, 5 Mar 2026 09:29:51 +0000 (10:29 +0100)
committerLukas Krickl <lukas@krickl.dev>
Thu, 5 Mar 2026 09:29:51 +0000 (10:29 +0100)
src/r_assets.c

index 02ba142fea4a9cb7add08bc02223ef8096ec0f0f..ce0d9a5b09ac0b0527be1611a36244a3b9d901e1 100644 (file)
@@ -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);