From 70a602de5c1bea2eb6793bec2f5928a4ab05e379 Mon Sep 17 00:00:00 2001 From: hut Date: Fri, 19 Apr 2024 03:38:32 +0200 Subject: [PATCH] enforce min/max zoom levels --- src/camera.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/camera.rs b/src/camera.rs index 468e4de..32168a5 100644 --- a/src/camera.rs +++ b/src/camera.rs @@ -138,10 +138,10 @@ pub fn update_map_camera( // Update zoom level if keyboard_input.pressed(settings.key_map_zoom_out) { - mapcam.target_zoom_level *= 1.1; + mapcam.target_zoom_level = (mapcam.target_zoom_level * 1.1).min(17e18); } if keyboard_input.pressed(settings.key_map_zoom_in) { - mapcam.target_zoom_level /= 1.1; + mapcam.target_zoom_level = (mapcam.target_zoom_level / 1.1).max(2.0); } let zoom_speed = 0.05; // should be between 0.0001 (slow) and 1.0 (instant) mapcam.zoom_level = zoom_speed * mapcam.target_zoom_level + (1.0 - zoom_speed) * mapcam.zoom_level;