From 016da80a59395344d54c218c31d8242475e6f4a8 Mon Sep 17 00:00:00 2001 From: Just Dzhi Date: Sun, 1 Oct 2023 17:56:36 +0400 Subject: [PATCH 1/2] Player anim --- .../enemies/trash_can/sprites/trash_can.png | Bin 1980 -> 0 bytes .../trash_can/sprites/trash_can.png.import | 35 ------------------ src/models/player/Player.tscn | 9 +++-- src/models/player/sprite.png | Bin 2131 -> 0 bytes .../player/sprites/player_spriteframes.tres | 35 ++++++++++++++++++ src/models/player/sprites/run.png | Bin 0 -> 1136 bytes .../run.png.import} | 6 +-- 7 files changed, 44 insertions(+), 41 deletions(-) delete mode 100644 src/models/enemies/trash_can/sprites/trash_can.png delete mode 100644 src/models/enemies/trash_can/sprites/trash_can.png.import delete mode 100644 src/models/player/sprite.png create mode 100644 src/models/player/sprites/player_spriteframes.tres create mode 100644 src/models/player/sprites/run.png rename src/models/player/{sprite.png.import => sprites/run.png.import} (71%) diff --git a/src/models/enemies/trash_can/sprites/trash_can.png b/src/models/enemies/trash_can/sprites/trash_can.png deleted file mode 100644 index 722a16440a2ee52dc7087626bbfe5d21db1753f8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1980 zcmcIlYitx%7#%D&Efv!GL``%YFhOK?o;$NMGC=7rb`9IsKBP5Pd*{xb?bzL!VP@Lh z^3tFr5{!vNNGc8WhY@I~hW_A(q9q}w27@snS`7w`Q4wM&i5e3U67TE_G*J7;O=jnH z?)lC=-v0%^BwqDQd5opAN=^*Z}?Q}Huv}hQFm8(EFj(< zT}lwuJyvIT(4E?-LMIymhNGiMKI>vML9AYzcL5wg0jZ<3Woy*zM^hAO85*@InqpIK z6Y95`w|J;yOG_u*G5{5WTDyi^omVkI76pLJXEV01<~6FotK#eMF+-6BNHCyLjbTBu zJJm)uIUXYA2v0+nWl33yaJm!)va*WgS)ONDiQxpAlT}etIgu>=C|u4nOtn3}p;Qdt zX;gm@xGKZsa=A!Oh&W!F;S@z-Sf1f|8Y5_b*bYFRw*6&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D3?7P?_)m!ILNd@%;7mI2o-i}F0EXYg zofKXmSwWKugp6QS=qNDD$#U~_CxO?`orIu05s_xnd3(@pV9;%#*J`8JY6E~>D3yhR zf;idVgKmTU8H(HC90_<-=;CF#UBpobmOG4Zfq|G5X5J02ccULM~3oQ7!`B$Ljgb8{x*O+?TrjX!83CeFWj7fP^c8KOV{`iuhr zWOGIQu)o>!$JglhZvgkfNfdE6}ATUn$4aT$#*SKb_f~ij{fTNX%dUcN)sEi=Jikz$ofpw@?FQvGh z7D_2-*<2BwBX5AYgGx-8ai(Pe0PeTm+5ph`@CvEaEC676ec!WPukOLLjFG-mgsH_~ zy?4Ja(eK~J&I>?AZ{(njymr#!0*-NuD}f5?)jc$86&bNGEd!=yxXmv$&S}a$+kP#o zSYF?EdDv|gsOo)eUKS$Xs1854Eku|nE-cuaj#2;zz57pg%M1!B^S3*-z7U3!xk;J`pknsFH3 z=*R~dib1!5sI#;HUvH9lqxdG>W$;LW(1p-toXgp)RXm&#A=H~NUJq1!6LuNUBRF>B z*w^1)tIg$%a2;JiOI(1*&UQKlo+#s(d4DdPNhPJFM!NJSHNa9`h7RN62K#jt7=F2< zGn9jF!v^>(pJX7?OM@o*e6Pw23_qW%yw*nzTHq2oN`7*<&CaviGjj{>|H7;pSX$ln zKdo#NN4E*@3thmR!^qS#ubHI9m0gnN4-qeD>@k(4ZoWFW6HajMoehI5Z=qE7j1PSJ zi9cLQYbtdGf)UDlqTKzmfd~V|K*S!jAb$LkZoyvvW#e=5+q!AHyFR#oPE!-r9Nq0000 Date: Sun, 1 Oct 2023 18:10:09 +0400 Subject: [PATCH 2/2] Player idle animand flip --- src/models/player/Player.tscn | 3 +-- src/models/player/player.gd | 14 +++++++++----- src/models/player/sprites/player_spriteframes.tres | 11 ++++++++++- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/models/player/Player.tscn b/src/models/player/Player.tscn index d68ab9c..c39d192 100644 --- a/src/models/player/Player.tscn +++ b/src/models/player/Player.tscn @@ -72,8 +72,7 @@ script = ExtResource( 2 ) [node name="Sprite" type="AnimatedSprite" parent="."] material = ExtResource( 3 ) frames = ExtResource( 1 ) -animation = "run" -frame = 2 +animation = "idle" playing = true centered = false diff --git a/src/models/player/player.gd b/src/models/player/player.gd index 788a7d2..faf4ab6 100644 --- a/src/models/player/player.gd +++ b/src/models/player/player.gd @@ -37,11 +37,6 @@ func draw_dashed_line(from, to, color, width, dash_length = 3, cap_end = false, if cap_end: draw_line(segment_start, to, color, width, antialiased) -func _process(_delta): - if Input.is_action_just_pressed("shoot"): - _shoot() - update() - func get_input(): var input_direction = Input.get_vector("left", "right", "up", "down") velocity = input_direction * speed @@ -76,6 +71,15 @@ func _draw(): var dist2enemy = position.distance_to(target.global_position) draw_dashed_line(Vector2(12, 8), target.global_position - self.global_position + Vector2(8, 7), Color("ffde00"), 1) +func _process(_delta): + $Sprite.play("idle") if velocity == Vector2.ZERO else $Sprite.play("run") + if abs(velocity.x) > 10: + $Sprite.flip_h = true if velocity.x < 0 else false + + if Input.is_action_just_pressed("shoot"): + _shoot() + update() + func _physics_process(delta): get_input() diff --git a/src/models/player/sprites/player_spriteframes.tres b/src/models/player/sprites/player_spriteframes.tres index 7214716..05d506d 100644 --- a/src/models/player/sprites/player_spriteframes.tres +++ b/src/models/player/sprites/player_spriteframes.tres @@ -1,7 +1,11 @@ -[gd_resource type="SpriteFrames" load_steps=8 format=2] +[gd_resource type="SpriteFrames" load_steps=9 format=2] [ext_resource path="res://src/models/player/sprites/run.png" type="Texture" id=1] +[sub_resource type="AtlasTexture" id=7] +atlas = ExtResource( 1 ) +region = Rect2( 0, 0, 22, 25 ) + [sub_resource type="AtlasTexture" id=1] atlas = ExtResource( 1 ) region = Rect2( 0, 0, 22, 25 ) @@ -28,6 +32,11 @@ region = Rect2( 110, 0, 22, 25 ) [resource] animations = [ { +"frames": [ SubResource( 7 ) ], +"loop": true, +"name": "idle", +"speed": 0.0 +}, { "frames": [ SubResource( 1 ), SubResource( 2 ), SubResource( 3 ), SubResource( 4 ), SubResource( 5 ), SubResource( 6 ) ], "loop": true, "name": "run",