class_name HealthBar
extends TextureRect

var hearts: Array[TextureRect] = []

func _ready() -> void:
	for child in get_children():
		if child is TextureRect:
			hearts.append(child)

func set_health(value: int) -> void:
	for i in range(hearts.size()):
		# This is the simple way of doing it
		#if i < value:
			#hearts[i].visible = true
		#else:
			#hearts[i].visible = false

		# This is the one line, better way of doing it
		hearts[i].visible = (i < value)
