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..008b906 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}; @@ -16,6 +17,8 @@ pub const Z_BASE_FLOOR: f32 = 100.0; // Base z-coordinate for 2D layers. pub const Z_BASE_OBJECTS: f32 = 200.0; // Ground object sprites. pub const SCREEN_SIZE: (f32, f32) = (1280.0, 720.0); pub const CAMERA_SCALE: f32 = 1.0; +pub const CAMERA_SCALE_BOUNDS: (f32, f32) = (1., 20.); +pub const CAMERA_ZOOM_SPEED: f32 = 3.; // Misc components. #[derive(Component)] @@ -70,7 +73,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 +965,24 @@ fn system_move_camera( camera_transform.translation.y = camera_current.y; } } + +fn system_camera_zoom( + mut cameras: Query<&mut OrthographicProjection, With>, + time: Res