From b8f1849d7a9c75f0a0c407bcbd5b9d0ca0f8a170 Mon Sep 17 00:00:00 2001 From: Muhammad Nauman Raza Date: Sat, 16 Mar 2024 00:14:10 +0000 Subject: [PATCH] feat: basic attacks --- Cargo.lock | 2 +- flake.lock | 12 +++++------ src/main.rs | 2 +- src/player.rs | 57 ++++++++++++++++++++++++++++++++++++--------------- 4 files changed, 49 insertions(+), 24 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 626e54d..036c445 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -129,7 +129,7 @@ dependencies = [ [[package]] name = "ambition" -version = "0.1.0" +version = "0.2.0" dependencies = [ "bevy", "bevy_egui", diff --git a/flake.lock b/flake.lock index 3a29579..3ca045c 100644 --- a/flake.lock +++ b/flake.lock @@ -8,11 +8,11 @@ "rust-analyzer-src": "rust-analyzer-src" }, "locked": { - "lastModified": 1710397340, - "narHash": "sha256-cetHTP4c7eILb1v5nD0HO4Nev1egEDuqo8OOk90khYg=", + "lastModified": 1710483719, + "narHash": "sha256-Ev/hJ59IAA3dWfTB3CWxMv/V/owO1yKyq0nwsek/d9o=", "owner": "nix-community", "repo": "fenix", - "rev": "80409698f025fcbf931d9bd7a6a07a3a06356271", + "rev": "d0439c495e5cd13ff252ade520ca620f52abb40b", "type": "github" }, "original": { @@ -97,11 +97,11 @@ "rust-analyzer-src": { "flake": false, "locked": { - "lastModified": 1710319630, - "narHash": "sha256-2PO3d37euWrUTFofT/Edji+zorOgfiIrMKqhuq3ffHU=", + "lastModified": 1710430493, + "narHash": "sha256-KfmUsf/d62ANcFhSTR3BDIpk2ww0AcxXdi9lpZJ5UtQ=", "owner": "rust-lang", "repo": "rust-analyzer", - "rev": "e8182a5bb32ca5763fd817661447f75138fb3883", + "rev": "14558af15ee3d471bf8f4212f7609ae1f9647bc5", "type": "github" }, "original": { diff --git a/src/main.rs b/src/main.rs index de142d9..0dde963 100644 --- a/src/main.rs +++ b/src/main.rs @@ -55,7 +55,7 @@ fn main() { .init_resource::() .init_resource::() .add_systems(Startup, (setup, setup_ui)) - .add_systems(Update, (render_ui, movement, camera_follow, player_regen)) + .add_systems(Update, (render_ui, movement, camera_follow, player_regen, attack)) .run(); } diff --git a/src/player.rs b/src/player.rs index 59f991e..ea1fa98 100644 --- a/src/player.rs +++ b/src/player.rs @@ -12,6 +12,13 @@ pub struct Player { pub stamina_max: f32, } +// Define the attacking component +#[derive(Component)] +pub struct Attack { + pub velocity: f32, + pub damage: f32, +} + // Define the player movement system pub fn movement( time: Res