aboutsummaryrefslogtreecommitdiffstats
path: root/Scripts/scene_control.gd
diff options
context:
space:
mode:
authorLibravatar IcECreAm777 <hgk.1998@googlemail.com>2023-07-08 17:05:48 +0200
committerLibravatar IcECreAm777 <hgk.1998@googlemail.com>2023-07-08 17:05:48 +0200
commit516635e22464699fa940ed981a186088352ba734 (patch)
tree9fcce535afb4b59f6109d95644b23ca5f5873b72 /Scripts/scene_control.gd
parent8b08fec313ac3517e782d946cbd203958801e6be (diff)
download2023-516635e22464699fa940ed981a186088352ba734.tar.gz
2023-516635e22464699fa940ed981a186088352ba734.tar.bz2
2023-516635e22464699fa940ed981a186088352ba734.zip
some cleanups
Diffstat (limited to '')
-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;