Initial commit
This commit is contained in:
commit
d109225da6
12 changed files with 5189 additions and 0 deletions
42
src/menu.rs
Normal file
42
src/menu.rs
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
use crate::AppState;
|
||||
|
||||
use bevy::{
|
||||
input::{keyboard::KeyCode, Input},
|
||||
prelude::*,
|
||||
sprite::MaterialMesh2dBundle,
|
||||
};
|
||||
|
||||
pub struct MenuPlugin;
|
||||
|
||||
impl Plugin for MenuPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.add_system_set(SystemSet::on_enter(AppState::Menu).with_system(setup))
|
||||
.add_system_set(
|
||||
SystemSet::on_update(AppState::Menu).with_system(keyboard_input_system),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||
commands.spawn_bundle(Text2dBundle {
|
||||
text: Text::from_section(
|
||||
"Press ENTER",
|
||||
TextStyle {
|
||||
font: asset_server.get_handle("Cantarell-VF.odt"),
|
||||
font_size: 64.0,
|
||||
color: Color::WHITE,
|
||||
},
|
||||
)
|
||||
.with_alignment(TextAlignment::CENTER),
|
||||
..Default::default()
|
||||
});
|
||||
}
|
||||
|
||||
fn keyboard_input_system(
|
||||
keyboard_input: Res<Input<KeyCode>>,
|
||||
mut app_state: ResMut<State<AppState>>,
|
||||
) {
|
||||
if keyboard_input.just_pressed(KeyCode::Return) {
|
||||
app_state.replace(AppState::Game).unwrap()
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue