generated from tipragot/rust
Add a camera system #69
|
@ -56,7 +56,13 @@ fn init_camera(mut commands: Commands) {
|
||||||
commands.spawn(Camera2dBundle::default());
|
commands.spawn(Camera2dBundle::default());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Initializes the key movement settings for the camera.
|
/// Initializes the resources related to the camera.
|
||||||
|
///
|
||||||
|
/// - [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) {
|
fn init_resources(mut commands: Commands) {
|
||||||
commands.insert_resource(KeysMovementSettings {
|
commands.insert_resource(KeysMovementSettings {
|
||||||
up: KeyCode::Z,
|
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(
|
fn scale_system(
|
||||||
mut scroll_ev: EventReader<MouseWheel>,
|
mut scroll_event: EventReader<MouseWheel>,
|
||||||
mut query: Query<&mut OrthographicProjection, With<Camera>>,
|
mut query: Query<&mut OrthographicProjection, With<Camera>>,
|
||||||
min_scale: Res<MinScale>,
|
min_scale: Res<MinScale>,
|
||||||
max_scale: Res<MaxScale>,
|
max_scale: Res<MaxScale>,
|
||||||
scale_speed: Res<CameraSpeedScale>,
|
scale_speed: Res<CameraSpeedScale>,
|
||||||
) {
|
) {
|
||||||
for ev in scroll_ev.read() {
|
for ev in scroll_event.read() {
|
||||||
for mut projection in query.iter_mut() {
|
for mut projection in query.iter_mut() {
|
||||||
if ev.unit != MouseScrollUnit::Line {
|
if ev.unit != MouseScrollUnit::Line {
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in a new issue