aboutsummaryrefslogblamecommitdiffstats
path: root/Scripts/drawing.gd
blob: a8068a22415ae39a2058447b6973b97c5ccc700f (plain) (tree)
1
2
3
4
5
6
7
8
9
10


                   
 
                         
                                      

              

                                                      
 

                     
                      



                       
                       


                                           


                               
                   
                                                      
                                              




                                 
extends Node

var drawing = false

@onready var line = $Road
@onready var path: Path2D = $TrackPath

func _ready():
	Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)


func start_drawing():
	reset()
	drawing = true


func _end_drawing():
	drawing = false
	line.simplify()
	line.draw_borders()
	for point in line.points:
		path.curve.add_point(point)
	owner.set_driving(true)


func _input(event):
	if drawing and event is InputEventMouseMotion:
		line.add_point(event.position)


func reset():
	line.clear_points()
	path.curve.clear_points()