54 lines
1.6 KiB
Rust
54 lines
1.6 KiB
Rust
use bevy::prelude::*;
|
|
#[cfg(feature = "inspector")]
|
|
use cyber_rider::glamor::CyberGlamorPlugin;
|
|
use cyber_rider::{
|
|
action::CyberActionPlugin, bike::CyberBikePlugin, camera::CyberCamPlugin, disable_mouse_trap,
|
|
input::CyberInputPlugin, lights::CyberSpaceLightsPlugin, planet::CyberPlanetPlugin,
|
|
ui::CyberUIPlugin,
|
|
};
|
|
|
|
//const CYBER_SKY: Color = Color::rgb(0.07, 0.001, 0.02);
|
|
const CYBER_SKY: Color = Color::srgb(0.64, 0.745, 0.937); // a light blue sky
|
|
|
|
fn main() {
|
|
let mut app = App::new();
|
|
app.insert_resource(ClearColor(CYBER_SKY))
|
|
.add_plugins(DefaultPlugins.set(WindowPlugin {
|
|
primary_window: Some(Window {
|
|
resolution: (2560.0, 1440.0).into(),
|
|
..Default::default()
|
|
}),
|
|
..Default::default()
|
|
}))
|
|
.add_plugins((
|
|
CyberPlanetPlugin,
|
|
CyberInputPlugin,
|
|
CyberActionPlugin,
|
|
CyberCamPlugin,
|
|
CyberSpaceLightsPlugin,
|
|
CyberUIPlugin,
|
|
CyberBikePlugin,
|
|
#[cfg(feature = "inspector")]
|
|
CyberGlamorPlugin,
|
|
))
|
|
.add_systems(Startup, disable_mouse_trap)
|
|
.add_systems(Update, close_on_esc);
|
|
|
|
app.run();
|
|
}
|
|
|
|
fn close_on_esc(
|
|
mut commands: Commands,
|
|
focused_windows: Query<(Entity, &Window)>,
|
|
input: Res<ButtonInput<KeyCode>>,
|
|
) {
|
|
for (window, focus) in focused_windows.iter() {
|
|
if !focus.focused {
|
|
continue;
|
|
}
|
|
|
|
if input.just_pressed(KeyCode::Escape) {
|
|
commands.entity(window).despawn();
|
|
}
|
|
}
|
|
}
|