From 492c4238cb700de5ef367254e348a17a6aa26829 Mon Sep 17 00:00:00 2001 From: Nixon Date: Sun, 28 Aug 2022 17:04:02 +0800 Subject: [PATCH] added initial zoom out timer - to view the overall level --- src/game.rs | 33 +++++++++++++++++++++++---------- src/levels.rs | 22 ++++++++++++++++++++-- src/main.rs | 2 +- 3 files changed, 44 insertions(+), 13 deletions(-) diff --git a/src/game.rs b/src/game.rs index 9562b99..b94eb90 100644 --- a/src/game.rs +++ b/src/game.rs @@ -2,8 +2,8 @@ #![allow(clippy::too_many_arguments)] pub use crate::filters::*; - use crate::{AppState, audio_system}; +use crate::levels; use bevy::{ ecs::system::EntityCommands, @@ -28,6 +28,7 @@ impl Plugin for GamePlugin { .init_resource::() .insert_resource(CurrentLevel(None)) .init_resource::() + .init_resource::() .add_system_set(SystemSet::on_enter(AppState::Game).with_system(setup)) .add_system_set(SystemSet::on_enter(AppState::Win).with_system(win_setup)) .add_system_set( @@ -39,14 +40,14 @@ impl Plugin for GamePlugin { .with_system(change_character_system) .with_system(player_movement_system) .with_system(level_keyboard_system) - .with_system(move_camera) + .with_system(camera_system) .with_system(character_particle_effect_system), ) .add_system_set( SystemSet::on_update(AppState::Win) .with_system(player_movement_system) .with_system(level_keyboard_system) - .with_system(move_camera) + .with_system(camera_system) .with_system(character_particle_effect_system) .with_system(move_win_text_system), ) @@ -136,13 +137,14 @@ fn setup( first_level: Res, mut current_level: ResMut, mut level_startup_event: EventWriter, - mut camera_query: Query<&mut Transform, With>, + mut camera_query: Query<(&mut Transform, &mut OrthographicProjection), With>, + mut zoom_timer: ResMut, ) { if current_level.0.is_none() { current_level.0 = Some(first_level.0); } - crate::levels::setup_level(&mut level_startup_event, &mut camera_query); + crate::levels::setup_level(&mut level_startup_event, &mut camera_query, &mut zoom_timer); } pub fn spawn_characters>( @@ -560,16 +562,22 @@ fn win_setup( .insert(WinText); } -fn move_camera( - mut camera_query: Query<(&Camera, &mut Transform)>, +fn camera_system( + mut camera_query: Query<(&Camera, &mut OrthographicProjection, &mut Transform)>, characters: Query<&Transform, (Without, With)>, time: Res