small racing game im working on
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
extends Label
class_name GameTimer
var elapsed_time: float = 0.0
func _ready() -> void:
stop()
func start() -> void:
set_process(true)
func stop() -> void:
set_process(false)
func now() -> float:
return elapsed_time
## format a number of seconds into m:s.ms
static func format(time: float) -> String:
return "%01d:%02d.%02d" % [time / 60, fmod(time, 60), fmod(time * 1000, 100)]
func _process(delta: float) -> void:
elapsed_time += delta
text = "祥 %s" % GameTimer.format(elapsed_time)
|