aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar perivesta <>2023-07-07 22:54:40 +0200
committerLibravatar perivesta <>2023-07-07 22:54:40 +0200
commited77e27ecd1101f02e3d7fb83cca5a4b62dd3dca (patch)
tree6a1c100c0ebde068158c9196434ce7fe398765ae
parent2fc6727848748e5fd3957bda69179d1c261b02a0 (diff)
download2023-ed77e27ecd1101f02e3d7fb83cca5a4b62dd3dca.tar.gz
2023-ed77e27ecd1101f02e3d7fb83cca5a4b62dd3dca.tar.bz2
2023-ed77e27ecd1101f02e3d7fb83cca5a4b62dd3dca.zip
very simple drawing
-rw-r--r--Nodes/drawing.tscn8
-rw-r--r--Scripts/drawing.gd18
2 files changed, 26 insertions, 0 deletions
diff --git a/Nodes/drawing.tscn b/Nodes/drawing.tscn
new file mode 100644
index 0000000..4c04ea7
--- /dev/null
+++ b/Nodes/drawing.tscn
@@ -0,0 +1,8 @@
+[gd_scene load_steps=2 format=3 uid="uid://covygojlfmx6x"]
+
+[ext_resource type="Script" path="res://Scripts/drawing.gd" id="1_03nmp"]
+
+[node name="Drawing" type="Node2D"]
+script = ExtResource("1_03nmp")
+
+[node name="TrackLine" type="Line2D" parent="."]
diff --git a/Scripts/drawing.gd b/Scripts/drawing.gd
new file mode 100644
index 0000000..34129ac
--- /dev/null
+++ b/Scripts/drawing.gd
@@ -0,0 +1,18 @@
+extends Node
+
+var drawing = false
+var line: Line2D
+
+
+func _ready():
+ line = $TrackLine
+ Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
+
+func _input(event):
+ if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT:
+ # start/stop drawing
+ drawing = event.pressed
+
+ if event is InputEventMouseMotion and drawing:
+ # extend the line
+ line.add_point(event.position)