From 32791d623f75d1887347d36f891094f969b893a3 Mon Sep 17 00:00:00 2001 From: Eduardo Date: Fri, 9 Feb 2024 03:00:18 +0100 Subject: [PATCH] the screen clock now has random glitches --- levels/ui.gd | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 levels/ui.gd diff --git a/levels/ui.gd b/levels/ui.gd new file mode 100644 index 0000000..9838283 --- /dev/null +++ b/levels/ui.gd @@ -0,0 +1,65 @@ +extends Control + +@export var battery := 100 +@onready var dateLabel := $HBoxContainer/Date +@onready var batteryLabel := $HBoxContainer/Battery +@onready var timeLabel := $Time +@onready var nightmareLabel := $NightmareText +@onready var rightTopLabel := $RightTopText +@onready var rightBottomLabel := $RightBottomText + + +# Called when the node enters the scene tree for the first time. +func _ready(): + batteryLabel.text = " ⚡ " + str(battery) + "%" + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta): + pass + + +# each second +func _on_timer_timeout(): + timeLabel.set_text(set_rand_timer()) + + +func set_rand_timer() -> String: + var random := randf() + var block: String = "?" + var text: String + + if .01 < random && random < .02: + block = "▓" + elif .02 < random && random < .03: + block = "▒" + elif .03 < random && random < .04: + block = "░" + elif .04 < random && random < .05: + block = "█" + + random = randf() * 10 + if 0 < random && random < 1: + text = block + "?:??" + elif 1 < random && random < 2: + text = "?" + block + ":??" + elif 2 < random && random < 3: + text = "??:" + block + "?" + elif 3 < random && random < 4: + text = "??:?" + block + else: + text = "??:??" + + random = randf() * 10 + if 0 < random && random < 1: + text += " AM" + elif 2 < random && random < 3: + text += " PM" + elif 6 < random && random < 7: + text += " " + block + "M" + else: + text += timeLabel.get_text().substr( + len(timeLabel.get_text()) - 3, len(timeLabel.get_text()) - 1 + ) + + return text -- 2.30.2