Skip to content

Commit

Permalink
refactor: hitboxes for a lot of the drops
Browse files Browse the repository at this point in the history
  • Loading branch information
SonuTheNecro committed Nov 16, 2024
1 parent 7a9f629 commit 82516d8
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 47 deletions.
19 changes: 5 additions & 14 deletions scenes/enemy/dynamite_drop.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=12 format=3 uid="uid://bcii3lc3s0ugh"]
[gd_scene load_steps=10 format=3 uid="uid://bcii3lc3s0ugh"]

[ext_resource type="Script" path="res://scripts/enemy/dynamite_drop.gd" id="1_q8s6r"]
[ext_resource type="PackedScene" uid="uid://byt03rernj7cq" path="res://scenes/enemy/drop.tscn" id="1_rauiw"]
Expand Down Expand Up @@ -46,12 +46,6 @@ animations = [{
"speed": 6.0
}]

[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_7yegr"]
radius = 7.0

[sub_resource type="CircleShape2D" id="CircleShape2D_kef7d"]
radius = 32.0156

[node name="dynamite_drop" type="Node2D" groups=["drop"]]
script = ExtResource("1_q8s6r")

Expand All @@ -69,16 +63,13 @@ animation = &"idle"

[node name="StaticBody2D" type="StaticBody2D" parent="." groups=["drop"]]

[node name="CollisionShape2D" type="CollisionShape2D" parent="StaticBody2D"]
position = Vector2(1, -15)
shape = SubResource("CapsuleShape2D_7yegr")
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="StaticBody2D"]
polygon = PackedVector2Array(-1, -29, 3, -29, 6, -27, 6, -2, 2, -1, 2, -1, 0, -1, -4, -2, -4, -26)

[node name="explosion_hitbox" type="Area2D" parent="."]

[node name="CollisionShape2D" type="CollisionShape2D" parent="explosion_hitbox"]
position = Vector2(0, -17)
shape = SubResource("CircleShape2D_kef7d")
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="explosion_hitbox"]
polygon = PackedVector2Array(-5, -40, -10, -40, -22, -42, -23, -41, -12, -32, -14, -31, -14, -33, -17, -32, -20, -31, -22, -31, -24, -29, -13, -21, -27, -21, -28, -20, -14, -14, -28, -10, -14, -6, -25, -3, -23, 0, -12, 1, -8, 1, -14, 7, -8, 9, 6, 4, 9, 8, 12, 8, 13, 4, 15, -1, 22, -2, 31, -3, 32, -4, 17, -10, 35, -19, 34, -20, 33, -21, 28, -22, 22, -22, 21, -23, 18, -23, 16, -24, 15, -25, 18, -27, 20, -28, 21, -29, 22, -30, 24, -30, 25, -31, 29, -37, 29, -38, 28, -39, 25, -39, 25, -40, 10, -40, 9, -39, 6, -39, 4, -40, 4, -42, 5, -42, 5, -44, 1, -48, -2, -43)
disabled = true
debug_color = Color(0.976379, 0.153833, 0, 0.42)

[connection signal="body_entered" from="explosion_hitbox" to="." method="_on_explosion_hitbox_body_entered"]
2 changes: 1 addition & 1 deletion scenes/enemy/honey_drop.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ fall_speed = 10
texture_filter = 1
position = Vector2(8, -29)
sprite_frames = SubResource("SpriteFrames_2q26l")
animation = &"explosion"
animation = &"idle"

[node name="StaticBody2D" type="StaticBody2D" parent="." groups=["drop"]]

Expand Down
21 changes: 5 additions & 16 deletions scenes/enemy/ice_drop.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=13 format=3 uid="uid://bt0n0l7e3i1s"]
[gd_scene load_steps=11 format=3 uid="uid://bt0n0l7e3i1s"]

[ext_resource type="PackedScene" uid="uid://byt03rernj7cq" path="res://scenes/enemy/drop.tscn" id="1_25fhf"]
[ext_resource type="Script" path="res://scripts/enemy/ice_drop.gd" id="1_ltntn"]
Expand Down Expand Up @@ -53,13 +53,6 @@ animations = [{
"speed": 5.0
}]

[sub_resource type="RectangleShape2D" id="RectangleShape2D_xyyee"]
size = Vector2(32, 33)

[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_a4iw7"]
radius = 33.0
height = 74.0

[node name="ice_drop" type="Node2D"]
script = ExtResource("1_ltntn")

Expand All @@ -77,17 +70,13 @@ animation = &"explosion"

[node name="StaticBody2D" type="StaticBody2D" parent="." groups=["drop"]]

[node name="CollisionShape2D" type="CollisionShape2D" parent="StaticBody2D"]
position = Vector2(1, -18.5)
shape = SubResource("RectangleShape2D_xyyee")
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="StaticBody2D"]
polygon = PackedVector2Array(18, -33, 17, -29, 17, -25, 16, -22, 15, -19, 14, -15, 12, -13, 12, -6, 11, -2, 10, -1, -8, -1, -9, -4, -10, -8, -11, -9, -11, -12, -12, -13, -12, -19, -13, -20, -13, -24, -14, -25, -14, -28, -15, -29, -15, -30, -16, -31, -16, -33, -15, -35, 3, -35, 17, -34)

[node name="explosion_hitbox" type="Area2D" parent="."]

