diff options
author | Lucas Fryzek <lucas.fryzek@fryzekconcepts.com> | 2024-09-29 22:31:03 +0100 |
---|---|---|
committer | Lucas Fryzek <lucas.fryzek@fryzekconcepts.com> | 2024-09-29 22:31:03 +0100 |
commit | a10570d865106dcaf1037979cad1788da03e989d (patch) | |
tree | 7f49d98cbeb8f85e32351a428e2d898cc8dcfd2a /scripts/ui.gd | |
parent | 0b14efee60765701f439b5174e56c0cf0639d20c (diff) |
ui: Add UI to disply ammo and info toasts
Diffstat (limited to 'scripts/ui.gd')
-rw-r--r-- | scripts/ui.gd | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/scripts/ui.gd b/scripts/ui.gd new file mode 100644 index 0000000..eaf2d0c --- /dev/null +++ b/scripts/ui.gd @@ -0,0 +1,31 @@ +extends CanvasLayer + +@export var player: Node3D + +var timeout: float = 0 +var timeout_counter: float = 0 + +# Called when the node enters the scene tree for the first time. +#func _ready() -> void: +# pass # Replace with function body. + +func have_toast() -> bool: + return timeout > 0 + +func set_toast(text: String, p_timeout: float) -> void: + $Toast.text = text + + if p_timeout != 0: + timeout = p_timeout + timeout_counter = 0 + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta: float) -> void: + $Ammo.text = "Ammo " + str(player.ammo) + + if timeout > 0: + if timeout_counter < timeout: + timeout_counter += delta + else: + $Toast.text = "" + timeout = 0 |