Chest + Door Functionality

This commit is contained in:
tiffanyfrias10
2021-12-06 16:08:29 -06:00
parent 51365d9f74
commit f774ea1741
19 changed files with 391 additions and 30 deletions

View File

@@ -4,7 +4,9 @@ onready var SNOWBALL_BLUE_SCENE = preload("res://Enemies/Snowball Blue.tscn")
var player = null
var move = Vector2.ZERO
var speed = 1
var speed = .5
var health: int = 2
func _physics_process(delta: float) -> void:
move = Vector2.ZERO
@@ -50,3 +52,13 @@ func _on_player_detector_area_entered(area: Area2D) -> void:
func _on_player_detector_area_exited(_area: Area2D):
player = null
return
func _on_hitbox_area_entered(area: Area2D) -> void:
if area.is_in_group('player_weapon_1'):
health -= 1
elif area.is_in_group('player_weapon_2'):
health -= 2
if health <= 0:
call_deferred('queue_free')
return

View File

@@ -40,7 +40,6 @@ autostart = true
[node name="hitbox" type="Area2D" parent="." groups=[
"enemy_hitbox_1",
]]
visible = false
collision_layer = 4
collision_mask = 2

View File

@@ -5,6 +5,8 @@ onready var SNOWBALL_SCENE = preload("res://Enemies/Snowball.tscn")
var player = null
var move = Vector2.ZERO
var speed = .5
var health: int = 2
func _physics_process(delta: float) -> void:
move = Vector2.ZERO
@@ -51,3 +53,14 @@ func _on_player_detector_area_entered(area: Area2D) -> void:
func _on_player_detector_area_exited(_area: Area2D):
player = null
return
func _on_hitbox_area_entered(area: Area2D) -> void:
print("HIT")
if area.is_in_group('player_weapon_1'):
health -= 1
elif area.is_in_group('player_weapon_2'):
health -= 2
if health <= 0:
call_deferred('queue_free')
return

View File

@@ -28,12 +28,10 @@ rotation = 1.5708
shape = SubResource( 1 )
[node name="detection" type="Area2D" parent="."]
visible = false
collision_layer = 0
collision_mask = 2
[node name="detection" type="CollisionShape2D" parent="detection"]
visible = false
shape = SubResource( 2 )
[node name="Timer" type="Timer" parent="."]