-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4bc2cde
commit c9321af
Showing
3 changed files
with
22 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,31 @@ | ||
class_name TimeLeftIndicator | ||
extends Label | ||
|
||
signal time_left_ended | ||
|
||
## The time in seconds that the player has to complete the level. | ||
@export var time: int = 300 | ||
|
||
@onready var timer: Timer = $Timer | ||
|
||
|
||
func _ready() -> void: | ||
timer.timeout.connect(_on_timer_timeout) | ||
|
||
|
||
func _process(_delta: float) -> void: | ||
text = "%02d:%02d" % [floor(timer.time_left / 60), int(timer.time_left) % 60] | ||
|
||
|
||
func _on_player_hub_player_exited() -> void: | ||
timer.start(300) | ||
timer.start(time) | ||
visible = true | ||
|
||
|
||
func _on_player_hub_player_entered() -> void: | ||
timer.stop() | ||
visible = false | ||
|
||
|
||
func _on_timer_timeout() -> void: | ||
time_left_ended.emit() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters