fix: scroll wheel sensitivity in WASM

This commit is contained in:
Kristofers Solo 2025-01-17 14:27:02 +02:00
parent e1fa12b6b9
commit 4398620ac8
4 changed files with 9 additions and 4 deletions

2
Cargo.lock generated
View File

@ -3157,7 +3157,7 @@ dependencies = [
[[package]] [[package]]
name = "maze-ascension" name = "maze-ascension"
version = "1.1.0" version = "1.1.1"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bevy", "bevy",

View File

@ -1,7 +1,7 @@
[package] [package]
name = "maze-ascension" name = "maze-ascension"
authors = ["Kristofers Solo <dev@kristofers.xyz>"] authors = ["Kristofers Solo <dev@kristofers.xyz>"]
version = "1.1.0" version = "1.1.1"
edition = "2021" edition = "2021"
[dependencies] [dependencies]

View File

@ -1,6 +1,6 @@
use bevy::{input::mouse::MouseWheel, prelude::*}; 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) { pub(super) fn plugin(app: &mut App) {
app.add_systems(Update, camera_zoom); app.add_systems(Update, camera_zoom);
@ -53,7 +53,7 @@ fn camera_zoom(
} }
for ev in scrool_evr.read() { 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 { if zoom_delta != 0.0 {

View File

@ -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 pub const TIME_REFERENCE_SECONDS: f32 = 60.0; // Reference time for score calculation
// Constants for camera control // Constants for camera control
pub const BASE_ZOOM_SPEED: f32 = 10.0; 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 MIN_ZOOM: f32 = 50.0;
pub const MAX_ZOOM: f32 = 2500.0; pub const MAX_ZOOM: f32 = 2500.0;