aboutsummaryrefslogtreecommitdiffstats
path: root/Scripts/drawing.gd
blob: 2e4af958954bd1c60547bb812b337f72e7c5994a (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
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 _process(delta):
	pass

func _physics_process(delta):
	pass

func _input(event):
	if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT:
		drawing = event.pressed
		if drawing:
			# start a new drawing
			line.clear_points()
			path.curve.clear_points()
			owner.set_driving(false)
		else:
			# start driving
			owner.set_driving(true)
	
	if event is InputEventMouseMotion and drawing:
		# extend the line
		line.add_point(event.position)
		path.curve.add_point(event.position)