a game about throwing hammers made for the github game off
Diffstat (limited to 'enemys/Enemy.gd')
-rw-r--r--enemys/Enemy.gd19
1 files changed, 11 insertions, 8 deletions
diff --git a/enemys/Enemy.gd b/enemys/Enemy.gd
index 6457c8f..92e92a3 100644
--- a/enemys/Enemy.gd
+++ b/enemys/Enemy.gd
@@ -9,15 +9,18 @@ signal died
## Current health
@onready var health := max_health:
- set(value):
- health = clamp(value, 0, max_health)
- if health == 0:
- died.emit() # ~~voodoo magic makes this signal connect to die()~~
- die() # the voodoo magic broke ;-;
+ set(value):
+ health = clamp(value, 0, max_health)
+ if health == 0:
+ died.emit() # ~~voodoo magic makes this signal connect to die()~~
+ die() # the voodoo magic broke ;-;
+
func hit(damage: int) -> void:
- health -= damage
+ health -= damage
+
func die() -> void:
- Utils.instance_scene_on_main(preload("res://fx/enemy_death.tscn"), global_position)
- queue_free()
+ Utils.instance_scene_on_main(preload("res://fx/enemy_death.tscn"), global_position)
+ SoundManager.play("death", -20)
+ queue_free()