diff --git a/assets/player/player-2x.png b/assets/player/player-2x.png index edfc2b3..c62aa7c 100644 Binary files a/assets/player/player-2x.png and b/assets/player/player-2x.png differ diff --git a/assets/player/player-4x.png b/assets/player/player-4x.png index db9490f..cc5a609 100644 Binary files a/assets/player/player-4x.png and b/assets/player/player-4x.png differ diff --git a/assets/player/player.png b/assets/player/player.png index d0d9131..47b4aa3 100644 Binary files a/assets/player/player.png and b/assets/player/player.png differ diff --git a/src/main.rs b/src/main.rs index 13b058b..b24e6f3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -55,12 +55,22 @@ fn main() { .init_resource::() .init_resource::() .add_systems(Startup, (setup, setup_ui)) - .add_systems(Update, (render_ui, movement, camera_follow)) + .add_systems(Update, (render_ui, movement, camera_follow, player_regen)) .run(); } // Bevy engine setup fn setup(mut commands: Commands, asset_server: Res) { + commands.spawn(SpriteBundle { + texture: asset_server.load("player/player-4x.png"), + transform: Transform { + scale: Vec3::splat(0.2), + ..default() + }, + ..default() + }); + + // Spawn the 2D camera commands.spawn(Camera2dBundle { camera: Camera { hdr: true, @@ -69,34 +79,26 @@ fn setup(mut commands: Commands, asset_server: Res) { tonemapping: Tonemapping::TonyMcMapface, ..default() }); - commands.spawn( - SpriteBundle { + + // Spawn the player + commands + .spawn(SpriteBundle { texture: asset_server.load("player/player-4x.png"), transform: Transform { scale: Vec3::splat(0.2), ..default() }, ..default() - }); - commands.spawn(( - SpriteBundle { - texture: asset_server.load("player/player-4x.png"), - transform: Transform { - scale: Vec3::splat(0.2), - ..default() - }, - ..default() - }, - Player { + }) + .insert(Player { movement_speed: 512., rotation_speed: f32::to_radians(360.), - health: 10., + health: 1., health_max: 10., - stamina: 10., + stamina: 1., stamina_max: 10., defence: 40., - }, - )); + }); } diff --git a/src/player.rs b/src/player.rs index 3af183a..f0ba0ac 100644 --- a/src/player.rs +++ b/src/player.rs @@ -18,13 +18,25 @@ pub struct Player { pub fn movement( time: Res