Fullscreen & exit controls
This commit is contained in:
parent
2a4625269f
commit
05ecbbbbec
2 changed files with 29 additions and 3 deletions
|
@ -2,6 +2,7 @@
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8"/>
|
<meta charset="UTF-8"/>
|
||||||
|
<title>Bevyjam</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<script type="module">
|
<script type="module">
|
||||||
|
|
31
src/main.rs
31
src/main.rs
|
@ -6,7 +6,10 @@ mod levels;
|
||||||
mod menu;
|
mod menu;
|
||||||
mod particle_effect;
|
mod particle_effect;
|
||||||
|
|
||||||
use bevy::prelude::*;
|
use bevy::{
|
||||||
|
prelude::*,
|
||||||
|
window::{WindowId, WindowMode},
|
||||||
|
};
|
||||||
use bevy_rapier2d::prelude::*;
|
use bevy_rapier2d::prelude::*;
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
|
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
|
||||||
|
@ -35,12 +38,17 @@ fn main() {
|
||||||
.add_plugin(game::GamePlugin)
|
.add_plugin(game::GamePlugin)
|
||||||
.add_plugin(particle_effect::ParticleEffectPlugin)
|
.add_plugin(particle_effect::ParticleEffectPlugin)
|
||||||
//.add_plugin(bevy_inspector_egui::WorldInspectorPlugin::new())
|
//.add_plugin(bevy_inspector_egui::WorldInspectorPlugin::new())
|
||||||
.add_system(bevy::window::close_on_esc)
|
.add_system(keyboard_util_system)
|
||||||
.add_startup_system(setup)
|
.add_startup_system(setup)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
fn setup(mut commands: Commands, mut windows: ResMut<Windows>, asset_server: Res<AssetServer>) {
|
||||||
|
windows
|
||||||
|
.get_mut(WindowId::primary())
|
||||||
|
.unwrap()
|
||||||
|
.set_title(String::from("Bevyjam"));
|
||||||
|
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
let font: Handle<Font> = asset_server.load("UacariLegacy-Thin.ttf");
|
let font: Handle<Font> = asset_server.load("UacariLegacy-Thin.ttf");
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_arch = "wasm32")]
|
||||||
|
@ -53,3 +61,20 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||||
brightness: 0.6,
|
brightness: 0.6,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn keyboard_util_system(keyboard_input: Res<Input<KeyCode>>, mut windows: ResMut<Windows>) {
|
||||||
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
|
{
|
||||||
|
if keyboard_input.just_released(KeyCode::Escape) {
|
||||||
|
std::process::exit(0);
|
||||||
|
}
|
||||||
|
if keyboard_input.just_pressed(KeyCode::F11) {
|
||||||
|
if let Some(window) = windows.get_primary_mut() {
|
||||||
|
window.set_mode(match window.mode() {
|
||||||
|
WindowMode::Windowed => WindowMode::Fullscreen,
|
||||||
|
_ => WindowMode::Windowed,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue