From f977fc5a19ba8e315a2482ad8f99749422c2f83a Mon Sep 17 00:00:00 2001 From: perivesta <> Date: Sun, 9 Jul 2023 17:40:17 +0200 Subject: Revert "merge branch 'curve-smoothing'" This reverts commit fd37d1030f79705fc7a2498bcd356ebc86462544, reversing changes made to 12c65d9ed4447a60b26b952fdfc397f45be2ca72. --- Assets/road.png | Bin 252 -> 0 bytes Assets/road.png.import | 34 -------------------- Scripts/Road.gd | 82 ------------------------------------------------- Scripts/drawing.gd | 6 +--- 4 files changed, 1 insertion(+), 121 deletions(-) delete mode 100644 Assets/road.png delete mode 100644 Assets/road.png.import delete mode 100644 Scripts/Road.gd diff --git a/Assets/road.png b/Assets/road.png deleted file mode 100644 index 5acc2e9..0000000 Binary files a/Assets/road.png and /dev/null differ diff --git a/Assets/road.png.import b/Assets/road.png.import deleted file mode 100644 index 59a81a8..0000000 --- a/Assets/road.png.import +++ /dev/null @@ -1,34 +0,0 @@ -[remap] - -importer="texture" -type="CompressedTexture2D" -uid="uid://bcn7tgs6a4fm7" -path="res://.godot/imported/road.png-c3c47e2cc8c90beae2ad5c8a3bb2c3ca.ctex" -metadata={ -"vram_texture": false -} - -[deps] - -source_file="res://Assets/road.png" -dest_files=["res://.godot/imported/road.png-c3c47e2cc8c90beae2ad5c8a3bb2c3ca.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/Scripts/Road.gd b/Scripts/Road.gd deleted file mode 100644 index 4b19c70..0000000 --- a/Scripts/Road.gd +++ /dev/null @@ -1,82 +0,0 @@ -extends Line2D - -var epsilon = 2 - -@onready var leftBorder = $LeftBorder -@onready var rightBorder = $RightBorder - -# Called when the node enters the scene tree for the first time. -func _ready(): - pass # Replace with function body. - -# Called every frame. 'delta' is the elapsed time since the previous frame. -func _process(delta): - pass - -func simplify(): - points = simplify_rec(points, epsilon) - -func simplify_rec(pointArray: PackedVector2Array, epsilon: float): - var dmax = 0 - var index = -1 - if pointArray.size() < 3: - return pointArray - var end = pointArray.size() - 1 - for i in range(1, end-1): - var d = find_perpendicular_distance(pointArray[i], pointArray[0], pointArray[end]) - if d > dmax: - index = i - dmax = d - - if dmax > epsilon: - var recResults1 = simplify_rec(pointArray.slice(0, index), epsilon) - var recResults2 = simplify_rec(pointArray.slice(index, end), epsilon) - recResults1.append_array(recResults2) - return recResults1 - else: - return [pointArray[0], pointArray[end]] - -func find_perpendicular_distance(p: Vector2, p1: Vector2, p2: Vector2): - var result - var slope - var intercept - if p1.x == p2.x: - result = p.x - p1.x - else: - slope = (p2.y - p1.y) / (p2.x - p1.x) - intercept = p1.y - (slope * p1.x) - result = abs(slope * p.x - p.y + intercept) / sqrt(pow(slope, 2) + 1) - - return result - -func get_bisector(left_side: bool, p2: Vector2, p1: Vector2 = p2, p3: Vector2 = p2): - var v1 = (p2 - p1).normalized() - var v2 = (p2 - p3).normalized() - var normal - if v1 == -v2: - normal = v2.rotated(-PI/2) - else: - normal = (v1 + v2).normalized() - if v2.rotated(-PI/2).dot(v1) < 0: - normal = -normal - - if left_side: - normal = -normal - return normal - - -func draw_borders(): - for pointIndex in range(0, points.size() - 1): - var normal - if pointIndex == 0: - continue - elif pointIndex == points.size() -1: - continue - #normal = Vector2.ZERO - else: - normal = get_bisector(true, points[pointIndex], points[pointIndex-1], points[pointIndex+1]) - - var point = points[pointIndex] + (normal*50) - leftBorder.add_point(point) - point = points[pointIndex] - (normal*50) - rightBorder.add_point(point) diff --git a/Scripts/drawing.gd b/Scripts/drawing.gd index 6b94f6e..832c42d 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: Line2D = $TrackLine @onready var path: Path2D = $TrackPath func _ready(): @@ -16,10 +16,6 @@ func start_drawing(): func _end_drawing(): drawing = false - line.simplify() - line.draw_borders() - for point in line.points: - path.curve.add_point(point) owner.set_driving(true) -- cgit From a9c6a7cf69010079139ae7942bdff5dac450c827 Mon Sep 17 00:00:00 2001 From: IcECreAm777 Date: Sun, 9 Jul 2023 17:43:27 +0200 Subject: level names --- Levels/Level1.tscn | 21 ++++++++++++++++++++- Levels/Level2.tscn | 21 ++++++++++++++++++++- Levels/Level3.tscn | 21 ++++++++++++++++++++- Levels/Tut01.tscn | 9 +++++++++ Levels/Tut02.tscn | 9 +++++++++ Levels/Tut03.tscn | 9 +++++++++ Nodes/driving_test.tscn | 2 +- Nodes/ui.tscn | 3 +-- 8 files changed, 89 insertions(+), 6 deletions(-) diff --git a/Levels/Level1.tscn b/Levels/Level1.tscn index d896692..3bd097a 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=13 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"] @@ -15,6 +15,10 @@ radius = 17.0 [sub_resource type="Curve2D" id="Curve2D_0exre"] +[sub_resource type="LabelSettings" id="LabelSettings_ux08a"] +outline_size = 3 +outline_color = Color(0, 0, 0, 1) + [node name="Level_test" type="Node2D"] script = ExtResource("1_jvdy8") silver_medal_time = 6.0 @@ -97,4 +101,19 @@ layer_1/tile_data = PackedInt32Array(2424836, 131072, 8, 2424837, 131072, 8, 242 build_mode = 1 polygon = PackedVector2Array(964, 570, 845, 570, 835, 586, 765, 585, 740, 616, 594, 618, 580, 602, 462, 601, 449, 617, 257, 618, 244, 601, 225, 602, 211, 586, 124, 585, 115, 599, 49, 602, 40, 595, 38, 573, 24, 561, 23, 538, 38, 535, 39, 509, 54, 501, 54, 364, 39, 351, 38, 318, 23, 304, 22, 284, 36, 278, 38, 173, 24, 163, 23, 123, 35, 118, 44, 105, 57, 101, 54, 58, 68, 54, 82, 54, 92, 39, 196, 38, 203, 53, 277, 53, 283, 68, 454, 70, 460, 56, 484, 54, 494, 38, 581, 38, 586, 51, 660, 53, 667, 69, 724, 70, 732, 55, 756, 54, 763, 39, 801, 37, 815, 55, 828, 39, 897, 37, 922, 68, 980, 71, 987, 84, 1075, 86, 1111, 122, 1113, 148, 1129, 155, 1130, 205, 1115, 220, 1115, 256, 1099, 268, 1097, 322, 1111, 331, 1113, 385, 1096, 396, 1098, 419, 1113, 427, 1115, 481, 1099, 491, 1099, 571, 1089, 585, 1069, 583, 1059, 600, 1011, 603, 996, 585, 978, 585) +[node name="Control" type="Control" parent="."] +layout_mode = 3 +anchors_preset = 0 +offset_left = 1014.0 +offset_top = 29.0 +offset_right = 1054.0 +offset_bottom = 69.0 + +[node name="Label" type="Label" parent="Control"] +layout_mode = 0 +offset_right = 63.0 +offset_bottom = 26.0 +text = "Level 01" +label_settings = SubResource("LabelSettings_ux08a") + [connection signal="mouse_entered" from="FinishLine/Area2D" to="DrawNode" method="_end_drawing"] diff --git a/Levels/Level2.tscn b/Levels/Level2.tscn index f2da4e1..812749e 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=12 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"] @@ -14,6 +14,10 @@ radius = 17.0 [sub_resource type="Curve2D" id="Curve2D_0exre"] +[sub_resource type="LabelSettings" id="LabelSettings_yc6jr"] +outline_size = 3 +outline_color = Color(0, 0, 0, 1) + [node name="Level_test2" type="Node2D"] script = ExtResource("1_hjw4x") gold_medal_time = 5.1 @@ -97,4 +101,19 @@ position = Vector2(-1, 7) build_mode = 1 polygon = PackedVector2Array(521, 175, 528, 156, 611, 160, 620, 174, 642, 175, 651, 189, 695, 209, 694, 239, 710, 241, 710, 286, 727, 292, 729, 328, 710, 339, 717, 409, 696, 420, 697, 440, 682, 454, 677, 475, 658, 498, 606, 497, 597, 480, 576, 479, 567, 464, 547, 468, 535, 452, 517, 433, 474, 433, 472, 402, 455, 395, 456, 371, 441, 366, 440, 342, 424, 332, 429, 308, 441, 299, 443, 235, 463, 210, 478, 186, 504, 190) +[node name="Control" type="Control" parent="."] +layout_mode = 3 +anchors_preset = 0 +offset_left = 1010.0 +offset_top = 31.0 +offset_right = 1050.0 +offset_bottom = 71.0 + +[node name="Label" type="Label" parent="Control"] +layout_mode = 0 +offset_right = 63.0 +offset_bottom = 26.0 +text = "Level 02" +label_settings = SubResource("LabelSettings_yc6jr") + [connection signal="mouse_entered" from="FinishLine/Area2D" to="DrawNode" method="_end_drawing"] diff --git a/Levels/Level3.tscn b/Levels/Level3.tscn index 344f7ee..689ec11 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=12 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"] @@ -14,6 +14,10 @@ radius = 17.0 [sub_resource type="Curve2D" id="Curve2D_0exre"] +[sub_resource type="LabelSettings" id="LabelSettings_4hqyx"] +outline_size = 3 +outline_color = Color(0, 0, 0, 1) + [node name="Level_test2" type="Node2D"] script = ExtResource("1_iao1p") gold_medal_time = 6.0 @@ -109,4 +113,19 @@ position = Vector2(-1, 7) build_mode = 1 polygon = PackedVector2Array(618, 147, 618, 353, 659, 353, 669, 340, 683, 324, 698, 318, 698, 291, 717, 278, 713, 263, 730, 249, 730, 198, 701, 179, 694, 163, 670, 160, 656, 145) +[node name="Control" type="Control" parent="."] +layout_mode = 3 +anchors_preset = 0 +offset_left = 1014.0 +offset_top = 29.0 +offset_right = 1054.0 +offset_bottom = 69.0 + +[node name="Label" type="Label" parent="Control"] +layout_mode = 0 +offset_right = 63.0 +offset_bottom = 26.0 +text = "Level 03" +label_settings = SubResource("LabelSettings_4hqyx") + [connection signal="mouse_entered" from="FinishLine/Area2D" to="DrawNode" method="_end_drawing"] diff --git a/Levels/Tut01.tscn b/Levels/Tut01.tscn index 0fbcfda..8cb12d0 100644 --- a/Levels/Tut01.tscn +++ b/Levels/Tut01.tscn @@ -83,6 +83,15 @@ offset_bottom = 466.0 text = "Click here to start drawing the road" label_settings = SubResource("LabelSettings_sv8of") +[node name="Label5" type="Label" parent="Control"] +layout_mode = 0 +offset_left = 963.0 +offset_top = 24.0 +offset_right = 1237.0 +offset_bottom = 50.0 +text = "Tutorial 01" +label_settings = SubResource("LabelSettings_sv8of") + [node name="Label4" type="RichTextLabel" parent="Control"] layout_mode = 0 offset_left = 127.0 diff --git a/Levels/Tut02.tscn b/Levels/Tut02.tscn index 915167e..2d95719 100644 --- a/Levels/Tut02.tscn +++ b/Levels/Tut02.tscn @@ -79,6 +79,15 @@ offset_bottom = 236.0 text = "Sand is off limits and the car won't go there" label_settings = SubResource("LabelSettings_sv8of") +[node name="Label2" type="Label" parent="Control"] +layout_mode = 0 +offset_left = 961.0 +offset_top = 21.0 +offset_right = 1296.0 +offset_bottom = 47.0 +text = "Tutorial 02" +label_settings = SubResource("LabelSettings_sv8of") + [node name="TileMap" type="TileMap" parent="."] z_index = -1 tile_set = ExtResource("8_a1rvy") diff --git a/Levels/Tut03.tscn b/Levels/Tut03.tscn index 862725f..a64f3de 100644 --- a/Levels/Tut03.tscn +++ b/Levels/Tut03.tscn @@ -79,6 +79,15 @@ offset_bottom = 145.0 text = "You need to include every checkpoint to make the race count." label_settings = SubResource("LabelSettings_sv8of") +[node name="Label2" type="Label" parent="Control"] +layout_mode = 0 +offset_left = 943.0 +offset_top = 27.0 +offset_right = 1420.0 +offset_bottom = 53.0 +text = "Tutorial 03" +label_settings = SubResource("LabelSettings_sv8of") + [node name="TileMap" type="TileMap" parent="."] z_index = -1 tile_set = ExtResource("8_1mcey") diff --git a/Nodes/driving_test.tscn b/Nodes/driving_test.tscn index 86964c5..15e6af6 100644 --- a/Nodes/driving_test.tscn +++ b/Nodes/driving_test.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=5 format=3 uid="uid://b205qlgjrpeqi"] +[gd_scene load_steps=5 format=3 uid="uid://13ynwilqep0f"] [ext_resource type="Script" path="res://Scripts/scene_control.gd" id="1_eopk0"] [ext_resource type="PackedScene" uid="uid://cqglbcitm2wlb" path="res://Nodes/simple_wall.tscn" id="1_o5f4t"] diff --git a/Nodes/ui.tscn b/Nodes/ui.tscn index 877dcf0..aa40214 100644 --- a/Nodes/ui.tscn +++ b/Nodes/ui.tscn @@ -252,7 +252,6 @@ text = "Time: " label_settings = SubResource("LabelSettings_cg3a3") [node name="PostGameUI" type="Panel" parent="Control"] -visible = false layout_mode = 1 anchors_preset = 15 anchor_right = 1.0 @@ -280,7 +279,7 @@ anchor_left = 0.3 anchor_top = 0.3 anchor_right = 0.5 anchor_bottom = 0.3 -offset_right = 10.0 +offset_right = -10.0 offset_bottom = 23.0 scale = Vector2(1, 1.02025) text = "Final Time:" -- cgit From e789ce08fed7a1b1023c411a7661bac6c8b0fa30 Mon Sep 17 00:00:00 2001 From: perivesta <> Date: Sun, 9 Jul 2023 17:49:03 +0200 Subject: smal fix --- .gitignore | 3 +++ Nodes/ui.tscn | 1 + 2 files changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index 4709183..df79fb1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ # Godot 4+ specific ignores .godot/ + +.build/ +.export_presets.cfg diff --git a/Nodes/ui.tscn b/Nodes/ui.tscn index aa40214..fb68989 100644 --- a/Nodes/ui.tscn +++ b/Nodes/ui.tscn @@ -252,6 +252,7 @@ text = "Time: " label_settings = SubResource("LabelSettings_cg3a3") [node name="PostGameUI" type="Panel" parent="Control"] +visible = false layout_mode = 1 anchors_preset = 15 anchor_right = 1.0 -- cgit