File size: 730 Bytes
b1e4a8e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
extends Control
var best_lap_time = null
var current_lap_time = null
func _ready():
EventManager.event_lap_started.connect(lap_started)
EventManager.event_lap_finished.connect(lap_finished)
func _process(delta):
if current_lap_time != null:
current_lap_time += delta
var time = Utils.time_convert_ms(current_lap_time)
$HBoxContainer/CurrentLabel.text = time
func lap_started(body):
print("lap started")
current_lap_time = 0.0
func lap_finished(body):
print("lap finished")
if !best_lap_time:
best_lap_time = current_lap_time
else:
if current_lap_time < best_lap_time:
best_lap_time = current_lap_time
$HBoxContainer/BestLabel.text = Utils.time_convert_ms(best_lap_time)
current_lap_time = 0.0
|