mod audio; mod camera; mod world; mod settings; mod hud; mod actor; use bevy::window::{Window, WindowMode, PrimaryWindow, CursorGrabMode }; use bevy::diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin}; use bevy::prelude::*; fn main() { App::new() .add_systems(Startup, ( setup, audio::setup, world::setup, )) .add_systems(Update, ( handle_input, audio::toggle_bgm, world::asset_loaded.after(world::load_cubemap_asset), )) .add_plugins(DefaultPlugins.set(ImagePlugin::default_nearest())) .add_plugins(( camera::CameraControllerPlugin, hud::HudPlugin, actor::ActorPlugin, )) .add_plugins(( FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin::default(), )) .insert_resource(settings::Settings::default()) .run(); } fn setup( //mut commands: Commands, mut windows: Query<&mut Window, With> ) { for mut window in &mut windows { window.cursor.grab_mode = CursorGrabMode::Locked; window.cursor.visible = false; window.mode = WindowMode::Fullscreen; window.title = "OutFly".to_string(); } } fn handle_input( keyboard_input: Res>, mut settings: ResMut, mut app_exit_events: ResMut> ) { if keyboard_input.pressed(KeyCode::KeyQ) { app_exit_events.send(bevy::app::AppExit); } if keyboard_input.just_pressed(KeyCode::F12) { settings.reset(); } }