extends CanvasLayer const Constants = preload("res://Scripts/Constants.gd") const FLASH_BOOST_DUR : float = 1.0 const FLASH_BOOST_CYCLE : float = 0.1 var scene : GameScene var player : DownhillAutoscrollerPlayer var boost_label : RichTextLabel var flash_boost : bool var flash_time_elapsed : float var speedometer : RichTextLabel var timer : RichTextLabel # Called when the node enters the scene tree for the first time. func _ready(): scene = get_node("/root/Scene") player = get_node("/root/Scene/Player") speedometer = $Speedometer timer = $Timer boost_label = $BoostLabel # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta): speedometer.text = " %d MPH" % scene.player_speed_mph timer.text = (" %05.2f" % scene.time_elapsed_in_race).replace(".", ":") if player.get_current_action() == Constants.UnitCurrentAction.SPINNING: flash_boost = false flash_time_elapsed = 0 boost_label.remove_color_override("default_color") boost_label.visible = true boost_label.text = "+" + str(floor(player.boost * 1.36)) + " MPH" else: if flash_boost: boost_label.add_color_override("default_color", Color.green) flash_time_elapsed += delta if flash_time_elapsed > FLASH_BOOST_DUR: flash_boost = false else: if int(floor(flash_time_elapsed / FLASH_BOOST_CYCLE)) % 2 == 0: boost_label.visible = true else: boost_label.visible = false else: boost_label.visible = false