Chest + Door Functionality
This commit is contained in:
@@ -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
|
||||
|
@@ -40,7 +40,6 @@ autostart = true
|
||||
[node name="hitbox" type="Area2D" parent="." groups=[
|
||||
"enemy_hitbox_1",
|
||||
]]
|
||||
visible = false
|
||||
collision_layer = 4
|
||||
collision_mask = 2
|
||||
|
||||
|
@@ -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
|
||||
|
@@ -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="."]
|
||||
|
Reference in New Issue
Block a user