From d42aea475cb3ca6e2968b767bb6f9b8eb3d2d21c Mon Sep 17 00:00:00 2001 From: Muhammad Nauman Raza Date: Wed, 6 Dec 2023 22:45:32 +0000 Subject: [PATCH] feat: begin on stamina Former-commit-id: d4d8c9a8e6ed2fb5483465a70a10c612be2823dc --- assets/player/player-2x.png | Bin 715 -> 756 bytes assets/player/player-4x.png | Bin 1239 -> 1419 bytes assets/player/player.png | Bin 375 -> 403 bytes src/main.rs | 38 ++++++++++++++++---------------- src/player.rs | 42 ++++++++++++++++++++++++++---------- src/ui.rs | 27 +++++++++++++++-------- 6 files changed, 69 insertions(+), 38 deletions(-) diff --git a/assets/player/player-2x.png b/assets/player/player-2x.png index edfc2b33e14bcfb26ef02ac347f54357a14b6f59..c62aa7c27851e4023cb4d8406e8bafdcb0dd7531 100644 GIT binary patch literal 756 zcmeAS@N?(olHy`uVBq!ia0vp^0U*r51|<6gKdl8)oCO|{#S9Fx?I6t9|MX)jP*AeO zHKHUqKdq!Zu_%?Hyu4g5GcUV1Ik6yBFTW^#_B$IX1_q`^PZ!6KiaBqu@68SllsWeC z`J5$UQyVTEbQ7?$aJlFxAny2Lfj9RomRHOEH!HO+;xwQ9!(5}oS^LVfOF3mlg)5s@ z?>5uFNjjCm)WY>;OEcxcX1YX+B|(@tNllY2V06O1Rs{#U5Ic_)qAkh@1J2qHuJuyvbp;GX}128d}0p;s;{$n zpvqvJBb{Hcd}BnN-QkUHr+f~q*c@E6;Wq;p=j^)g_hK{WtlBsKXpE;(A?JGeZCre2 zZbdc>7Fj*Hc``@1FVD-CImqnR@#ateKedKSEW34|>Y82OFn9K~n8#dl7q;qO={fjn z$#2OAziyVjduWn2E2D41_X8`$*ITv6{`uYbrD46>QLj1AVkUEl8T`6p^|$-tdI%bKkD+|?>PN6`NKzs1rHJ)e?5H7qTXR8x6p?f|G$YG_$e}7 z=j{JC_QuNd&DV|;!0nQcYA_S;h4fR&}Q%P+^7e=MK;t}#>YD*N7wn^t?64Az$4 zvP%e;Ix1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_xIqzx8!?lxHi&lR*|Xw4RavO znJ@V+z52&F;ZW!|{e~&dj1z(xo`^75vO4&UGN~F4|5#VmOa023tQiU{lo&i+{an^L HB{Ts5W(4?d diff --git a/assets/player/player.png b/assets/player/player.png index d0d9131aba61ea14cf6c7658046fde5820e5435b..47b4aa376c8b3640ad989189c3129dd095288e7d 100644 GIT binary patch delta 353 zcmey)G?`hkGr-TCmrII^fq{Y7)59eQNNa#F2OE&=`L`o?qM~iRf~SjPNJQ(~EB0PT z97K+PywAP6^@h$5_RSToYguOJe&L9ewzl5e>^hB;ql)!yj!TR0o<@!&)wqLh$JgrU zntaY-VRcQdOa8tucGAPM?L3_;w1Pr^rA04z_34quRUc2*lK!(<0ee{{tbA2OIyPhj6xRLt&vcp$@ zcBVD8pEG9sZmlh|D?Remd9P;EP!CK!8Yyk=f;+AQWI{*PqSOymU#94 zj^3N#CCk2-}mI66Hi-f_ARrY^#5E#jyYS3 uvBGS|n>;7d9L$(ENlrN1kb^3;m(g`anDI5HS@VFQ#^CAd=d#Wzp$P!E@1O(# delta 325 zcmV-L0lNN^1NQz{BwJpRx{=9>~B9X%Sw!qx|KiqU1FTxpU;l!W=LH?J{hfu=nbGM zvR=$>jsFd>_vmNa$}Q0USb9)pf3@fho>Q|l^}se~Q*Gt=)8zn*A#mcjZv8o6xojN* zn_p~gg!1(uH7{uduJl=eb3ndrigCv+WT%Y-Tsc|_=osk!+!^0gWv%E9?yBTg8o}`8 zsvA)M`{e-A2{C$ie>qbnTk^?8{g0r5N`8a}Fn|FJU;qOczyJm?fB_6(8vp|spy_%C X2=Yi>cco(Y00000NkvXXu0mjfvHgmP 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