aboutsummaryrefslogtreecommitdiffstats
path: root/Scripts/drawing.gd
diff options
context:
space:
mode:
authorLibravatar cel 🌸 <cel@blos.sm>2023-07-07 23:08:09 +0100
committerLibravatar cel 🌸 <cel@blos.sm>2023-07-07 23:08:09 +0100
commit45b2751b4e63c8d7b048b005f19f9042782e5a13 (patch)
tree41f8da13e1a8ef0e4c7f50c8fd7af0ef1addf2a1 /Scripts/drawing.gd
parent4cb4a220710f3795aa4f4e4bfed3a27617310733 (diff)
parentf3c450b15226a74a8390275ce24f8a4c5b025117 (diff)
download2023-45b2751b4e63c8d7b048b005f19f9042782e5a13.tar.gz
2023-45b2751b4e63c8d7b048b005f19f9042782e5a13.tar.bz2
2023-45b2751b4e63c8d7b048b005f19f9042782e5a13.zip
merge branch 'drawing'
Diffstat (limited to '')
-rw-r--r--Scripts/drawing.gd38
1 files changed, 38 insertions, 0 deletions
diff --git a/Scripts/drawing.gd b/Scripts/drawing.gd
new file mode 100644
index 0000000..d47e161
--- /dev/null
+++ b/Scripts/drawing.gd
@@ -0,0 +1,38 @@
+extends Node
+
+var drawing = false
+var driving_progress = -1
+var line: Line2D
+var path: Path2D
+
+
+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)
+
+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()
+ driving_progress = -1
+ else:
+ # start driving
+ driving_progress = 0
+
+ if event is InputEventMouseMotion and drawing:
+ # extend the line
+ line.add_point(event.position)
+ path.curve.add_point(event.position)