From c3a678513ff273d288906cc025c6087128da72d5 Mon Sep 17 00:00:00 2001 From: bog Date: Sun, 1 Oct 2023 16:11:38 +0200 Subject: [PATCH] ADD: actors animated sprite. --- assets/player.ase | Bin 0 -> 1532 bytes assets/player.png | Bin 0 -> 868 bytes src/Actor/Falling.gd | 4 ++-- src/Actor/Jump.gd | 10 +++++---- src/Actor/actor.tscn | 11 +++++---- src/Actor/player.png | Bin 0 -> 868 bytes src/Actor/player.tres | 51 ++++++++++++++++++++++++++++++++++++++++++ src/Player/player.gd | 8 +++++++ 8 files changed, 74 insertions(+), 10 deletions(-) create mode 100644 assets/player.ase create mode 100644 assets/player.png create mode 100644 src/Actor/player.png create mode 100644 src/Actor/player.tres diff --git a/assets/player.ase b/assets/player.ase new file mode 100644 index 0000000000000000000000000000000000000000..b3b56f7794295707ca6082723d37f211666bf4c7 GIT binary patch literal 1532 zcmd^;e^8Tk9LFCJ!EBVv>qJH}erCqciR=ap$^}!lvs}rKV@SB1w+);Km}4AQ1ny$T zAqUA|z)T9X(GWXi@>3ZIW6X=66QO~?AP|P*M-(pBXLd??{o7xDpL<^SJb%4k@6Ypj zj9U?8{Cg_|`}DFv5actsHxG96@qc-Ww?vS2gVpoY2avKG`z+P*#Y_`|IAi^Qp?iaX zOoA_PEXf@>e3=Q`$_S0FBk01OF90s4HJ z35+@Y5XcalfN|<6plZYjG{Hd-@sIVutPBB=#byJeBWS>L2XlbcI2>>|k^$848-RI5 z;lLcOkBJRktPq&6xg3;$2A~h_AP&}`489->rl1LqAP9D#23{ZqMxbMMF`2*u6d)hM zAsJ#J69OR(q8!ah*e$?k2NVz+gc{E~c^2!dhnKBb1XQ*mCK&(UXAgo#&X=kS-{0Qm zvm=ymi>AxbqlZ#w503II4c2?A@ZE#^S|2~exGP<)S>yc|dyGYg3s7H4)!(q$i%(d= zdVk^10?lOlnOADVTEqlmjWCL2yX!=YKy7z5n^ik&v*=Lp$hH2`wS?6h_l>*kHDVR< zZOoWvVF~XQ&CzY7$!PTX1M8pUm3UU-R_I9{vKY>5PNGM*?WSpUcQ=M&yB9u}oy%30 zO^%LyyVl(Pp~0`U{R7O}NKJr<+sx<|P7Z7-cawGeHdQ}WolTKM5tD->`CM-_Onlv7 z@qEE7;N9Hb@?Y&8ke$%J8QNR=qC#ivo#kg-h-QV zQEAl>S@_N=@>u7pQQ=CN!*o;}Uzpie-sE_P#C5OZHEEZfd3_Y2=7-)TnuKy~xL-uW z{Sl=Iq=-8!?sjPoNk=P)IUC+Xgh8rOx4$*IvQ#IJZ47GauYLo=x%yKI*~5x|_K4u* zz2P=e*Pjony!%(fPJKNX$e|d;WTp^LnXpBt#w2XO_x|TVUaoaOy|4~On8tto4CZyv zZT<`munzfiecAG5s}A!z6iSa}7!)Z1yZ6_6wSW1#Q(1A5u+t;@pjgjZ@!mrgrJj5|@|S=m{4zb`plNw=APtX{U)h2NZsosOdN1b#bv z6Nd^i(#b3QCB28Igiu59&*tSv^z%%Gzd$wzOILsV{!D+%S} Is4q}|0YI>AuK)l5 literal 0 HcmV?d00001 diff --git a/assets/player.png b/assets/player.png new file mode 100644 index 0000000000000000000000000000000000000000..37cbfe7118e369aa86a9a45bd3877a6267b81c97 GIT binary patch literal 868 zcmV-q1DpJbP)Hz>y%4e{(cZSvFIW6VglS@>~1@!GVI*^6gDc^?v!PNs=ovyYI zuHs*qo$_0qu9uenxa>y~Ut7rm0BSpjTEZe*duOOuiU5E{vyE!G;15#-^-3|QcpLhq zdA+cNzauZpQ!g@kR6Vhxei9^OF;(?Hoq*<3@g?*@oC$HP2>zCLyGX3vAenRxyM4R+o#xL_hVJCQ-AC!Dm@hKhBbl}x{ zWY8BYSqB0^@+06_Yetq;JLO`w~nXLNr3krsjU&mh;-b`HJO;y1z{9o)g u6>lN_k#_cf8Ru!jXT~rL!!QiP4CF7m&Bpw;F}s@p0000= 0.38: + if m_ratio >= m_ratio_end: m_jump_state = self.go_down func go_down(delta): @@ -31,7 +33,7 @@ func go_down(delta): sprite.scale.x = m_ratio sprite.scale.y = m_ratio - if m_ratio <= 0.25: + if m_ratio <= m_ratio_start: this.to_normal() queue_free() diff --git a/src/Actor/actor.tscn b/src/Actor/actor.tscn index e2814e4..94b531d 100644 --- a/src/Actor/actor.tscn +++ b/src/Actor/actor.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=4 format=3 uid="uid://c0kqx6dsury58"] [ext_resource type="Script" path="res://Actor/actor.gd" id="1_0612w"] -[ext_resource type="Texture2D" uid="uid://blr8qcmuqs5vl" path="res://icon.svg" id="2_itibm"] +[ext_resource type="SpriteFrames" uid="uid://o3tacari6pde" path="res://Actor/player.tres" id="2_1hnut"] [sub_resource type="CircleShape2D" id="CircleShape2D_e2sef"] radius = 3.16228 @@ -9,9 +9,12 @@ radius = 3.16228 [node name="Actor" type="CharacterBody2D" groups=["actors"]] script = ExtResource("1_0612w") -[node name="Sprite2D" type="Sprite2D" parent="."] -scale = Vector2(0.25, 0.25) -texture = ExtResource("2_itibm") +[node name="Sprite2D" type="AnimatedSprite2D" parent="."] +scale = Vector2(1.5, 1.5) +sprite_frames = ExtResource("2_1hnut") +animation = &"Walk" +frame = 3 +frame_progress = 0.69616 [node name="CollisionShape2D" type="CollisionShape2D" parent="."] shape = SubResource("CircleShape2D_e2sef") diff --git a/src/Actor/player.png b/src/Actor/player.png new file mode 100644 index 0000000000000000000000000000000000000000..37cbfe7118e369aa86a9a45bd3877a6267b81c97 GIT binary patch literal 868 zcmV-q1DpJbP)Hz>y%4e{(cZSvFIW6VglS@>~1@!GVI*^6gDc^?v!PNs=ovyYI zuHs*qo$_0qu9uenxa>y~Ut7rm0BSpjTEZe*duOOuiU5E{vyE!G;15#-^-3|QcpLhq zdA+cNzauZpQ!g@kR6Vhxei9^OF;(?Hoq*<3@g?*@oC$HP2>zCLyGX3vAenRxyM4R+o#xL_hVJCQ-AC!Dm@hKhBbl}x{ zWY8BYSqB0^@+06_Yetq;JLO`w~nXLNr3krsjU&mh;-b`HJO;y1z{9o)g u6>lN_k#_cf8Ru!jXT~rL!!QiP4CF7m&Bpw;F}s@p0000 0: delta = delta.normalized() $Actor.m_dir = delta + $Actor/Sprite2D.play("Walk") + else: + $Actor/Sprite2D.play("Idle") if $Actor.is_normal() or $Actor.is_jump(): $Actor.velocity = delta * $Actor.m_speed