diff options
author | perivesta <> | 2023-07-08 11:40:53 +0200 |
---|---|---|
committer | perivesta <> | 2023-07-08 11:40:53 +0200 |
commit | 892ed4854bcccbac546f5ac32c0c5fa0245f5fa7 (patch) | |
tree | 6c3403e1734790c48a90741e62e0369301b1e06a /Scripts/drawing.gd | |
parent | a10d0e582a9a614b933f3e689592595e6438513e (diff) | |
download | 2023-892ed4854bcccbac546f5ac32c0c5fa0245f5fa7.tar.gz 2023-892ed4854bcccbac546f5ac32c0c5fa0245f5fa7.tar.bz2 2023-892ed4854bcccbac546f5ac32c0c5fa0245f5fa7.zip |
draw a path for car to follow
Diffstat (limited to '')
-rw-r--r-- | Scripts/drawing.gd | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/Scripts/drawing.gd b/Scripts/drawing.gd index d47e161..2e4af95 100644 --- a/Scripts/drawing.gd +++ b/Scripts/drawing.gd @@ -1,24 +1,18 @@ extends Node var drawing = false -var driving_progress = -1 -var line: Line2D -var path: Path2D +@onready var line: Line2D = $TrackLine +@onready var path: Path2D = $TrackPath func _ready(): - line = $TrackLine - path = $TrackPath Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE) func _process(delta): pass func _physics_process(delta): - if driving_progress >= 0: - driving_progress += delta*200 - $TrackPath/TrackFollower.progress = driving_progress - #print(driving_progress) + pass func _input(event): if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT: @@ -27,10 +21,10 @@ func _input(event): # start a new drawing line.clear_points() path.curve.clear_points() - driving_progress = -1 + owner.set_driving(false) else: # start driving - driving_progress = 0 + owner.set_driving(true) if event is InputEventMouseMotion and drawing: # extend the line |