mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-07-13 11:03:48 +00:00
feat(*): Add hud with timer
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
extends Node3D
|
||||
|
||||
@onready var game_timer: Timer = get_node("Timer")
|
||||
signal timer_updated(minutes: int, seconds: int)
|
||||
|
||||
func _ready():
|
||||
# Set timer to 2 minutes 30 seconds (150 seconds)
|
||||
game_timer.wait_time = 150.0
|
||||
game_timer.one_shot = true # Timer runs once
|
||||
game_timer.start()
|
||||
|
||||
func _process(_delta):
|
||||
if game_timer.time_left > 0:
|
||||
var time_left = game_timer.time_left
|
||||
var minutes = int(time_left) / 60
|
||||
var seconds = int(time_left) % 60
|
||||
timer_updated.emit(minutes, seconds)
|
||||
else:
|
||||
print("Timer finished!")
|
||||
|
||||
func _on_timer_timeout() -> void:
|
||||
if game_timer.time_left == 0:
|
||||
get_tree().change_scene_to_file("res://scenes/main_menu.tscn")
|
||||
Reference in New Issue
Block a user