From c8162dc2de9bd11ad8a85aefc56072598625fc39 Mon Sep 17 00:00:00 2001 From: Carson Date: Thu, 29 Aug 2024 23:30:20 -0700 Subject: [PATCH 1/2] krypta zooming and LMB readme correction --- README.md | 2 +- examples/krypta.rs | 29 ++++++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e6bcf43..7c704f4 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ cargo run --example krypta ``` - WASD to control camera. -- LMC to place a light source. +- SHIFT+LMC to place a light source. - RMC to change color of light source. ## TODOs diff --git a/examples/krypta.rs b/examples/krypta.rs index b6c8bc3..e3dac7a 100644 --- a/examples/krypta.rs +++ b/examples/krypta.rs @@ -1,4 +1,5 @@ use bevy::color::palettes; +use bevy::input::mouse::MouseWheel; use bevy::prelude::*; use bevy::render::camera::RenderTarget; use bevy::render::texture::{ImageFilterMode, ImageSamplerDescriptor}; @@ -70,7 +71,7 @@ fn main() .register_type::() .register_type::() .add_systems(Startup, setup.after(setup_post_processing_camera)) - .add_systems(Update, system_move_camera) + .add_systems(Update, (system_move_camera, system_camera_zoom)) .add_systems(Update, system_control_mouse_light.after(system_move_camera)) .run(); } @@ -962,3 +963,29 @@ fn system_move_camera( camera_transform.translation.y = camera_current.y; } } + +mod camera { + pub const MIN_SCALE: f32 =1.; + pub const MAX_SCALE: f32 = 20.; +} + +fn system_camera_zoom( + mut cameras: Query<&mut OrthographicProjection, With>, + time: Res