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.gd13
1 files changed, 8 insertions, 5 deletions
diff --git a/Scripts/scene_control.gd b/Scripts/scene_control.gd
index 0b55d0f..d01342f 100644
--- a/Scripts/scene_control.gd
+++ b/Scripts/scene_control.gd
@@ -7,14 +7,16 @@ class_name SceneControl
@onready var car = $Car
@onready var checkpoints = $Checkpoints.get_children()
@onready var ui = $UI/Control
-@onready var finish_line: Area2D
+@onready var start = $Start
+
+var finish_line: Area2D
var is_driving = false
var current_time = 0.0
func _ready():
- finish_line = $FinishLine as Area2D
+ finish_line = $FinishLine/Area2D as Area2D
finish_line.body_entered.connect(_on_finish_line_body_entered)
reset_level()
@@ -41,8 +43,12 @@ func set_driving(driving: bool):
func reset_level():
ui.update_timer_label(-1)
+
for cp in checkpoints:
cp.set_was_visited(false)
+
+ car.global_position = start.global_position
+ car.global_rotation = start.rotation;
func start_driving():
current_time = 0.0
@@ -61,6 +67,3 @@ func _on_finish_line_body_entered(node: Node2D):
set_driving(false)
reset_level()
- # TODO get this from the start position
- car.global_position = Vector2.ZERO
- car.global_rotation = 0;