cli: skip to level
This commit is contained in:
parent
445f3850ca
commit
21d98a4a1d
2 changed files with 14 additions and 1 deletions
|
@ -21,6 +21,8 @@ pub enum AudioMsg {
|
|||
Switch,
|
||||
}
|
||||
|
||||
pub struct FirstLevel(pub LevelId);
|
||||
|
||||
#[derive(Clone, Copy, Eq, Hash, PartialEq)]
|
||||
pub struct LevelId(pub u32);
|
||||
|
||||
|
@ -99,12 +101,13 @@ pub struct CollisionCount(usize);
|
|||
// Systems
|
||||
|
||||
fn setup(
|
||||
first_level: Res<FirstLevel>,
|
||||
mut current_level: ResMut<CurrentLevel>,
|
||||
mut level_startup_event: EventWriter<LevelStartupEvent>,
|
||||
mut camera_query: Query<&mut Transform, With<Camera>>,
|
||||
) {
|
||||
if current_level.0.is_none() {
|
||||
current_level.0 = Some(LevelId(0));
|
||||
current_level.0 = Some(first_level.0);
|
||||
}
|
||||
|
||||
crate::levels::setup_level(&mut level_startup_event, &mut camera_query);
|
||||
|
|
10
src/main.rs
10
src/main.rs
|
@ -26,10 +26,20 @@ fn main() {
|
|||
#[cfg(not(target_arch = "wasm32"))]
|
||||
std::thread::spawn(move || audio::setup(audio_event_receiver));
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
let first_level = game::LevelId(
|
||||
std::env::args()
|
||||
.nth(1)
|
||||
.map_or(0, |s| s.parse().unwrap_or(0)),
|
||||
);
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
let first_level = game::LevelId(0);
|
||||
|
||||
App::new()
|
||||
.insert_resource(Msaa { samples: 4 })
|
||||
.insert_resource(audio_event_sender)
|
||||
.add_state(AppState::Menu)
|
||||
.insert_resource(game::FirstLevel(first_level))
|
||||
.insert_resource(ClearColor(Color::BLACK))
|
||||
.add_plugins(DefaultPlugins)
|
||||
.add_plugin(RapierPhysicsPlugin::<NoUserData>::pixels_per_meter(64.0))
|
||||
|
|
Loading…
Reference in a new issue