20 lines
263 B
GDScript
20 lines
263 B
GDScript
extends Sprite2D
|
|
class_name Block
|
|
|
|
@export var health: int = 1
|
|
|
|
func _ready():
|
|
_update_text()
|
|
|
|
func _update_text():
|
|
$Label.text = "%s" % health
|
|
|
|
func take_damage(damage):
|
|
health -= damage
|
|
_update_text()
|
|
if health < 0:
|
|
die()
|
|
|
|
func die():
|
|
self.queue_free()
|