Add a camera system #69

Merged
CoCo_Sol merged 15 commits from camera into main 2024-03-02 11:18:13 +00:00
Showing only changes of commit 382d1c102d - Show all commits

View file

@ -56,7 +56,13 @@ fn init_camera(mut commands: Commands) {
commands.spawn(Camera2dBundle::default());
}
/// Initializes the key movement settings for the camera.
/// Initializes the resources related to the camera.
CoCo_Sol marked this conversation as resolved Outdated

Not only...

Not only...
///
/// - [KeysMovementSettings]: The key settings for camera movement.
/// - [CameraSpeedMouvement]: The speed of camera movement.
/// - [CameraSpeedScale]: The speed of camera scaling.
/// - [MinScale]: The minimum scale of the camera.
/// - [MaxScale]: The maximum scale of the camera.
fn init_resources(mut commands: Commands) {
commands.insert_resource(KeysMovementSettings {
up: KeyCode::Z,
@ -94,15 +100,15 @@ fn movement_system(
}
}
/// Scales the camera with mouse input.
/// Scales the view with mouse input.
fn scale_system(
mut scroll_ev: EventReader<MouseWheel>,
mut scroll_event: EventReader<MouseWheel>,
mut query: Query<&mut OrthographicProjection, With<Camera>>,
min_scale: Res<MinScale>,
max_scale: Res<MaxScale>,
scale_speed: Res<CameraSpeedScale>,
) {
for ev in scroll_ev.read() {
for ev in scroll_event.read() {
for mut projection in query.iter_mut() {
if ev.unit != MouseScrollUnit::Line {
return;