outfly/src/main.rs

46 lines
1.1 KiB
Rust
Raw Normal View History

2024-03-16 19:53:57 +00:00
mod audio;
2024-03-16 20:22:59 +00:00
mod player;
mod camera;
2024-03-16 20:44:51 +00:00
mod world;
2024-03-16 19:53:57 +00:00
2024-03-16 20:44:51 +00:00
use bevy::window::{Window, WindowMode, PrimaryWindow, CursorGrabMode };
use bevy::prelude::*;
2024-03-16 14:00:31 +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, (
setup,
audio::setup,
2024-03-16 20:22:59 +00:00
player::setup,
2024-03-16 20:44:51 +00:00
world::setup,
2024-03-16 19:53:57 +00:00
))
2024-03-16 15:22:44 +00:00
.add_systems(Update, (
2024-03-16 19:53:57 +00:00
handle_input,
audio::toggle_bgm,
2024-03-16 20:44:51 +00:00
world::asset_loaded.after(world::load_cubemap_asset),
2024-03-16 15:22:44 +00:00
))
2024-03-16 15:35:39 +00:00
.add_plugins(DefaultPlugins.set(ImagePlugin::default_nearest()))
.add_plugins(camera::CameraControllerPlugin)
2024-03-16 14:00:31 +00:00
.run();
}
fn setup(
2024-03-16 20:44:51 +00:00
//mut commands: Commands,
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 15:22:44 +00:00
}
2024-03-16 15:12:35 +00:00
fn handle_input(
keyboard_input: Res<ButtonInput<KeyCode>>,
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
}
}