From 43d693450eec592815124669e138790edccc6f49 Mon Sep 17 00:00:00 2001 From: Luna Brovchuk Date: Sat, 30 Sep 2023 22:48:27 +0200 Subject: [PATCH] Finish Trash Can Enemy And Fix Drops --- project.godot | 10 ++++ src/models/enemies/trash_can/TrashCan.tscn | 7 +-- .../enemies/trash_can/drop/TrashDrop.tscn | 14 ++++- src/models/enemies/trash_can/drop/drop.png | Bin 0 -> 1795 bytes .../enemies/trash_can/drop/drop.png.import | 35 +++++++++++ .../enemies/trash_can/drop/trash_drop.gd | 10 ++++ .../trash_can/sprites/path/horizontal.png | Bin 0 -> 575 bytes .../sprites/path/horizontal.png.import | 35 +++++++++++ .../trash_can/sprites/path/vertical.png | Bin 0 -> 5157 bytes .../sprites/path/vertical.png.import | 35 +++++++++++ .../enemies/trash_can/sprites/trash_can.png | Bin 0 -> 1980 bytes .../trash_can/sprites/trash_can.png.import | 35 +++++++++++ src/models/enemies/trash_can/trash_can.gd | 56 ++++++++++++++++-- src/models/player/Player.tscn | 2 +- src/scenes/game/Game.tscn | 44 +++++++------- 15 files changed, 247 insertions(+), 36 deletions(-) create mode 100644 src/models/enemies/trash_can/drop/drop.png create mode 100644 src/models/enemies/trash_can/drop/drop.png.import create mode 100644 src/models/enemies/trash_can/drop/trash_drop.gd create mode 100644 src/models/enemies/trash_can/sprites/path/horizontal.png create mode 100644 src/models/enemies/trash_can/sprites/path/horizontal.png.import create mode 100644 src/models/enemies/trash_can/sprites/path/vertical.png create mode 100644 src/models/enemies/trash_can/sprites/path/vertical.png.import create mode 100644 src/models/enemies/trash_can/sprites/trash_can.png create mode 100644 src/models/enemies/trash_can/sprites/trash_can.png.import diff --git a/project.godot b/project.godot index e759724..3a99c34 100644 --- a/project.godot +++ b/project.godot @@ -8,6 +8,16 @@ config_version=4 +_global_script_classes=[ { +"base": "EditorVCSInterface", +"class": "GitAPI", +"language": "NativeScript", +"path": "res://addons/godot-git-plugin/git_api.gdns" +} ] +_global_script_class_icons={ +"GitAPI": "" +} + [application] config/name="LD54" diff --git a/src/models/enemies/trash_can/TrashCan.tscn b/src/models/enemies/trash_can/TrashCan.tscn index 5003d5d..1cd5245 100644 --- a/src/models/enemies/trash_can/TrashCan.tscn +++ b/src/models/enemies/trash_can/TrashCan.tscn @@ -1,21 +1,20 @@ [gd_scene load_steps=4 format=2] -[ext_resource path="res://icon.png" type="Texture" id=1] +[ext_resource path="res://src/models/enemies/trash_can/sprites/trash_can.png" type="Texture" id=1] [ext_resource path="res://src/models/enemies/trash_can/trash_can.gd" type="Script" id=2] [sub_resource type="RectangleShape2D" id=1] -extents = Vector2( 8, 8.5 ) +extents = Vector2( 6, 7 ) [node name="TrashCan" type="KinematicBody2D"] script = ExtResource( 2 ) [node name="Sprite" type="Sprite" parent="."] -scale = Vector2( 0.25, 0.25 ) texture = ExtResource( 1 ) centered = false [node name="EnemyCollider" type="Area2D" parent="."] [node name="CollisionShape2D" type="CollisionShape2D" parent="EnemyCollider"] -position = Vector2( 8, 8.5 ) +position = Vector2( 6, 7 ) shape = SubResource( 1 ) diff --git a/src/models/enemies/trash_can/drop/TrashDrop.tscn b/src/models/enemies/trash_can/drop/TrashDrop.tscn index 05b9885..3a5b905 100644 --- a/src/models/enemies/trash_can/drop/TrashDrop.tscn +++ b/src/models/enemies/trash_can/drop/TrashDrop.tscn @@ -1,12 +1,20 @@ -[gd_scene load_steps=2 format=2] +[gd_scene load_steps=4 format=2] + +[ext_resource path="res://src/models/enemies/trash_can/drop/drop.png" type="Texture" id=1] +[ext_resource path="res://src/models/enemies/trash_can/drop/trash_drop.gd" type="Script" id=2] [sub_resource type="RectangleShape2D" id=1] -extents = Vector2( 6, 6 ) +extents = Vector2( 4, 4 ) [node name="TrashDrop" type="StaticBody2D"] +script = ExtResource( 2 ) + +[node name="Sprite" type="Sprite" parent="."] +texture = ExtResource( 1 ) +centered = false [node name="Area2D" type="Area2D" parent="."] [node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"] -position = Vector2( 6, 6 ) +position = Vector2( 4, 4 ) shape = SubResource( 1 ) diff --git a/src/models/enemies/trash_can/drop/drop.png b/src/models/enemies/trash_can/drop/drop.png new file mode 100644 index 0000000000000000000000000000000000000000..41be4029efbc8c651f758a03e83a8266f5fa8fc6 GIT binary patch literal 1795 zcmcIlO^D<~7|kFqyQ9OdC^+~>%($RvB~_JV(h1YM&Q6az4Q3o>8g>ReSgERXhv}rU zNqV|x5XA)#;$iWy9>jxq5K(Y%3JU&!9z_rY6})&-@bBiqiwmZvXMtSY^c||$4 z6Lq$WZU0G+idZL11Y94*sYENv(%Df;=q@kRfOn&$sr~-ZCz=|urgp*hp`WhsUbJ?Q z@vVdP4n5eVF4NAQQI|%ZB#3!I)KT0|a&Oes#=M@qE*~43I))UxO>Ma>sBZfk>Wav? z>gX6y2%+k@ItmtT;<%5g7-DR|MFW`tIi9uXAxo`(nk<*G(A#W1Q5BPSO|4fHsb?6& z;ZPr%y2!c)a$VPe*uWS_1jzT3f{Z|tFVqYzp3^K!i%2AD$w&e*D4Lp-I+;V9PHB_8 z@<}>oj7VxA9hP&dfxdq@G>)g}yjb0nRVuwVB+fhgDK|EGE(RIpt9v{t7V2VYPZT2W ziJNGfzW#?oMyCbSLDnDJ!>GagJeJ(K#G=%93>96!k|6I60c z-Sj9%lm|2bp@S^IEy)&yl9w_ogvbg4htZntsVtJ84(VUdTB>4_5id4u6fz4i#1UYY z<$}PrF<{hmp+zaT97j{H)m;&Nk@ma+Yi@Zt zUG3$~bid$`wKSY literal 0 HcmV?d00001 diff --git a/src/models/enemies/trash_can/drop/drop.png.import b/src/models/enemies/trash_can/drop/drop.png.import new file mode 100644 index 0000000..85909e8 --- /dev/null +++ b/src/models/enemies/trash_can/drop/drop.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/drop.png-43903b6c0b365d394fc3a965a28edba7.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://src/models/enemies/trash_can/drop/drop.png" +dest_files=[ "res://.import/drop.png-43903b6c0b365d394fc3a965a28edba7.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=false +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=false +svg/scale=1.0 diff --git a/src/models/enemies/trash_can/drop/trash_drop.gd b/src/models/enemies/trash_can/drop/trash_drop.gd new file mode 100644 index 0000000..933af56 --- /dev/null +++ b/src/models/enemies/trash_can/drop/trash_drop.gd @@ -0,0 +1,10 @@ +extends StaticBody2D + +var alive_timer = .0 + +func _physics_process(delta): + alive_timer += delta + if alive_timer > 2: + $Sprite.modulate.a = 3 - alive_timer + if alive_timer > 3: + self.call_deferred("free") diff --git a/src/models/enemies/trash_can/sprites/path/horizontal.png b/src/models/enemies/trash_can/sprites/path/horizontal.png new file mode 100644 index 0000000000000000000000000000000000000000..acf6534d77990c2f1d37af70081eee5e6f35f160 GIT binary patch literal 575 zcmV-F0>J%=P)EX>4Tx04R}tkv&MmKpe$iQ$;HkhgJ{~$xxl_q9Ts93Pq?;YK2xEOfLO`CJjl7 zi=*ILaPVWX>fqw6tAnc`2!4RLx;QDiNQwVT3N2zhIPS;0dyl(!fY7Kg)$ED^s%9DK zL|n|~R>huI1Tcya1`&{$sn4ZSNqCO0d-(Wz7v)*r=l&f1O5S9EPb7{p-LQx^h-Wq} zo%23%n3W`j_?&pcpbHW|a$R=$jdRgqfoFz|OnRO;Oe_{VSngm}GF0Me;)tSZlrLmm zRyc2QRx35ux+i~OFt4pFbDic05?I6%QV=1dhB7L!5T#Wk#YCF+;~xHD$DbmXOs+B* zITlcb3d!+<|H1EW&BD~An-q)#-7mKNF$VPP0?oQ@e;?a+^91le16NwxUu^)hpQP8@ zTI2{A*aj}H+nT%wTBR00009a7bBm001r{001r{0eG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uFsnJ3YBPx%ZPVkJHJ$&99vm zwYq!Ht-YtF?`3heb$f5u?c|c5E?j=%kIe8TLq2f!_{6&(jHS8v#;Kvd`l=?sd+EgD zL%okYbd)%`W9s3CQ9nPs`HN%EPAsqPKB(5dI`-$)(_bkw(+$(74)=8JBl5HNpYQ70 zJ$~o0Zzd0%`S#2&+cf*L-?tg{3x^MO?0=M-u1cMKXZ*y*dgf4q7*{W .5: - drop_timer = 0 - drop_trash() - velocity = Vector2.ZERO if movement_type == "horizontal": if movement_start == "left": velocity.x += horizontal_speed + if self.global_position.x > 360: + path_sprite.call_deferred("free") + self.call_deferred("free") + if self.global_position.x > last_x + 7: + last_x = self.global_position.x + drop_trash() else: velocity.x -= horizontal_speed + if self.global_position.x < 0: + path_sprite.call_deferred("free") + self.call_deferred("free") + if self.global_position.x < last_x - 7: + last_x = self.global_position.x + drop_trash() + else: velocity.y += vertical_speed + if self.global_position.y > 160: + path_sprite.call_deferred("free") + self.call_deferred("free") + if self.global_position.y > last_y + 7: + last_y = self.global_position.y + drop_trash() velocity = move_and_slide(velocity) diff --git a/src/models/player/Player.tscn b/src/models/player/Player.tscn index 3b617e1..14e9b52 100644 --- a/src/models/player/Player.tscn +++ b/src/models/player/Player.tscn @@ -4,7 +4,7 @@ [ext_resource path="res://src/models/player/player.gd" type="Script" id=2] [sub_resource type="RectangleShape2D" id=1] -extents = Vector2( 7, 11 ) +extents = Vector2( 4, 5.5 ) [sub_resource type="RectangleShape2D" id=2] extents = Vector2( 7, 11 ) diff --git a/src/scenes/game/Game.tscn b/src/scenes/game/Game.tscn index 496c123..d9a0c9e 100644 --- a/src/scenes/game/Game.tscn +++ b/src/scenes/game/Game.tscn @@ -44,28 +44,6 @@ centered = false region_enabled = true region_rect = Rect2( 0, 0, 320, 180 ) -[node name="Houses" type="StaticBody2D" parent="View/Background"] - -[node name="Sprite" type="Sprite" parent="View/Background/Houses"] -texture = ExtResource( 2 ) -centered = false - -[node name="CollisionShape2D" type="CollisionShape2D" parent="View/Background/Houses"] -position = Vector2( 10, 60 ) -shape = SubResource( 2 ) - -[node name="CollisionShape2D2" type="CollisionShape2D" parent="View/Background/Houses"] -position = Vector2( 310, 60 ) -shape = SubResource( 2 ) - -[node name="CollisionShape2D3" type="CollisionShape2D" parent="View/Background/Houses"] -position = Vector2( 160, 10.25 ) -shape = SubResource( 3 ) - -[node name="CollisionShape2D4" type="CollisionShape2D" parent="View/Background/Houses"] -position = Vector2( 160, 109.875 ) -shape = SubResource( 3 ) - [node name="Player" parent="View" instance=ExtResource( 5 )] position = Vector2( 46, 42 ) @@ -73,6 +51,28 @@ position = Vector2( 46, 42 ) margin_right = 40.0 margin_bottom = 40.0 +[node name="Houses" type="StaticBody2D" parent="UI"] + +[node name="Sprite" type="Sprite" parent="UI/Houses"] +texture = ExtResource( 2 ) +centered = false + +[node name="CollisionShape2D" type="CollisionShape2D" parent="UI/Houses"] +position = Vector2( 10, 60 ) +shape = SubResource( 2 ) + +[node name="CollisionShape2D2" type="CollisionShape2D" parent="UI/Houses"] +position = Vector2( 310, 60 ) +shape = SubResource( 2 ) + +[node name="CollisionShape2D3" type="CollisionShape2D" parent="UI/Houses"] +position = Vector2( 160, 10.25 ) +shape = SubResource( 3 ) + +[node name="CollisionShape2D4" type="CollisionShape2D" parent="UI/Houses"] +position = Vector2( 160, 109.875 ) +shape = SubResource( 3 ) + [node name="Background" type="TextureRect" parent="UI"] margin_top = 120.0 margin_right = 320.0