diff options
author | Jonas Bernard <public.jbernard@web.de> | 2021-04-24 22:00:16 +0200 |
---|---|---|
committer | Jonas Bernard <public.jbernard@web.de> | 2021-04-24 22:00:16 +0200 |
commit | a6d55f5145d1aa05c4b05fc4e9f980643dfbeefd (patch) | |
tree | 4e5482f769268ca48f4f019a3d3888d0893cc1d1 /components/healthbar/healtbar.gd | |
parent | 5d74b160790f35f201f2dd1876b84201a8be9534 (diff) | |
download | ldjam48-a6d55f5145d1aa05c4b05fc4e9f980643dfbeefd.tar.gz ldjam48-a6d55f5145d1aa05c4b05fc4e9f980643dfbeefd.tar.bz2 ldjam48-a6d55f5145d1aa05c4b05fc4e9f980643dfbeefd.zip |
healthbar
Diffstat (limited to 'components/healthbar/healtbar.gd')
-rw-r--r-- | components/healthbar/healtbar.gd | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/components/healthbar/healtbar.gd b/components/healthbar/healtbar.gd new file mode 100644 index 0000000..ee9915f --- /dev/null +++ b/components/healthbar/healtbar.gd @@ -0,0 +1,25 @@ +extends Node2D + +export var maxhealth = 3 +export var offset = 40 + +var h: PackedScene = preload("res://components/healthbar/heart.tscn") +var hearts: Array = [] + + + +# Called when the node enters the scene tree for the first time. +func _ready(): + for i in maxhealth: + var heart = h.instance() + hearts.append(heart) + heart.position = Vector2(i * offset, 0) + add_child(heart) + + +func _process(delta): + pass + +func set_health(health: int=maxhealth): + for i in maxhealth: + hearts[i].set_filled(i < health) |