2024-03-16 19:53:57 +00:00
|
|
|
mod audio;
|
2024-03-16 20:00:40 +00:00
|
|
|
mod camera;
|
2024-03-16 20:44:51 +00:00
|
|
|
mod world;
|
2024-03-16 21:20:23 +00:00
|
|
|
mod settings;
|
2024-03-17 14:23:22 +00:00
|
|
|
mod hud;
|
2024-03-17 22:49:50 +00:00
|
|
|
mod actor;
|
2024-03-16 19:53:57 +00:00
|
|
|
|
2024-03-16 22:05:07 +00:00
|
|
|
use bevy::window::{Window, WindowMode, PrimaryWindow, CursorGrabMode };
|
2024-03-17 13:55:09 +00:00
|
|
|
use bevy::diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin};
|
2024-03-16 20:44:51 +00:00
|
|
|
use bevy::prelude::*;
|
2024-03-16 14:00:31 +00:00
|
|
|
|
2024-03-16 13:27:22 +00:00
|
|
|
fn main() {
|
2024-03-16 14:00:31 +00:00
|
|
|
App::new()
|
2024-03-16 19:53:57 +00:00
|
|
|
.add_systems(Startup, (
|
2024-03-16 22:05:07 +00:00
|
|
|
setup,
|
|
|
|
audio::setup,
|
|
|
|
world::setup,
|
2024-03-16 19:53:57 +00:00
|
|
|
))
|
2024-03-16 15:22:44 +00:00
|
|
|
.add_systems(Update, (
|
2024-03-16 22:05:07 +00:00
|
|
|
handle_input,
|
|
|
|
audio::toggle_bgm,
|
|
|
|
world::asset_loaded.after(world::load_cubemap_asset),
|
2024-03-16 15:22:44 +00:00
|
|
|
))
|
2024-03-16 22:05:07 +00:00
|
|
|
.add_plugins(DefaultPlugins.set(ImagePlugin::default_nearest()))
|
2024-03-17 14:23:22 +00:00
|
|
|
.add_plugins((
|
|
|
|
camera::CameraControllerPlugin,
|
2024-03-17 22:49:50 +00:00
|
|
|
hud::HudPlugin,
|
|
|
|
actor::ActorPlugin,
|
2024-03-17 14:23:22 +00:00
|
|
|
))
|
2024-03-17 13:55:09 +00:00
|
|
|
.add_plugins((
|
|
|
|
FrameTimeDiagnosticsPlugin,
|
|
|
|
LogDiagnosticsPlugin::default(),
|
|
|
|
))
|
2024-03-17 17:26:44 +00:00
|
|
|
.insert_resource(settings::Settings::default())
|
2024-03-16 14:00:31 +00:00
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
2024-03-16 18:07:28 +00:00
|
|
|
fn setup(
|
2024-03-16 20:44:51 +00:00
|
|
|
//mut commands: Commands,
|
2024-03-16 18:07:28 +00:00
|
|
|
mut windows: Query<&mut Window, With<PrimaryWindow>>
|
|
|
|
) {
|
|
|
|
for mut window in &mut windows {
|
|
|
|
window.cursor.grab_mode = CursorGrabMode::Locked;
|
|
|
|
window.cursor.visible = false;
|
|
|
|
window.mode = WindowMode::Fullscreen;
|
2024-03-16 23:24:47 +00:00
|
|
|
window.title = "OutFly".to_string();
|
2024-03-16 18:07:28 +00:00
|
|
|
}
|
2024-03-16 15:22:44 +00:00
|
|
|
}
|
|
|
|
|
2024-03-16 15:12:35 +00:00
|
|
|
fn handle_input(
|
|
|
|
keyboard_input: Res<ButtonInput<KeyCode>>,
|
2024-03-17 17:26:44 +00:00
|
|
|
mut settings: ResMut<settings::Settings>,
|
2024-03-16 15:12:35 +00:00
|
|
|
mut app_exit_events: ResMut<Events<bevy::app::AppExit>>
|
|
|
|
) {
|
|
|
|
if keyboard_input.pressed(KeyCode::KeyQ) {
|
|
|
|
app_exit_events.send(bevy::app::AppExit);
|
2024-03-16 14:13:00 +00:00
|
|
|
}
|
2024-03-16 21:20:23 +00:00
|
|
|
if keyboard_input.just_pressed(KeyCode::F12) {
|
2024-03-17 17:26:44 +00:00
|
|
|
settings.reset();
|
2024-03-16 21:20:23 +00:00
|
|
|
}
|
2024-03-16 14:13:00 +00:00
|
|
|
}
|