From c98a6d7dc5e94eea1e88de244f02a9030562808b Mon Sep 17 00:00:00 2001 From: hut Date: Sat, 16 Mar 2024 22:33:02 +0100 Subject: [PATCH] add player::handle_input --- src/main.rs | 1 + src/player.rs | 20 +++++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index a0080e0..3d6a9b4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -18,6 +18,7 @@ fn main() { )) .add_systems(Update, ( handle_input, + player::handle_input, audio::toggle_bgm, world::asset_loaded.after(world::load_cubemap_asset), )) diff --git a/src/player.rs b/src/player.rs index 8b4b212..e0e6ba9 100644 --- a/src/player.rs +++ b/src/player.rs @@ -4,8 +4,26 @@ use bevy::prelude::*; pub struct Player { pub hp: f32, 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) { - commands.spawn(Player{ hp: 100.0, pos: Vec3::ZERO}); + commands.spawn(Player::default()); +} + +pub fn handle_input( + keyboard_input: Res>, +) { + if keyboard_input.pressed(KeyCode::KeyW) { + } }