2023-01-30 08:02:47 +00:00
|
|
|
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")
|
2023-01-30 10:12:53 +00:00
|
|
|
speedometer = $Speedometer
|
|
|
|
timer = $Timer
|
|
|
|
boost_label = $BoostLabel
|
2023-01-30 08:02:47 +00:00
|
|
|
|
|
|
|
|
|
|
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
|
|
func _process(delta):
|
2023-01-30 10:12:53 +00:00
|
|
|
speedometer.text = " %d MPH" % scene.player_speed_mph
|
2023-01-30 08:02:47 +00:00
|
|
|
|
2023-01-30 10:12:53 +00:00
|
|
|
timer.text = (" %05.2f" % scene.time_elapsed_in_race).replace(".", ":")
|
2023-01-30 08:02:47 +00:00
|
|
|
|
|
|
|
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
|