try/PlayerHUD.gd
2023-10-31 19:24:10 -07:00

40 lines
1,003 B
GDScript3

extends CanvasLayer
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
# This one is what I have cut out of the tutorial
# Sorry. I know my code looks like a maniac wrote it.
var heart_full = preload("res://art/full_heart.png")
var heart_empty = preload("res://art/empty_heart.png")
var heart_half = preload("res://art/half_heart.png")
func update_health(halfheart):
var health = halfheart
for i in get_child_count():
if halfheart > i * 2 + 1:
get_child(i).texture = heart_full
elif halfheart > i * 2:
get_child(i).texture = heart_half
else:
get_child(i).texture = heart_empty
#Health UI test, comment this out afterwards
if Input.is_action_pressed("move_up"):
health =+ 1
if Input.is_action_pressed("move_down"):
health =- 1