Major collision detection improvements, more file organization, and added key interactable

This commit is contained in:
VoidTwo
2021-12-04 00:07:33 -06:00
parent ca2ea40b23
commit fcea3cee03
18 changed files with 155 additions and 59 deletions

View File

@@ -45,13 +45,18 @@ func add_currency(amount: int) -> void:
return
func add_item(item: String) -> void:
print('%s added to inventory' % [item])
return
func _on_Inventory_update_currency(amount: int) -> void:
hud.update_currency(amount)
return
func _on_Hitbox_body_entered(body: Node) -> void:
if not 'enemies' in body.get_groups():
func _on_hitbox_area_entered(area: Area2D) -> void:
if not 'enemy_hitbox' in area.get_groups():
return
if health_index != 0:

View File

@@ -8,25 +8,25 @@
[sub_resource type="SpriteFrames" id=1]
animations = [ {
"frames": [ ExtResource( 2 ) ],
"loop": false,
"name": "look_right",
"speed": 5.0
}, {
"frames": [ ExtResource( 3 ) ],
"loop": false,
"name": "look_down",
"speed": 5.0
}, {
"frames": [ ExtResource( 4 ) ],
"frames": [ ExtResource( 2 ) ],
"loop": false,
"name": "look_up",
"name": "look_right",
"speed": 5.0
}, {
"frames": [ ExtResource( 2 ) ],
"loop": false,
"name": "look_left",
"speed": 5.0
}, {
"frames": [ ExtResource( 4 ) ],
"loop": false,
"name": "look_up",
"speed": 5.0
} ]
[sub_resource type="CapsuleShape2D" id=2]
@@ -180,7 +180,7 @@ graph_offset = Vector2( -3591.37, -302.6 )
[sub_resource type="AnimationNodeStateMachinePlayback" id=14]
[node name="Player" type="KinematicBody2D"]
[node name="Player" type="KinematicBody2D" groups=["player"]]
collision_layer = 2
script = ExtResource( 1 )
@@ -188,16 +188,17 @@ script = ExtResource( 1 )
light_mask = 2
frames = SubResource( 1 )
animation = "look_right"
offset = Vector2( 0, -5 )
offset = Vector2( 0, -4 )
[node name="Collision" type="CollisionShape2D" parent="."]
visible = false
rotation = 1.5708
shape = SubResource( 2 )
[node name="Hitbox" type="Area2D" parent="."]
[node name="Hitbox" type="Area2D" parent="." groups=["player_hitbox"]]
collision_layer = 2
collision_mask = 2
collision_mask = 4
input_pickable = false
[node name="CollisionShape2D" type="CollisionShape2D" parent="Hitbox"]
visible = false
@@ -220,5 +221,5 @@ parameters/Idle/blend_position = Vector2( 0.0760697, 0 )
[node name="Inventory" parent="." instance=ExtResource( 5 )]
[connection signal="body_entered" from="Hitbox" to="." method="_on_Hitbox_body_entered"]
[connection signal="area_entered" from="Hitbox" to="." method="_on_hitbox_area_entered"]
[connection signal="update_currency" from="Inventory" to="." method="_on_Inventory_update_currency"]