From fc40a5c36871adfc3d640d7e211c65936c085314 Mon Sep 17 00:00:00 2001 From: 3002102 <3002102@stud.hs-mannheim.de> Date: Wed, 15 Apr 2026 18:14:52 +0200 Subject: [PATCH] add timer to the ui (#8) Reviewed-on: https://gitty.informatik.hs-mannheim.de/3002102/gae_wild_jam/pulls/8 Co-authored-by: 3002102 <3002102@stud.hs-mannheim.de> Co-committed-by: 3002102 <3002102@stud.hs-mannheim.de> --- scenes/game.gd | 10 +++++----- scenes/game.tscn | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/scenes/game.gd b/scenes/game.gd index 7ac5837..61e4edc 100644 --- a/scenes/game.gd +++ b/scenes/game.gd @@ -1,11 +1,11 @@ extends Node2D +@onready var _timer_label: Label = $CanvasLayer/TimerLabel +@onready var _spawn_control = $SpawnControl -# Called when the node enters the scene tree for the first time. func _ready(): MusicManager.play(preload("res://assets/music&sfx/music/ashveil-355633.mp3")) - -# Called every frame. 'delta' is the elapsed time since the previous frame. -func _process(delta: float) -> void: - pass +func _process(_delta: float) -> void: + var t = int(_spawn_control.elapsed_time) + _timer_label.text = "%02d:%02d" % [t / 60, t % 60] diff --git a/scenes/game.tscn b/scenes/game.tscn index dcf25f2..19e203d 100644 --- a/scenes/game.tscn +++ b/scenes/game.tscn @@ -2436,6 +2436,24 @@ patch_margin_top = 5 patch_margin_right = 8 patch_margin_bottom = 6 +[node name="TimerLabel" type="Label" parent="CanvasLayer" unique_id=1111111111] +anchors_preset = 5 +anchor_left = 0.5 +anchor_right = 0.5 +offset_left = -60.0 +offset_top = 31.0 +offset_right = 60.0 +offset_bottom = 55.0 +grow_horizontal = 2 +text = "00:00" +horizontal_alignment = 1 +theme_override_fonts/font = ExtResource("19_1kice") +theme_override_font_sizes/font_size = 20 +theme_override_colors/font_color = Color(1, 1, 1, 1) +theme_override_colors/font_shadow_color = Color(0, 0, 0, 1) +theme_override_constants/shadow_offset_x = 1 +theme_override_constants/shadow_offset_y = 1 + [node name="LevelUpManager" type="Control" parent="CanvasLayer" unique_id=292400493] process_mode = 3 layout_mode = 3