aboutsummaryrefslogtreecommitdiffstats
path: root/Scripts/scene_control.gd
diff options
context:
space:
mode:
Diffstat (limited to 'Scripts/scene_control.gd')
-rw-r--r--Scripts/scene_control.gd22
1 files changed, 18 insertions, 4 deletions
diff --git a/Scripts/scene_control.gd b/Scripts/scene_control.gd
index ce3332f..453853c 100644
--- a/Scripts/scene_control.gd
+++ b/Scripts/scene_control.gd
@@ -2,18 +2,22 @@ extends Node
class_name SceneControl
+@export var gold_medal_time = 5.0
+@export var silver_medal_time = 7.0
+@export var bronze_medal_time = 10
+
@onready var path: Path2D = $DrawNode/TrackPath
@onready var path_follow: PathFollow2D = $DrawNode/TrackPath/TrackFollower
@onready var car = $Car
@onready var checkpoints = $Checkpoints.get_children()
@onready var ui = $UI/Control
@onready var drawing = $DrawNode
+@onready var start = $Start
var is_driving = false
var current_time = 0.0
var game_control
-var start
func _ready():
@@ -23,8 +27,8 @@ func _ready():
$UI/Control/PostGameUI/RestartButton.pressed.connect(reset_level)
$UI/Control/PostGameUI/NextLevelButton.pressed.connect(next_level)
- start = $Start as TextureButton
- start.pressed.connect(start_drawing)
+ var start_button = $Start/Start as TextureButton
+ start_button.button_down.connect(start_drawing)
reset_level()
@@ -60,6 +64,7 @@ func reset_level():
car.global_position = start.global_position
car.global_rotation = start.rotation;
+ car.velocity = Vector2.ZERO
current_time = 0.0
@@ -75,10 +80,19 @@ func evaluate_driving():
return false
return true
+func evaluate_time():
+ if current_time < gold_medal_time:
+ return 0
+ if current_time < silver_medal_time:
+ return 1
+ if current_time < bronze_medal_time:
+ return 2
+ return 3
+
func _on_finish_line_body_entered(node: Node2D):
if evaluate_driving():
- ui.switch_to_post_game_UI()
+ ui.switch_to_post_game_UI(evaluate_time())
set_driving(false)
return