Files
GMTK25/damageable/damageable.gd
Minimata 2d44a2da05
All checks were successful
Create tag and build when new code gets to main / BumpTag (push) Successful in 6s
Create tag and build when new code gets to main / Export (push) Successful in 2m26s
feat: final cutscene and full game loop
2025-08-03 11:25:21 +02:00

27 lines
442 B
GDScript

extends Node
class_name Damageable
@export var health = 3
@export var hitback_velocity: float = 500
var active = true
signal got_hit
signal die
func set_active(new_active: bool):
active = new_active
func damage(value: int = 0, direction: Vector2 = Vector2.UP):
if not active:
return
if hitback_velocity > 0:
get_parent().velocity = hitback_velocity * direction
got_hit.emit()
health -= value
if health <= 0:
die.emit()