online multiplayer chess game (note server currently down)
Diffstat (limited to 'ui/TimerLabels.gd')
| -rw-r--r-- | ui/TimerLabels.gd | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/ui/TimerLabels.gd b/ui/TimerLabels.gd index 75cba88..03e8aee 100644 --- a/ui/TimerLabels.gd +++ b/ui/TimerLabels.gd @@ -1,8 +1,10 @@ extends Label -var time := 0.0 setget set_time +var time: float setget set_time var stop := false +const TIME = 300 + export(bool) var white := false onready var colorrect := $ColorRect @@ -23,10 +25,10 @@ func set_time(newtime) -> bool: func _ready() -> void: - _on_turn_over() + set_time(TIME) + set_color() colorrect.show_behind_parent = true - colorrect.color = Globals.grid.overlay_color - Events.connect("turn_over", self, "_on_turn_over") + Events.connect("turn_over", self, "set_color") Events.connect("game_over", self, "_on_game_over") @@ -34,5 +36,8 @@ func _on_game_over() -> void: stop = true -func _on_turn_over() -> void: - colorrect.visible = Globals.turn == white +func set_color() -> void: + if time > 10: + colorrect.color = Globals.grid.clockrunning_color if Globals.turn == white else Color.transparent + else: + colorrect.color = Globals.grid.clockrunninglow if Globals.turn == white else Globals.grid.clocklow |