[node name="CollisionShape2D" type="CollisionShape2D" parent="explosion_hitbox"]
position = Vector2(7, -26)
rotation = 1.5708
shape = SubResource("CapsuleShape2D_a4iw7")
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="explosion_hitbox"]
polygon = PackedVector2Array(-25, -5, -23, -6, -23, -8, -22, -9, -21, -9, -20, -10, -20, -11, -19, -12, -17, -13, -18, -15, -16, -16, -15, -17, -15, -21, -33, -21, -32, -23, -29, -24, -22, -25, -15, -26, -15, -29, -22, -30, -25, -31, -31, -33, -35, -34, -35, -36, -15, -36, -15, -39, -12, -42, -11, -42, -10, -43, -12, -45, -13, -47, -13, -53, -12, -56, -11, -56, -10, -54, -8, -52, -6, -50, -5, -49, -3, -48, -3, -47, 0, -47, 0, -48, 5, -48, 5, -50, 7, -50, 7, -56, 8, -58, 10, -60, 12, -60, 12, -47, 17, -48, 18, -46, 20, -46, 21, -48, 23, -49, 24, -50, 25, -52, 28, -53, 30, -54, 31, -54, 31, -50, 30, -47, 28, -45, 27, -44, 27, -42, 25, -42, 25, -41, 26, -40, 29, -37, 29, -33, 30, -33, 38, -32, 38, -30, 44, -30, 41, -29, 35, -28, 30, -27, 31, -25, 31, -22, 40, -21, 44, -20, 48, -19, 50, -17, 44, -16, 34, -15, 34, -14, 31, -13, 31, -9, 28, -7, 27, -6, 27, -4, 28, -2, 29, -1, 30, -1, 30, 2, 31, 3, 28, 3, 25, 2, 23, 0, 21, -1, 20, -2, 20, -3, 19, -4, 18, -4, 15, -3, 11, -3, 10, -1, 7, 3, 5, 3, 4, 3, 4, -3, 2, -4, -2, -5, -4, -6, -6, -7, -6, -9, -12, -9, -12, -8, -15, -8, -15, -6, -18, -6, -18, -4)
disabled = true
debug_color = Color(0.922421, 0.201833, 0.485053, 0.42)

[connection signal="body_entered" from="explosion_hitbox" to="." method="_on_explosion_hitbox_body_entered"]
10 changes: 3 additions & 7 deletions scenes/enemy/recycle_drop.tscn
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
[gd_scene load_steps=5 format=3 uid="uid://il0rmx21373j"]
[gd_scene load_steps=4 format=3 uid="uid://il0rmx21373j"]

[ext_resource type="Script" path="res://scripts/enemy/trash_drop.gd" id="1_4r021"]
[ext_resource type="PackedScene" uid="uid://byt03rernj7cq" path="res://scenes/enemy/drop.tscn" id="1_t7hxi"]
[ext_resource type="Texture2D" uid="uid://gmb53j23hwlp" path="res://art/enemy/recycle_bag.png" id="2_gnhg6"]

[sub_resource type="CircleShape2D" id="CircleShape2D_xopqp"]
radius = 25.0799

[node name="recycle_drop" type="Node2D"]
script = ExtResource("1_4r021")

Expand All @@ -22,6 +19,5 @@ texture = ExtResource("2_gnhg6")

[node name="StaticBody2D" type="StaticBody2D" parent="." groups=["drop"]]

[node name="CollisionShape2D" type="CollisionShape2D" parent="StaticBody2D"]
position = Vector2(-6, 9)
shape = SubResource("CircleShape2D_xopqp")
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="StaticBody2D"]
polygon = PackedVector2Array(16, -1, 16, 20, 6, 32, -11, 32, -24, 30, -29, 23, -29, 11, -24, 0, -17, -9, -12, -13, -11, -17, -2, -17)
10 changes: 3 additions & 7 deletions scenes/enemy/trash_drop.tscn
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
[gd_scene load_steps=5 format=3 uid="uid://cavkox226ugj2"]
[gd_scene load_steps=4 format=3 uid="uid://cavkox226ugj2"]

[ext_resource type="PackedScene" uid="uid://byt03rernj7cq" path="res://scenes/enemy/drop.tscn" id="1_iv03g"]
[ext_resource type="Script" path="res://scripts/enemy/trash_drop.gd" id="1_lhp6l"]
[ext_resource type="Texture2D" uid="uid://cw2gifd8toa4n" path="res://art/enemy/trash.png" id="2_ib0ly"]

[sub_resource type="CircleShape2D" id="CircleShape2D_eajab"]
radius = 27.0

[node name="trash_drop" type="Node2D" groups=["drop"]]
script = ExtResource("1_lhp6l")

Expand All @@ -22,6 +19,5 @@ texture = ExtResource("2_ib0ly")

[node name="StaticBody2D" type="StaticBody2D" parent="." groups=["drop"]]

[node name="CollisionShape2D" type="CollisionShape2D" parent="StaticBody2D"]
position = Vector2(-6, 6)
shape = SubResource("CircleShape2D_eajab")
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="StaticBody2D"]
polygon = PackedVector2Array(16, -1, 16, 19, 6, 31, -11, 31, -24, 29, -29, 24, -29, 11, -25, 1, -16, -10, -10, -16, -10, -17, -2, -17)
2 changes: 1 addition & 1 deletion scripts/enemy/dynamite_drop.gd
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ func _ready() -> void:

func timer_timeout_event():
self.rotation_degrees = 0
get_node("explosion_hitbox/CollisionShape2D").set_deferred("disabled", false)
get_node("explosion_hitbox/CollisionPolygon2D").set_deferred("disabled", false)
$AnimatedSprite2D.play("explosion")


Expand Down
2 changes: 1 addition & 1 deletion scripts/enemy/ice_drop.gd
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ func _ready() -> void:

func timer_timeout_event():
self.rotation_degrees = 0
get_node("explosion_hitbox/CollisionShape2D").set_deferred("disabled", false)
get_node("explosion_hitbox/CollisionPolygon2D").set_deferred("disabled", false)
$AnimatedSprite2D.play("explosion")


Expand Down

0 comments on commit 82516d8

Please sign in to comment.