From be6cad911c2432c3d7b9d7efad8248f0f44f65df Mon Sep 17 00:00:00 2001 From: qwsdcvghyu89 <61093706+qwsdcvghyu89@users.noreply.github.com> Date: Tue, 9 Jun 2026 22:38:07 +1000 Subject: [PATCH] Added new animations --- objects/animation/frames/player.tres | 46 +++++++++++++++++++++- sprites/atlas/demoman_idles.png | Bin 0 -> 2025 bytes sprites/atlas/demoman_idles.png.import | 40 +++++++++++++++++++ sprites/man_falls.png | Bin 0 -> 1241 bytes sprites/man_falls.png.import | 40 +++++++++++++++++++ sprites/man_jumps.png | Bin 0 -> 1297 bytes sprites/man_jumps.png.import | 40 +++++++++++++++++++ src/components/PlayerPhysicsController.cs | 26 +++++++++--- 8 files changed, 184 insertions(+), 8 deletions(-) create mode 100644 sprites/atlas/demoman_idles.png create mode 100644 sprites/atlas/demoman_idles.png.import create mode 100644 sprites/man_falls.png create mode 100644 sprites/man_falls.png.import create mode 100644 sprites/man_jumps.png create mode 100644 sprites/man_jumps.png.import diff --git a/objects/animation/frames/player.tres b/objects/animation/frames/player.tres index e4707ad..d8ec67f 100644 --- a/objects/animation/frames/player.tres +++ b/objects/animation/frames/player.tres @@ -1,6 +1,25 @@ [gd_resource type="SpriteFrames" format=3 uid="uid://doxc4pl5hvs6k"] [ext_resource type="Texture2D" uid="uid://bv4gsgya7wp4d" path="res://sprites/atlas/demoman_walking.png" id="1_1t22f"] +[ext_resource type="Texture2D" uid="uid://dy7fh0eg6qulr" path="res://sprites/atlas/demoman_idles.png" id="1_c2ath"] +[ext_resource type="Texture2D" uid="uid://cl3uy4d6lgspe" path="res://sprites/man_falls.png" id="1_kdeld"] +[ext_resource type="Texture2D" uid="uid://cr5bdv3hgmd4q" path="res://sprites/man_jumps.png" id="3_a1t44"] + +[sub_resource type="AtlasTexture" id="AtlasTexture_w1sc6"] +atlas = ExtResource("1_c2ath") +region = Rect2(0, 0, 32, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_mcxxx"] +atlas = ExtResource("1_c2ath") +region = Rect2(0, 64, 32, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_nf227"] +atlas = ExtResource("1_c2ath") +region = Rect2(32, 0, 32, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_sbabb"] +atlas = ExtResource("1_c2ath") +region = Rect2(32, 64, 32, 64) [sub_resource type="AtlasTexture" id="AtlasTexture_c2ath"] atlas = ExtResource("1_1t22f") @@ -24,12 +43,35 @@ region = Rect2(64, 0, 32, 64) [resource] animations = [{ -"frames": [], +"frames": [{ +"duration": 1.0, +"texture": ExtResource("1_kdeld") +}], +"loop": true, +"name": &"fall", +"speed": 5.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_w1sc6") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_mcxxx") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_nf227") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_sbabb") +}], "loop": true, "name": &"idle", "speed": 5.0 }, { -"frames": [], +"frames": [{ +"duration": 1.0, +"texture": ExtResource("3_a1t44") +}], "loop": true, "name": &"jump", "speed": 5.0 diff --git a/sprites/atlas/demoman_idles.png b/sprites/atlas/demoman_idles.png new file mode 100644 index 0000000000000000000000000000000000000000..8645209f8922ed401bec5d912f43347ba8606564 GIT binary patch literal 2025 zcmV9(E6oB8fRijZC7z|B}gqXN7y3s&U@Fy-v6BaCtTiLjBXCkryodq!svUQpKDLSV=ppqxqYm#K$xVYqDvFM4^g)6F3jpn9MzTfWy71Q|eR z1u6hU0wx3S$GCVwFb{B5fVlsx0w5(o6<*~54i%wPA+S9C#(MetZ|P%gf3mVwEAcX=p0G;Ury*$fDbZamG_`H06H@VZsvJDCSNyMUH1$QL9E|vose zM`L%(urczXN`&%&A6lnh>F52AbflpTLJFV&v>LBvdG?-}`?FG~%xY#;9mFN9~G328FFbkYw7I+S$ zfC?c5fOf0#ISYZ8T;#Kl_I_u&kNbr{tI^5xYztNa83LpLE(F}=v(48ofA!{gc29P7 z^RA;;Re2~6U=~Fl1tNcH{t>63L3-uL~JP^R8&T@Y7*YgAGOdHeHWk>;&V%&3P z-`csIU4L9{f++H@d|BUgy?^b|Y;f`Db8RNckXulSe1> zm4E-1;Azz7y2%l*rY=W z`Bo1|p+M0Fr~qIsfGL0CS+1UAOMtQDqdg#&0!1630)VvuR8M`oH=Q1?p+vb4?EyXq zB5^MzjCAEx)`4;!u*pvffZ|0l0O;g{oglS!E!+AEK-nx7THne8LK7|9^C}N0o5e!w zTX{feqGfwtP_q4ZI)n<4Or2 zWDY7FfY3Rp0ze6x)YIcS-IBgRqUh=I!T}UHJ#O;MWFAoT^myR_ik=?V0f>=2VGqMGiv$PB7N^x~&SO$U)#QMTLTt;bqE~lO_PEa!@n?uH$k7NU9v91yJ<#IERob z2ay1nrpLL$>etoS;bl_@n8HZ+)BNDC(9n5+ZF)Qg0N)ol$Y9BDkO(oj=<5N#0I)d- z6#~%oxXuIk|6E4qA>zV_i|Uc8Ds3 z4Z-LD_{MDG>$aXB(}ZEX&-NynBml%lu)h+cBtR1YY#xZ31i2EF=?z^N6!HpvTA;s8XP-^W$~2ml5G`Xws2j<3g?-**9EI{ZK*y&eGE=l4TQ zkE^Y??ewQ^5^Be>A>cf}?=n3O9mXifU+Db>;8~znt99GWQ0ip9#fwgON_tA*6L@_>*u z%lNFJ_kjNai%AX$=b3Lu0000GWMx7}H8(LZMKDG+MnyO^LpVi6GZ6e>00000NkvXX Hu0mjff@_Ri literal 0 HcmV?d00001 diff --git a/sprites/atlas/demoman_idles.png.import b/sprites/atlas/demoman_idles.png.import new file mode 100644 index 0000000..b36fb49 --- /dev/null +++ b/sprites/atlas/demoman_idles.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dy7fh0eg6qulr" +path="res://.godot/imported/demoman_idles.png-a329588d12d5e8eda94ae9b9fc61068e.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://sprites/atlas/demoman_idles.png" +dest_files=["res://.godot/imported/demoman_idles.png-a329588d12d5e8eda94ae9b9fc61068e.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/sprites/man_falls.png b/sprites/man_falls.png new file mode 100644 index 0000000000000000000000000000000000000000..856fa4ba36ff21a5e2ef39c823c19fb8137c3989 GIT binary patch literal 1241 zcmV;~1Sb25P)|Dc;wrc}6dXhs zzXtz-u7azAASi-}v!h>&NIcgH6=`p{IS=o>@8RSP_@}al& zNGJ$B`~gb&4@MFwCBgU~Y%QgLhCn111PfyWv@}K&OJgC`YslrfW#?|*+1+>dc9FSe zZgywq9KoL*`6ahs*5l{pa0YyL&czg&9#x42gX8-N;DbCAq*u67o z;?B-)zyAKK+p3S%i8MjD!VwMokXY|uCIX=ULP8@pR19^{-2$OEYg&Wmv-R@icxk1o zKAoMMemtPN;d=25NIfHp1t4|d;7oBX&{yFs06%{m9=+N&Jv{wvWBuKJyEmyF976uR zy}bPJ9-1sCpU%&3Znf>W_-)Iul_xmH6?AyCyYph%00MhSUS0qBJu@d+nf=8D^M3yg zd42tMasK)2{*L{=xUjskx@NE4X%c`F2+%${dW9wg9dh((_uX;*N%ajlgK-19ml)R) zOyKh0Sbwwk<-)XdGXyEssUeppJ;&LVvQF!2W-@P0ARre!cY?X{m9{PG_~Vp z!OnmhDFn&~M4dsp_{|JJsj(#Oy->e4BSXFL=ZXiwPTepe){tz?06XCSuO$N@4Rz)3 zy6=@G1Hd;CU;9{JiR1v3&V*z`5I1VyRD258am;W;Tu5nHCT9Q=krK7-e6?_3lLH{# zfN!a;_O5Z+KS9?(vF*5-;rnBS){}rp&VX)!_@3no<$$sM`?o?S0PM7VG&dmJJr)Z9 z#{{V~P##jUPyQLC37|Lab(y-{&2vC;_IBK=DwY8>QCcX~slBV-I|GndC=+m=ldd<9 z^Vt~C-J|^10SU*J*#L-Li0{oKes%!5nSk_U8Cp0zXPW^?05Z-{GcDu_Y<2+R6b=}x z%9jz@TEMSx+$^Lic-*&a0JtXZN@e)-1Gc~)Ay60+h1pVOf-4Z&8Gu3|?Lv)K?;E{- zlYyWosGbb~sbHEY^ll)qt5OkA1QY>9KoL*`JP`N?{YI6u85%I100000NkvXXu0mjf D-IqOa literal 0 HcmV?d00001 diff --git a/sprites/man_falls.png.import b/sprites/man_falls.png.import new file mode 100644 index 0000000..1e51786 --- /dev/null +++ b/sprites/man_falls.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cl3uy4d6lgspe" +path="res://.godot/imported/man_falls.png-61beb99173ba0b99454c416e7ba44020.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://sprites/man_falls.png" +dest_files=["res://.godot/imported/man_falls.png-61beb99173ba0b99454c416e7ba44020.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/sprites/man_jumps.png b/sprites/man_jumps.png new file mode 100644 index 0000000000000000000000000000000000000000..42c6eb70f9fee641da2fec379b87fe464e1ae216 GIT binary patch literal 1297 zcmV+s1@8KZP)|Dc;wrc}6dXhs zzXtz-u7azAASi-}v!h>&NIcgH6=`p{IS=o>@8RSP_@}aliULJ}qCiogDDYn@P~L z+M`%z=Pb_oz8rBx#yTwKyR$tD;73H)X>z_P7ohu2m~sL53eM;qz!TE0co9dwndty; z;t)Xn>|ldrA0I9UpAY!6`{(cN?ZvqiC9W?ntgY?s$1y%Fuk7xeo#>xU?4#CA0EswF zeDm|_$Mc4K{O`{SoL)_%$rVqTkw^Sc~;J>1;lR-5ybI6S!dRACTTvTk=kAW+vF z5eW#l?j4Wj$?gCI43!!V0T>qRxz;-#@ML!Yh$CQo%hvVo&e8GpRsN-gJYF_i00~GS zE_uo8oPgmDYQ8$!OF3BpB<5O^b^`oms^dKn7k0dNRY^ja1<(@7eV#y!t31}J)#AfG zwE!V7wlys}ffBa@qLHP%@K4Pnz5-kefiM6B+ubF{;TX-|9MOVM4|NC7joca3R*c4z z#u5>_U+d2bU?bA3d}>QlB6vlBCv;xSM+;%SGuR`5#ILPq|Bl{#mMAgn7LakzDBCAm1#JS#xBbfoQ7h04InJMuhm6!N0P-Ruzv6^3IxbC`KA z*6sHI2;z15A)eJ*k50A#qb=!w`B?>^{*oZ<9Y6!U*Ku|SK$vb@Ki)y~vgPthl?QJ2 z5`=@71)$L*6JHUpJk~h99|2lHD`5C@mB+f)_AUT`r3&Fi95^N>004Mf95rp+nGwLd z@(?InfBwayQ(yo ze_|cb4k-TD*S_vQs}{go`MxWeDvfvqti%HlZ6))6)=njkee4e+TH>=(X%MEi(E&Q* z+6vQj(>GS%0n-QF2a)jz#L9=(_W@C&6a|U`MS-HggcSG(Mtiw!^Ih;400000NkvXX Hu0mjfw5eMV literal 0 HcmV?d00001 diff --git a/sprites/man_jumps.png.import b/sprites/man_jumps.png.import new file mode 100644 index 0000000..a1c4983 --- /dev/null +++ b/sprites/man_jumps.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cr5bdv3hgmd4q" +path="res://.godot/imported/man_jumps.png-70ad3c36f80f10d1a96a8706ccbc76b6.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://sprites/man_jumps.png" +dest_files=["res://.godot/imported/man_jumps.png-70ad3c36f80f10d1a96a8706ccbc76b6.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/src/components/PlayerPhysicsController.cs b/src/components/PlayerPhysicsController.cs index dedfc88..c3da1b1 100644 --- a/src/components/PlayerPhysicsController.cs +++ b/src/components/PlayerPhysicsController.cs @@ -71,16 +71,30 @@ public partial class PlayerPhysicsController : CharacterBody2D { public override void _Process(double delta) { var grounded = this.IsOnFloor(); var absvel = new Vector2(Mathf.Abs(Velocity.X), Mathf.Abs(Velocity.Y)); - Sprite.FlipH = Velocity.X < 0; - if (grounded && absvel.X > 0) { - Sprite.Play("walk", absvel.X switch { + var xAxis = Input.GetAxis("move_left", "move_right"); + Sprite.FlipH = xAxis < 0; + if (grounded && absvel.X > 0.1) { + Sprite.Animation = "walk"; + Sprite.SpeedScale = absvel.X switch { < 10 => 1, < 150 => 2, < 300 => 4, _ => 1 - }); - } else if (grounded && absvel.X < epsilon && absvel.Y < epsilon) { - Sprite.Play("idle"); + }; + } else { + Sprite.SpeedScale = 1; + } + + if (grounded && absvel.X < 0.1) { + Sprite.Animation = "idle"; + } + + if (!grounded && Velocity.Y > 0.1) { + Sprite.Animation = "fall"; + } + + if (!grounded && Velocity.Y < 0.1) { + Sprite.Animation = "jump"; } }