blob: 612ba60c2bd20df0161b8fce840a8e1938210623 (
plain) (
tree)
|
|
extends Node
var drawing = false
@onready var line = $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()
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)
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()
|