blob: e99d4a018c35080ec09768e90a9caa16cd9925f5 (
plain) (
blame)
| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
 | extends Node
var drawing = false
@onready var line: Line2D = $TrackLine
@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()
	owner.set_driving(true)
func _input(event):
	if drawing and event is InputEventMouseMotion:
		line.add_point(event.position)
		path.curve.add_point(event.position)
	if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_RIGHT:
		drawing = false
		reset()
func reset():
	line.clear_points()
	line.clear_borders()
	path.curve.clear_points()
 |