Added zoom limits

master
Mark 2023-12-22 22:15:41 -08:00
parent c0db69bd76
commit c12d278d80
Signed by: Mark
GPG Key ID: C6D63995FE72FD80
1 changed files with 5 additions and 1 deletions

View File

@ -78,6 +78,9 @@ struct Game {
}
impl Game {
const ZOOM_MIN: Pfloat = 200.0;
const ZOOM_MAX: Pfloat = 2000.0;
fn new() -> Self {
Game {
last_update: Instant::now(),
@ -119,7 +122,8 @@ impl Game {
}
if self.input.v_scroll != 0.0 {
self.camera.zoom += self.input.v_scroll;
self.camera.zoom =
(self.camera.zoom + self.input.v_scroll).clamp(Self::ZOOM_MIN, Self::ZOOM_MAX);
self.input.v_scroll = 0.0;
}