enforce min/max zoom levels

This commit is contained in:
yuni 2024-04-19 03:38:32 +02:00
parent 7d063209fa
commit 70a602de5c

View file

@ -138,10 +138,10 @@ pub fn update_map_camera(
// Update zoom level // Update zoom level
if keyboard_input.pressed(settings.key_map_zoom_out) { 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) { 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) 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; mapcam.zoom_level = zoom_speed * mapcam.target_zoom_level + (1.0 - zoom_speed) * mapcam.zoom_level;