1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use bevy::prelude::*;

use game_library::CameraScaleLevel;

#[derive(Component)]
pub struct MainCamera;

/// Spawns a basic camera
pub fn setup_camera(mut commands: Commands) {
    commands.spawn((
        Camera2dBundle::default(),
        MainCamera,
        CameraScaleLevel::default(),
    ));
}

/// Zooms the camera based on the current scale level
pub fn zoom_camera(
    mut query: Query<(&mut OrthographicProjection, &CameraScaleLevel), With<MainCamera>>,
) {
    for (mut projection, scale_level) in &mut query {
        projection.scale = scale_level.value();
    }
}