61 lines
1.5 KiB
Rust
61 lines
1.5 KiB
Rust
mod audio;
|
|
mod camera;
|
|
mod world;
|
|
mod settings;
|
|
mod hud;
|
|
mod actor;
|
|
|
|
#[allow(dead_code)]
|
|
mod nature;
|
|
|
|
use bevy::window::{Window, WindowMode, PrimaryWindow, CursorGrabMode};
|
|
use bevy::diagnostic::FrameTimeDiagnosticsPlugin;
|
|
use bevy::prelude::*;
|
|
|
|
fn main() {
|
|
App::new().add_plugins(OutFlyPlugin).run();
|
|
}
|
|
|
|
pub struct OutFlyPlugin;
|
|
impl Plugin for OutFlyPlugin {
|
|
fn build(&self, app: &mut App) {
|
|
app.add_systems(Startup, setup);
|
|
app.add_systems(Update, handle_input);
|
|
app.insert_resource(settings::Settings::default());
|
|
app.add_plugins((
|
|
DefaultPlugins,//.set(ImagePlugin::default_nearest()),
|
|
FrameTimeDiagnosticsPlugin,
|
|
|
|
world::WorldPlugin,
|
|
camera::CameraControllerPlugin,
|
|
hud::HudPlugin,
|
|
actor::ActorPlugin,
|
|
audio::AudioPlugin,
|
|
));
|
|
}
|
|
}
|
|
|
|
fn setup(
|
|
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;
|
|
window.title = "OutFly".to_string();
|
|
}
|
|
}
|
|
|
|
fn handle_input(
|
|
keyboard_input: Res<ButtonInput<KeyCode>>,
|
|
mut settings: ResMut<settings::Settings>,
|
|
mut app_exit_events: ResMut<Events<bevy::app::AppExit>>
|
|
) {
|
|
if keyboard_input.pressed(settings.key_exit) {
|
|
app_exit_events.send(bevy::app::AppExit);
|
|
}
|
|
if keyboard_input.just_pressed(settings.key_restart) {
|
|
settings.reset();
|
|
}
|
|
}
|