From 4398620ac832c4c77160e217f904ec9bf96600fc Mon Sep 17 00:00:00 2001 From: Kristofers Solo Date: Fri, 17 Jan 2025 14:27:02 +0200 Subject: [PATCH] fix: scroll wheel sensitivity in WASM --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/camera.rs | 4 ++-- src/constants.rs | 5 +++++ 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fcfcd1a..0e769ef 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3157,7 +3157,7 @@ dependencies = [ [[package]] name = "maze-ascension" -version = "1.1.0" +version = "1.1.1" dependencies = [ "anyhow", "bevy", diff --git a/Cargo.toml b/Cargo.toml index 3a10a92..196dd9d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "maze-ascension" authors = ["Kristofers Solo "] -version = "1.1.0" +version = "1.1.1" edition = "2021" [dependencies] diff --git a/src/camera.rs b/src/camera.rs index ec8362c..5a21655 100644 --- a/src/camera.rs +++ b/src/camera.rs @@ -1,6 +1,6 @@ use bevy::{input::mouse::MouseWheel, prelude::*}; -use crate::constants::{BASE_ZOOM_SPEED, MAX_ZOOM, MIN_ZOOM}; +use crate::constants::{BASE_ZOOM_SPEED, MAX_ZOOM, MIN_ZOOM, SCROLL_MODIFIER}; pub(super) fn plugin(app: &mut App) { app.add_systems(Update, camera_zoom); @@ -53,7 +53,7 @@ fn camera_zoom( } for ev in scrool_evr.read() { - zoom_delta += ev.y * adjusted_zoom_speed; + zoom_delta += ev.y * adjusted_zoom_speed * SCROLL_MODIFIER; } if zoom_delta != 0.0 { diff --git a/src/constants.rs b/src/constants.rs index 771ec7c..7a7c8e0 100644 --- a/src/constants.rs +++ b/src/constants.rs @@ -14,6 +14,11 @@ pub const MIN_TIME_MULTIPLIER: f32 = 0.1; // Minimum score multiplier for time pub const TIME_REFERENCE_SECONDS: f32 = 60.0; // Reference time for score calculation // Constants for camera control + pub const BASE_ZOOM_SPEED: f32 = 10.0; +#[cfg(not(target_family = "wasm"))] +pub const SCROLL_MODIFIER: f32 = 1.; +#[cfg(target_family = "wasm")] +pub const SCROLL_MODIFIER: f32 = 0.01; pub const MIN_ZOOM: f32 = 50.0; pub const MAX_ZOOM: f32 = 2500.0;