From 859563f6ad4370a7f5f96963d63f4d83eecad9a4 Mon Sep 17 00:00:00 2001 From: cel 🌸 Date: Sun, 9 Jul 2023 16:54:44 +0100 Subject: fix crash --- Levels/Level1.tscn | 18 ++++++++++++++---- Levels/Level2.tscn | 18 ++++++++++++++---- Levels/Level3.tscn | 18 ++++++++++++++---- Levels/LevelTemplate.tscn | 18 ++++++++++++++---- Levels/Level_test_2.tscn | 18 ++++++++++++++---- Levels/Tut01.tscn | 16 ++++++++++++---- Levels/Tut02.tscn | 19 ++++++++++++++----- Levels/Tut03.tscn | 18 ++++++++++++++---- Scripts/Road.gd | 4 ++++ Scripts/drawing.gd | 3 ++- 10 files changed, 116 insertions(+), 34 deletions(-) diff --git a/Levels/Level1.tscn b/Levels/Level1.tscn index d896692..cbe44c2 100644 --- a/Levels/Level1.tscn +++ b/Levels/Level1.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=12 format=3 uid="uid://b7nxnsf8dirqk"] +[gd_scene load_steps=14 format=3 uid="uid://b7nxnsf8dirqk"] [ext_resource type="Script" path="res://Scripts/scene_control.gd" id="1_jvdy8"] [ext_resource type="PackedScene" uid="uid://c8r6i3bu37ogu" path="res://Nodes/ui.tscn" id="2_2bp3f"] @@ -8,6 +8,8 @@ [ext_resource type="Script" path="res://Scripts/drawing.gd" id="6_yls5q"] [ext_resource type="Texture2D" uid="uid://dg3v488vx0oj6" path="res://Assets/checkpoint.png" id="7_e50r0"] [ext_resource type="PackedScene" uid="uid://wkfai2lvnp7n" path="res://Nodes/checkpoint.tscn" id="8_mrrls"] +[ext_resource type="Texture2D" uid="uid://bcn7tgs6a4fm7" path="res://Assets/road.png" id="8_yjlto"] +[ext_resource type="Script" path="res://Scripts/Road.gd" id="9_3mco4"] [ext_resource type="TileSet" uid="uid://cl8153posdeim" path="res://Assets/grass_tile_set.tres" id="9_m86ct"] [sub_resource type="CircleShape2D" id="CircleShape2D_qhju2"] @@ -48,9 +50,6 @@ z_index = 3 [node name="DrawNode" type="Node2D" parent="."] script = ExtResource("6_yls5q") -[node name="TrackLine" type="Line2D" parent="DrawNode"] -default_color = Color(0.870588, 0.870588, 0.870588, 0.431373) - [node name="TrackPath" type="Path2D" parent="DrawNode"] curve = SubResource("Curve2D_0exre") @@ -66,6 +65,17 @@ texture = ExtResource("7_e50r0") wait_time = 0.2 one_shot = true +[node name="TrackLine" type="Line2D" parent="DrawNode"] +texture_repeat = 2 +width = 70.0 +texture = ExtResource("8_yjlto") +texture_mode = 1 +script = ExtResource("9_3mco4") + +[node name="LeftBorder" type="Line2D" parent="DrawNode/TrackLine"] + +[node name="RightBorder" type="Line2D" parent="DrawNode/TrackLine"] + [node name="Checkpoints" type="Node" parent="."] [node name="Checkpoint" parent="Checkpoints" instance=ExtResource("8_mrrls")] diff --git a/Levels/Level2.tscn b/Levels/Level2.tscn index f2da4e1..048ceb4 100644 --- a/Levels/Level2.tscn +++ b/Levels/Level2.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=11 format=3 uid="uid://c4ufprgnkgelp"] +[gd_scene load_steps=13 format=3 uid="uid://c4ufprgnkgelp"] [ext_resource type="Script" path="res://Scripts/scene_control.gd" id="1_hjw4x"] [ext_resource type="PackedScene" uid="uid://c8r6i3bu37ogu" path="res://Nodes/ui.tscn" id="2_koori"] @@ -6,8 +6,10 @@ [ext_resource type="Texture2D" uid="uid://cxhterify3l" path="res://Assets/Images/goal.png" id="4_euu0i"] [ext_resource type="PackedScene" uid="uid://c1mvbh2fwqtkb" path="res://Nodes/car.tscn" id="5_5co3o"] [ext_resource type="Script" path="res://Scripts/drawing.gd" id="6_hv33l"] +[ext_resource type="Texture2D" uid="uid://bcn7tgs6a4fm7" path="res://Assets/road.png" id="7_k0xyq"] [ext_resource type="TileSet" uid="uid://cl8153posdeim" path="res://Assets/grass_tile_set.tres" id="7_lgn1k"] [ext_resource type="PackedScene" uid="uid://wkfai2lvnp7n" path="res://Nodes/checkpoint.tscn" id="7_vm5ky"] +[ext_resource type="Script" path="res://Scripts/Road.gd" id="8_ni64o"] [sub_resource type="CircleShape2D" id="CircleShape2D_6g88q"] radius = 17.0 @@ -45,15 +47,23 @@ shape = SubResource("CircleShape2D_6g88q") [node name="DrawNode" type="Node2D" parent="."] script = ExtResource("6_hv33l") -[node name="TrackLine" type="Line2D" parent="DrawNode"] -default_color = Color(0.870588, 0.870588, 0.870588, 0.431373) - [node name="TrackPath" type="Path2D" parent="DrawNode"] curve = SubResource("Curve2D_0exre") [node name="TrackFollower" type="PathFollow2D" parent="DrawNode/TrackPath"] loop = false +[node name="TrackLine" type="Line2D" parent="DrawNode"] +texture_repeat = 2 +width = 70.0 +texture = ExtResource("7_k0xyq") +texture_mode = 1 +script = ExtResource("8_ni64o") + +[node name="LeftBorder" type="Line2D" parent="DrawNode/TrackLine"] + +[node name="RightBorder" type="Line2D" parent="DrawNode/TrackLine"] + [node name="Checkpoints" type="Node" parent="."] [node name="Checkpoint" parent="Checkpoints" instance=ExtResource("7_vm5ky")] diff --git a/Levels/Level3.tscn b/Levels/Level3.tscn index 344f7ee..0b9c987 100644 --- a/Levels/Level3.tscn +++ b/Levels/Level3.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=11 format=3 uid="uid://ctw32x620maaj"] +[gd_scene load_steps=13 format=3 uid="uid://ctw32x620maaj"] [ext_resource type="Script" path="res://Scripts/scene_control.gd" id="1_iao1p"] [ext_resource type="PackedScene" uid="uid://c8r6i3bu37ogu" path="res://Nodes/ui.tscn" id="2_rgpyj"] @@ -7,7 +7,9 @@ [ext_resource type="PackedScene" uid="uid://c1mvbh2fwqtkb" path="res://Nodes/car.tscn" id="5_ja277"] [ext_resource type="Script" path="res://Scripts/drawing.gd" id="6_c7w7m"] [ext_resource type="TileSet" uid="uid://cl8153posdeim" path="res://Assets/grass_tile_set.tres" id="7_2rtyp"] +[ext_resource type="Texture2D" uid="uid://bcn7tgs6a4fm7" path="res://Assets/road.png" id="7_7isac"] [ext_resource type="PackedScene" uid="uid://wkfai2lvnp7n" path="res://Nodes/checkpoint.tscn" id="7_c20c2"] +[ext_resource type="Script" path="res://Scripts/Road.gd" id="8_itqp7"] [sub_resource type="CircleShape2D" id="CircleShape2D_6g88q"] radius = 17.0 @@ -46,15 +48,23 @@ shape = SubResource("CircleShape2D_6g88q") [node name="DrawNode" type="Node2D" parent="."] script = ExtResource("6_c7w7m") -[node name="TrackLine" type="Line2D" parent="DrawNode"] -default_color = Color(0.870588, 0.870588, 0.870588, 0.431373) - [node name="TrackPath" type="Path2D" parent="DrawNode"] curve = SubResource("Curve2D_0exre") [node name="TrackFollower" type="PathFollow2D" parent="DrawNode/TrackPath"] loop = false +[node name="TrackLine" type="Line2D" parent="DrawNode"] +texture_repeat = 2 +width = 70.0 +texture = ExtResource("7_7isac") +texture_mode = 1 +script = ExtResource("8_itqp7") + +[node name="LeftBorder" type="Line2D" parent="DrawNode/TrackLine"] + +[node name="RightBorder" type="Line2D" parent="DrawNode/TrackLine"] + [node name="Checkpoints" type="Node" parent="."] [node name="Checkpoint" parent="Checkpoints" instance=ExtResource("7_c20c2")] diff --git a/Levels/LevelTemplate.tscn b/Levels/LevelTemplate.tscn index 8539704..7799a9d 100644 --- a/Levels/LevelTemplate.tscn +++ b/Levels/LevelTemplate.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=10 format=3 uid="uid://dliou1u4o6bib"] +[gd_scene load_steps=12 format=3 uid="uid://dliou1u4o6bib"] [ext_resource type="Script" path="res://Scripts/scene_control.gd" id="1_2b4bf"] [ext_resource type="PackedScene" uid="uid://c8r6i3bu37ogu" path="res://Nodes/ui.tscn" id="2_2w0c4"] @@ -6,6 +6,8 @@ [ext_resource type="Texture2D" uid="uid://cxhterify3l" path="res://Assets/Images/goal.png" id="4_x2h7q"] [ext_resource type="PackedScene" uid="uid://c1mvbh2fwqtkb" path="res://Nodes/car.tscn" id="5_v816p"] [ext_resource type="Script" path="res://Scripts/drawing.gd" id="6_ihf71"] +[ext_resource type="Script" path="res://Scripts/Road.gd" id="7_58u4u"] +[ext_resource type="Texture2D" uid="uid://bcn7tgs6a4fm7" path="res://Assets/road.png" id="7_o1l8b"] [ext_resource type="TileSet" uid="uid://cl8153posdeim" path="res://Assets/grass_tile_set.tres" id="8_7sh6f"] [sub_resource type="CircleShape2D" id="CircleShape2D_6g88q"] @@ -42,15 +44,23 @@ shape = SubResource("CircleShape2D_6g88q") [node name="DrawNode" type="Node2D" parent="."] script = ExtResource("6_ihf71") -[node name="TrackLine" type="Line2D" parent="DrawNode"] -default_color = Color(0.870588, 0.870588, 0.870588, 0.431373) - [node name="TrackPath" type="Path2D" parent="DrawNode"] curve = SubResource("Curve2D_0exre") [node name="TrackFollower" type="PathFollow2D" parent="DrawNode/TrackPath"] loop = false +[node name="TrackLine" type="Line2D" parent="DrawNode"] +texture_repeat = 2 +width = 70.0 +texture = ExtResource("7_o1l8b") +texture_mode = 1 +script = ExtResource("7_58u4u") + +[node name="LeftBorder" type="Line2D" parent="DrawNode/TrackLine"] + +[node name="RightBorder" type="Line2D" parent="DrawNode/TrackLine"] + [node name="Checkpoints" type="Node" parent="."] [node name="TileMap" type="TileMap" parent="."] diff --git a/Levels/Level_test_2.tscn b/Levels/Level_test_2.tscn index 350663f..2698b31 100644 --- a/Levels/Level_test_2.tscn +++ b/Levels/Level_test_2.tscn @@ -1,10 +1,12 @@ -[gd_scene load_steps=11 format=3 uid="uid://b7nxnsf8dirqk"] +[gd_scene load_steps=13 format=3 uid="uid://b7nxnsf8dirqk"] [ext_resource type="Script" path="res://Scripts/scene_control.gd" id="1_amd1r"] [ext_resource type="PackedScene" uid="uid://c8r6i3bu37ogu" path="res://Nodes/ui.tscn" id="2_veexm"] [ext_resource type="Texture2D" uid="uid://cxhterify3l" path="res://Assets/Images/goal.png" id="3_4pkmo"] [ext_resource type="PackedScene" uid="uid://c1mvbh2fwqtkb" path="res://Nodes/car.tscn" id="5_vbxx6"] +[ext_resource type="Texture2D" uid="uid://bcn7tgs6a4fm7" path="res://Assets/road.png" id="6_5wji0"] [ext_resource type="Script" path="res://Scripts/drawing.gd" id="6_6cnd6"] +[ext_resource type="Script" path="res://Scripts/Road.gd" id="7_53orf"] [ext_resource type="Texture2D" uid="uid://bsadcfl3o65wb" path="res://Assets/Images/start.png" id="7_oyh3d"] [ext_resource type="PackedScene" uid="uid://wkfai2lvnp7n" path="res://Nodes/checkpoint.tscn" id="8_8dt61"] [ext_resource type="TileSet" uid="uid://cl8153posdeim" path="res://Assets/grass_tile_set.tres" id="8_dcy0l"] @@ -33,15 +35,23 @@ shape = SubResource("CircleShape2D_6g88q") [node name="DrawNode" type="Node2D" parent="."] script = ExtResource("6_6cnd6") -[node name="TrackLine" type="Line2D" parent="DrawNode"] -default_color = Color(0.870588, 0.870588, 0.870588, 0.431373) - [node name="TrackPath" type="Path2D" parent="DrawNode"] curve = SubResource("Curve2D_0exre") [node name="TrackFollower" type="PathFollow2D" parent="DrawNode/TrackPath"] loop = false +[node name="TrackLine" type="Line2D" parent="DrawNode"] +texture_repeat = 2 +width = 70.0 +texture = ExtResource("6_5wji0") +texture_mode = 1 +script = ExtResource("7_53orf") + +[node name="LeftBorder" type="Line2D" parent="DrawNode/TrackLine"] + +[node name="RightBorder" type="Line2D" parent="DrawNode/TrackLine"] + [node name="Checkpoints" type="Node" parent="."] [node name="Checkpoint" parent="Checkpoints" instance=ExtResource("8_8dt61")] diff --git a/Levels/Tut01.tscn b/Levels/Tut01.tscn index 0fbcfda..1665673 100644 --- a/Levels/Tut01.tscn +++ b/Levels/Tut01.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=11 format=3 uid="uid://bp56skqd5gqub"] +[gd_scene load_steps=13 format=3 uid="uid://bp56skqd5gqub"] [ext_resource type="Script" path="res://Scripts/scene_control.gd" id="1_lcu5v"] [ext_resource type="PackedScene" uid="uid://c8r6i3bu37ogu" path="res://Nodes/ui.tscn" id="2_44idh"] @@ -6,6 +6,8 @@ [ext_resource type="Texture2D" uid="uid://cxhterify3l" path="res://Assets/Images/goal.png" id="4_mfiv7"] [ext_resource type="PackedScene" uid="uid://c1mvbh2fwqtkb" path="res://Nodes/car.tscn" id="5_mi6tb"] [ext_resource type="Script" path="res://Scripts/drawing.gd" id="6_0pqvb"] +[ext_resource type="Script" path="res://Scripts/Road.gd" id="7_d0og5"] +[ext_resource type="Texture2D" uid="uid://bcn7tgs6a4fm7" path="res://Assets/road.png" id="7_w2gmt"] [ext_resource type="TileSet" uid="uid://cl8153posdeim" path="res://Assets/grass_tile_set.tres" id="8_wphs7"] [sub_resource type="CircleShape2D" id="CircleShape2D_6g88q"] @@ -53,9 +55,15 @@ z_index = 3 script = ExtResource("6_0pqvb") [node name="TrackLine" type="Line2D" parent="DrawNode"] -z_index = 1 -points = PackedVector2Array(1636, 177) -default_color = Color(0.870588, 0.870588, 0.870588, 0.431373) +texture_repeat = 2 +width = 70.0 +texture = ExtResource("7_w2gmt") +texture_mode = 1 +script = ExtResource("7_d0og5") + +[node name="LeftBorder" type="Line2D" parent="DrawNode/TrackLine"] + +[node name="RightBorder" type="Line2D" parent="DrawNode/TrackLine"] [node name="TrackPath" type="Path2D" parent="DrawNode"] curve = SubResource("Curve2D_0exre") diff --git a/Levels/Tut02.tscn b/Levels/Tut02.tscn index 915167e..1fbe1a9 100644 --- a/Levels/Tut02.tscn +++ b/Levels/Tut02.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=11 format=3 uid="uid://ccgojoehaouv0"] +[gd_scene load_steps=13 format=3 uid="uid://ccgojoehaouv0"] [ext_resource type="Script" path="res://Scripts/scene_control.gd" id="1_77i7n"] [ext_resource type="PackedScene" uid="uid://c8r6i3bu37ogu" path="res://Nodes/ui.tscn" id="2_wchsl"] @@ -6,6 +6,8 @@ [ext_resource type="Texture2D" uid="uid://cxhterify3l" path="res://Assets/Images/goal.png" id="4_yklwl"] [ext_resource type="PackedScene" uid="uid://c1mvbh2fwqtkb" path="res://Nodes/car.tscn" id="5_h0kjy"] [ext_resource type="Script" path="res://Scripts/drawing.gd" id="6_0m5bn"] +[ext_resource type="Texture2D" uid="uid://bcn7tgs6a4fm7" path="res://Assets/road.png" id="7_iioy2"] +[ext_resource type="Script" path="res://Scripts/Road.gd" id="8_1xa7f"] [ext_resource type="TileSet" uid="uid://cl8153posdeim" path="res://Assets/grass_tile_set.tres" id="8_a1rvy"] [sub_resource type="CircleShape2D" id="CircleShape2D_6g88q"] @@ -49,16 +51,23 @@ z_index = 3 [node name="DrawNode" type="Node2D" parent="."] script = ExtResource("6_0m5bn") -[node name="TrackLine" type="Line2D" parent="DrawNode"] -z_index = 1 -default_color = Color(0.870588, 0.870588, 0.870588, 0.431373) - [node name="TrackPath" type="Path2D" parent="DrawNode"] curve = SubResource("Curve2D_0exre") [node name="TrackFollower" type="PathFollow2D" parent="DrawNode/TrackPath"] loop = false +[node name="TrackLine" type="Line2D" parent="DrawNode"] +texture_repeat = 2 +width = 70.0 +texture = ExtResource("7_iioy2") +texture_mode = 1 +script = ExtResource("8_1xa7f") + +[node name="LeftBorder" type="Line2D" parent="DrawNode/TrackLine"] + +[node name="RightBorder" type="Line2D" parent="DrawNode/TrackLine"] + [node name="Checkpoints" type="Node" parent="."] [node name="Control" type="Control" parent="."] diff --git a/Levels/Tut03.tscn b/Levels/Tut03.tscn index 862725f..8085194 100644 --- a/Levels/Tut03.tscn +++ b/Levels/Tut03.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=12 format=3 uid="uid://ceoxn74ev4wui"] +[gd_scene load_steps=14 format=3 uid="uid://ceoxn74ev4wui"] [ext_resource type="Script" path="res://Scripts/scene_control.gd" id="1_6ktyo"] [ext_resource type="PackedScene" uid="uid://c8r6i3bu37ogu" path="res://Nodes/ui.tscn" id="2_cbrmn"] @@ -6,8 +6,10 @@ [ext_resource type="Texture2D" uid="uid://cxhterify3l" path="res://Assets/Images/goal.png" id="4_a601a"] [ext_resource type="PackedScene" uid="uid://c1mvbh2fwqtkb" path="res://Nodes/car.tscn" id="5_hgfxg"] [ext_resource type="Script" path="res://Scripts/drawing.gd" id="6_uikm8"] +[ext_resource type="Texture2D" uid="uid://bcn7tgs6a4fm7" path="res://Assets/road.png" id="7_wag28"] [ext_resource type="TileSet" uid="uid://cl8153posdeim" path="res://Assets/grass_tile_set.tres" id="8_1mcey"] [ext_resource type="PackedScene" uid="uid://wkfai2lvnp7n" path="res://Nodes/checkpoint.tscn" id="8_7nfp6"] +[ext_resource type="Script" path="res://Scripts/Road.gd" id="8_st1kl"] [sub_resource type="CircleShape2D" id="CircleShape2D_6g88q"] radius = 17.0 @@ -48,15 +50,23 @@ z_index = 3 [node name="DrawNode" type="Node2D" parent="."] script = ExtResource("6_uikm8") -[node name="TrackLine" type="Line2D" parent="DrawNode"] -default_color = Color(0.870588, 0.870588, 0.870588, 0.431373) - [node name="TrackPath" type="Path2D" parent="DrawNode"] curve = SubResource("Curve2D_0exre") [node name="TrackFollower" type="PathFollow2D" parent="DrawNode/TrackPath"] loop = false +[node name="TrackLine" type="Line2D" parent="DrawNode"] +texture_repeat = 2 +width = 70.0 +texture = ExtResource("7_wag28") +texture_mode = 1 +script = ExtResource("8_st1kl") + +[node name="LeftBorder" type="Line2D" parent="DrawNode/TrackLine"] + +[node name="RightBorder" type="Line2D" parent="DrawNode/TrackLine"] + [node name="Checkpoints" type="Node" parent="."] [node name="Checkpoint" parent="Checkpoints" instance=ExtResource("8_7nfp6")] diff --git a/Scripts/Road.gd b/Scripts/Road.gd index 4b19c70..db60c7d 100644 --- a/Scripts/Road.gd +++ b/Scripts/Road.gd @@ -80,3 +80,7 @@ func draw_borders(): leftBorder.add_point(point) point = points[pointIndex] - (normal*50) rightBorder.add_point(point) + +func clear_borders(): + leftBorder.clear_points() + rightBorder.clear_points() diff --git a/Scripts/drawing.gd b/Scripts/drawing.gd index 6b94f6e..612ba60 100644 --- a/Scripts/drawing.gd +++ b/Scripts/drawing.gd @@ -2,7 +2,7 @@ extends Node var drawing = false -@onready var line = $Road +@onready var line = $TrackLine @onready var path: Path2D = $TrackPath func _ready(): @@ -34,4 +34,5 @@ func _input(event): func reset(): line.clear_points() + line.clear_borders() path.curve.clear_points() -- cgit