diff options
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 |