From 516635e22464699fa940ed981a186088352ba734 Mon Sep 17 00:00:00 2001 From: IcECreAm777 Date: Sat, 8 Jul 2023 17:05:48 +0200 Subject: some cleanups --- Scripts/scene_control.gd | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'Scripts/scene_control.gd') 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; -- cgit