From ed77e27ecd1101f02e3d7fb83cca5a4b62dd3dca Mon Sep 17 00:00:00 2001 From: perivesta <> Date: Fri, 7 Jul 2023 22:54:40 +0200 Subject: very simple drawing --- Nodes/drawing.tscn | 8 ++++++++ Scripts/drawing.gd | 18 ++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 Nodes/drawing.tscn create mode 100644 Scripts/drawing.gd 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) -- cgit From 2236b0c2050f98aa11c6c631ee6ddc9dd7e57df0 Mon Sep 17 00:00:00 2001 From: perivesta <> Date: Fri, 7 Jul 2023 23:26:08 +0200 Subject: follow the drawn path --- Nodes/drawing.tscn | 13 ++++++++++++- Scripts/drawing.gd | 24 ++++++++++++++++++++++-- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/Nodes/drawing.tscn b/Nodes/drawing.tscn index 4c04ea7..3f65fee 100644 --- a/Nodes/drawing.tscn +++ b/Nodes/drawing.tscn @@ -1,8 +1,19 @@ -[gd_scene load_steps=2 format=3 uid="uid://covygojlfmx6x"] +[gd_scene load_steps=4 format=3 uid="uid://covygojlfmx6x"] [ext_resource type="Script" path="res://Scripts/drawing.gd" id="1_03nmp"] +[ext_resource type="Texture2D" uid="uid://bpasf8is2xnfb" path="res://icon.svg" id="2_sgpkt"] + +[sub_resource type="Curve2D" id="Curve2D_dtc4h"] [node name="Drawing" type="Node2D"] script = ExtResource("1_03nmp") [node name="TrackLine" type="Line2D" parent="."] + +[node name="TrackPath" type="Path2D" parent="."] +curve = SubResource("Curve2D_dtc4h") + +[node name="TrackFollower" type="PathFollow2D" parent="TrackPath"] + +[node name="Sprite2D" type="Sprite2D" parent="TrackPath/TrackFollower"] +texture = ExtResource("2_sgpkt") diff --git a/Scripts/drawing.gd b/Scripts/drawing.gd index 34129ac..d47e161 100644 --- a/Scripts/drawing.gd +++ b/Scripts/drawing.gd @@ -1,18 +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: - # start/stop drawing 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) -- cgit From f3c450b15226a74a8390275ce24f8a4c5b025117 Mon Sep 17 00:00:00 2001 From: perivesta <> Date: Fri, 7 Jul 2023 23:47:00 +0200 Subject: basic level ig --- Assets/checkpoint.png | Bin 0 -> 1240 bytes Assets/checkpoint.png.import | 34 ++++++++++++++++++++++++++++++++++ Assets/end.png | Bin 0 -> 699 bytes Assets/end.png.import | 34 ++++++++++++++++++++++++++++++++++ Assets/start.png | Bin 0 -> 1221 bytes Assets/start.png.import | 34 ++++++++++++++++++++++++++++++++++ Nodes/Level_test.tscn | 30 ++++++++++++++++++++++++++++++ project.godot | 1 + 8 files changed, 133 insertions(+) create mode 100644 Assets/checkpoint.png create mode 100644 Assets/checkpoint.png.import create mode 100644 Assets/end.png create mode 100644 Assets/end.png.import create mode 100644 Assets/start.png create mode 100644 Assets/start.png.import create mode 100644 Nodes/Level_test.tscn diff --git a/Assets/checkpoint.png b/Assets/checkpoint.png new file mode 100644 index 0000000..73d03c0 Binary files /dev/null and b/Assets/checkpoint.png differ diff --git a/Assets/checkpoint.png.import b/Assets/checkpoint.png.import new file mode 100644 index 0000000..a6f017e --- /dev/null +++ b/Assets/checkpoint.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dg3v488vx0oj6" +path="res://.godot/imported/checkpoint.png-2694eaf00c0543b664b2954acfb1c821.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/checkpoint.png" +dest_files=["res://.godot/imported/checkpoint.png-2694eaf00c0543b664b2954acfb1c821.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/Assets/end.png b/Assets/end.png new file mode 100644 index 0000000..4d0a847 Binary files /dev/null and b/Assets/end.png differ diff --git a/Assets/end.png.import b/Assets/end.png.import new file mode 100644 index 0000000..13d2f2c --- /dev/null +++ b/Assets/end.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://b8vhe5kt6037n" +path="res://.godot/imported/end.png-9e563786902fadcc061b10b8f57eda4d.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/end.png" +dest_files=["res://.godot/imported/end.png-9e563786902fadcc061b10b8f57eda4d.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/Assets/start.png b/Assets/start.png new file mode 100644 index 0000000..a785cf9 Binary files /dev/null and b/Assets/start.png differ diff --git a/Assets/start.png.import b/Assets/start.png.import new file mode 100644 index 0000000..0cd268f --- /dev/null +++ b/Assets/start.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://5xqahgawme4m" +path="res://.godot/imported/start.png-aec87fdb06c416de1966abd728121a36.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/start.png" +dest_files=["res://.godot/imported/start.png-aec87fdb06c416de1966abd728121a36.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/Nodes/Level_test.tscn b/Nodes/Level_test.tscn new file mode 100644 index 0000000..b3be870 --- /dev/null +++ b/Nodes/Level_test.tscn @@ -0,0 +1,30 @@ +[gd_scene load_steps=5 format=3 uid="uid://dt5grvd5n2ioj"] + +[ext_resource type="Texture2D" uid="uid://5xqahgawme4m" path="res://Assets/start.png" id="1_wenkl"] +[ext_resource type="Texture2D" uid="uid://b8vhe5kt6037n" path="res://Assets/end.png" id="2_gp6ng"] +[ext_resource type="Texture2D" uid="uid://dg3v488vx0oj6" path="res://Assets/checkpoint.png" id="3_cgigr"] +[ext_resource type="PackedScene" uid="uid://covygojlfmx6x" path="res://Nodes/drawing.tscn" id="4_t4rjk"] + +[node name="Level_test" type="Node2D"] + +[node name="Start" type="Sprite2D" parent="."] +position = Vector2(669, 515) +texture = ExtResource("1_wenkl") + +[node name="End" type="Sprite2D" parent="."] +position = Vector2(616, 86) +texture = ExtResource("2_gp6ng") + +[node name="cp1" type="Sprite2D" parent="."] +position = Vector2(270, 338) +texture = ExtResource("3_cgigr") + +[node name="cp2" type="Sprite2D" parent="."] +position = Vector2(621, 323) +texture = ExtResource("3_cgigr") + +[node name="cp3" type="Sprite2D" parent="."] +position = Vector2(404, 145) +texture = ExtResource("3_cgigr") + +[node name="Drawing" parent="." instance=ExtResource("4_t4rjk")] diff --git a/project.godot b/project.godot index f23358f..dc15082 100644 --- a/project.godot +++ b/project.godot @@ -11,5 +11,6 @@ config_version=5 [application] config/name="CodeWithYourFriends23" +run/main_scene="res://Nodes/Level_test.tscn" config/features=PackedStringArray("4.0", "Forward Plus") config/icon="res://icon.svg" -- cgit