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);