add player::handle_input

This commit is contained in:
yuni 2024-03-16 22:33:02 +01:00
parent b223dcdb29
commit c98a6d7dc5
2 changed files with 20 additions and 1 deletions

View file

@ -18,6 +18,7 @@ fn main() {
)) ))
.add_systems(Update, ( .add_systems(Update, (
handle_input, handle_input,
player::handle_input,
audio::toggle_bgm, audio::toggle_bgm,
world::asset_loaded.after(world::load_cubemap_asset), world::asset_loaded.after(world::load_cubemap_asset),
)) ))

View file

@ -4,8 +4,26 @@ use bevy::prelude::*;
pub struct Player { pub struct Player {
pub hp: f32, pub hp: f32,
pub pos: Vec3, pub pos: Vec3,
pub v: Vec3,
}
impl Default for Player {
fn default() -> Self {
Self {
hp: 100.0,
pos: Vec3::ZERO,
v: Vec3::ZERO,
}
}
} }
pub fn setup(mut commands: Commands) { pub fn setup(mut commands: Commands) {
commands.spawn(Player{ hp: 100.0, pos: Vec3::ZERO}); commands.spawn(Player::default());
}
pub fn handle_input(
keyboard_input: Res<ButtonInput<KeyCode>>,
) {
if keyboard_input.pressed(KeyCode::KeyW) {
}
} }