From 82bfc1d184f0f5b0025db29f516ffac73fbe17cd Mon Sep 17 00:00:00 2001 From: Fisch Date: Wed, 4 Dec 2024 16:30:43 +0100 Subject: [PATCH] tried adding guide lines --- project.godot | 2 +- scenes/map_03.tscn | 4 +- scenes/map_04.tscn | 117 +++++++++++++----- scripts/car.gd | 24 ++-- scripts/line_2d_collision.gd | 14 +++ ...d_to_collisionpolygon.gd => roadborder.gd} | 0 6 files changed, 115 insertions(+), 46 deletions(-) create mode 100644 scripts/line_2d_collision.gd rename scripts/{line2d_to_collisionpolygon.gd => roadborder.gd} (100%) diff --git a/project.godot b/project.godot index 43cce65..300a00a 100644 --- a/project.godot +++ b/project.godot @@ -28,7 +28,7 @@ window/stretch/mode="canvas_items" 2d_physics/layer_1="walls" 2d_physics/layer_2="walldetection" 2d_physics/layer_3="Marking" -2d_physics/layer_4="Layer 4" +2d_physics/layer_4="roadguide" [rendering] diff --git a/scenes/map_03.tscn b/scenes/map_03.tscn index 53baa94..3a50e4b 100644 --- a/scenes/map_03.tscn +++ b/scenes/map_03.tscn @@ -6,7 +6,7 @@ [ext_resource type="TileSet" uid="uid://carpfxq3rn3aa" path="res://sprites/spritesheet_htrohr/htrohr.tres" id="5_748hi"] [ext_resource type="Texture2D" uid="uid://dpuhee0x5ekud" path="res://sprites/background/spritesheet_scenery.png" id="5_lefrm"] -[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_qbu02"] +[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_fam2n"] texture = ExtResource("1_8lp8c") texture_region_size = Vector2i(256, 256) 0:0/0 = 0 @@ -44,7 +44,7 @@ texture_region_size = Vector2i(256, 256) [sub_resource type="TileSet" id="TileSet_5knbn"] tile_size = Vector2i(256, 256) -sources/1 = SubResource("TileSetAtlasSource_qbu02") +sources/1 = SubResource("TileSetAtlasSource_fam2n") [sub_resource type="RectangleShape2D" id="RectangleShape2D_daqun"] size = Vector2(23, 317) diff --git a/scenes/map_04.tscn b/scenes/map_04.tscn index b02a6dd..1c1a58f 100644 --- a/scenes/map_04.tscn +++ b/scenes/map_04.tscn @@ -1,15 +1,15 @@ [gd_scene load_steps=17 format=4 uid="uid://dji2ku3464aus"] [ext_resource type="Texture2D" uid="uid://bu05e161cb61k" path="res://sprites/background/spritesheet_bg.png" id="1_m3cjb"] -[ext_resource type="TileSet" uid="uid://beswbm12qkkxk" path="res://sprites/spritesheet_road/bg_road.tres" id="2_u1rh5"] [ext_resource type="TileSet" uid="uid://buu8w8n61kbxf" path="res://sprites/spritesheet_road/markings.tres" id="3_xmt4t"] +[ext_resource type="Texture2D" uid="uid://f07emh5nd432" path="res://upload_90656c517c9d3b6045c12e343446b97c.png" id="3_ytr3a"] [ext_resource type="Texture2D" uid="uid://cvkrjllwsen6r" path="res://sprites/htrohr/ht_rohr.png" id="4_46p8j"] [ext_resource type="Texture2D" uid="uid://dpuhee0x5ekud" path="res://sprites/background/spritesheet_scenery.png" id="5_unub2"] -[ext_resource type="Script" path="res://scripts/line2d_to_collisionpolygon.gd" id="6_50nf2"] +[ext_resource type="Script" path="res://scripts/roadborder.gd" id="6_50nf2"] [ext_resource type="Texture2D" uid="uid://bal4r8rnh38dx" path="res://sprites/htrohr/ht_rohr_fitting.png" id="6_lu60n"] [ext_resource type="Texture2D" uid="uid://b0h14qq3jgbcw" path="res://sprites/htrohr/weights.png" id="7_7xqft"] -[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_qbu02"] +[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_hemvv"] texture = ExtResource("1_m3cjb") texture_region_size = Vector2i(256, 256) 0:0/0 = 0 @@ -45,21 +45,21 @@ texture_region_size = Vector2i(256, 256) 6:3/0 = 0 7:3/0 = 0 -[sub_resource type="TileSet" id="TileSet_5knbn"] +[sub_resource type="TileSet" id="TileSet_8cocw"] tile_size = Vector2i(256, 256) -sources/1 = SubResource("TileSetAtlasSource_qbu02") +sources/1 = SubResource("TileSetAtlasSource_hemvv") [sub_resource type="RectangleShape2D" id="RectangleShape2D_daqun"] -size = Vector2(23, 222) +size = Vector2(23, 327) [sub_resource type="RectangleShape2D" id="RectangleShape2D_dltky"] -size = Vector2(19, 108) +size = Vector2(57.5, 211) [sub_resource type="RectangleShape2D" id="RectangleShape2D_uys5r"] -size = Vector2(20, 126) +size = Vector2(35, 194) [sub_resource type="RectangleShape2D" id="RectangleShape2D_82iti"] -size = Vector2(20, 231) +size = Vector2(53, 112) [sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_hclam"] texture = ExtResource("5_unub2") @@ -196,63 +196,107 @@ sources/0 = SubResource("TileSetAtlasSource_hclam") [node name="Map" type="Node"] [node name="Background" type="TileMapLayer" parent="."] -tile_map_data = PackedByteArray("AAD+/wEAAQAAAAAAAAD+/wAAAQAAAAAAAAD+////AQAAAAAAAAD+//7/AQABAAAAAAD///7/AQAAAAAAAAD///3/AQAAAAAAAAAAAP3/AQAAAAAAAAD+//3/AQABAAAAAAABAP3/AQAAAAAAAAACAP3/AQAAAAAAAAADAP3/AQABAAAAAAADAP7/AQAAAAAAAAAEAP7/AQAAAAAAAAACAP7/AQAAAAAAAAABAP7/AQAAAAAAAAAAAP7/AQAAAAAAAAAAAP//AQAAAAAAAAD/////AQAAAAAAAAABAP//AQAAAAAAAAACAP//AQAAAAAAAAADAP//AQAAAAAAAAAEAP//AQAAAAAAAAAEAAAAAQAAAAAAAAADAAAAAQABAAAAAAACAAAAAQAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAQAAAAAAAAD//wAAAQAAAAAAAAD//wEAAQAAAAAAAAAAAAEAAQAAAAAAAAABAAEAAQAAAAAAAAACAAEAAQAAAAAAAAADAAEAAQAAAAAAAAAEAAEAAQABAAAAAAAEAP3/AQABAAAAAAA=") -tile_set = SubResource("TileSet_5knbn") +scale = Vector2(0.5, 0.5) +tile_map_data = PackedByteArray("AAD7//v/AQACAAAAAAD8//v/AQAEAAAAAFD9//v/AQACAAAAAAD+//v/AQACAAAAAAD///v/AQAEAAAAAFAAAPv/AQACAAAAAAABAPv/AQACAAAAAAACAPv/AQAEAAAAAHADAPz/AQACAAAAAAACAPz/AQACAAAAAAABAPz/AQACAAAAAAAAAPz/AQADAAAAAAD///z/AQACAAAAAAD6//r/AQACAAAAAGD6//v/AQACAAAAAGD6//z/AQACAAAAAGD6//3/AQACAAAAAHD6//7/AQADAAAAAGD6////AQACAAAAAGD6/wAAAQACAAAAAGD6/wEAAQACAAAAAAD7//r/AQACAAAAADD7//z/AQACAAAAAGD7//3/AQACAAAAACD7//7/AQACAAAAADD7////AQACAAAAAGD7/wAAAQACAAAAAAD7/wEAAQACAAAAAAD8//r/AQAEAAAAAFD8//z/AQADAAAAAFD8//3/AQAEAAAAAHD8//7/AQAEAAAAAHD8////AQAEAAAAAHD8/wAAAQAEAAAAAHD8/wEAAQAEAAAAAFD9//r/AQACAAAAAGD9//z/AQACAAAAAAD9//3/AQACAAAAAHD9//7/AQACAAAAAGD9////AQACAAAAAAD9/wAAAQACAAAAAAD9/wEAAQACAAAAAAD+//r/AQADAAAAAGD+//z/AQADAAAAAAD+//3/AQACAAAAACD+//7/AQADAAAAAAD+////AQACAAAAAFD+/wAAAQACAAAAAAD+/wEAAQACAAAAAAD///r/AQAEAAAAAHD///3/AQAEAAAAAFD///7/AQAEAAAAAHD/////AQAEAAAAAHD//wAAAQAEAAAAAFD//wEAAQAEAAAAAHAAAPr/AQACAAAAAAAAAP3/AQACAAAAAEAAAP7/AQACAAAAAAAAAP//AQACAAAAAAAAAAAAAQACAAAAAAAAAAEAAQACAAAAAAABAPr/AQACAAAAAGABAP3/AQACAAAAAFABAP7/AQACAAAAAAABAP//AQACAAAAAAABAAAAAQACAAAAADABAAEAAQACAAAAAAACAPr/AQAEAAAAAHACAP3/AQAEAAAAAHACAP7/AQAEAAAAAHACAP//AQAEAAAAAFACAAAAAQAEAAAAAFACAAEAAQAEAAAAAHADAPr/AQACAAAAADADAPv/AQACAAAAAAADAP3/AQACAAAAAFADAP7/AQACAAAAADADAP//AQADAAAA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/AQACAAAAAAD1//n/AQACAAAAADD1//r/AQACAAAAADD1//v/AQACAAAAAAD1//z/AQACAAAAAAD1//3/AQACAAAAAHD1//7/AQACAAAAAHD1////AQACAAAAAAD1/wAAAQACAAAAAAD1/wEAAQACAAAAAFD2//b/AQACAAAAAFD2//f/AQACAAAAAFD2//j/AQACAAAAADD2//n/AQACAAAAADD2//r/AQACAAAAAAD2//v/AQACAAAAAFD2//z/AQACAAAAADD2//3/AQACAAAAAHD2//7/AQACAAAAAAD2////AQACAAAAADD2/wAAAQACAAAAAAD2/wEAAQACAAAAAAD3//b/AQACAAAAAAD3//f/AQACAAAAAAD3//j/AQACAAAAAAD3//n/AQACAAAAAAD3//r/AQACAAAAAAD3//v/AQACAAAAAAD3//z/AQACAAAAADD3//3/AQACAAAAAHD3//7/AQACAAAAADD3////AQACAAAAADD3/wAAAQACAAAAAAD3/wEAAQACAAAAAAD4//b/AQACAAAAAAD4//f/AQACAAAAADD4//j/AQACAAAAAAD4//n/AQACAAAAAAD4//r/AQACAAAAAAD4//v/AQACAAAAAAD4//z/AQACAAAAAAD4//3/AQACAAAAAHD4//7/AQACAAAAAAD4////AQACAAAAADD4/wAAAQACAAAAAAD4/wEAAQACAAAAAAD5//b/AQACAAAAAAD5//f/AQAEAAAAAFD5//j/AQAEAAAAAFD5//n/AQAEAAAAAFD5//r/AQAEAAAAAHD5//v/AQAEAAAAAFD5//z/AQACAAAAAFD5//3/AQAEAAAAAHD5//7/AQAEAAAAAFD5////AQAEAAAAAHD5/wAAAQAEAAAAAFD5/wEAAQAEAAAAAFD0//T/AQACAAAAADD0//X/AQACAAAAAAD1//T/AQACAAAAAAD1//X/AQACAAAAADD2//T/AQACAAAAAAD2//X/AQACAAAAAAD3//T/AQACAAAAAAD3//X/AQACAAAAAAD4//T/AQACAAAAAAD4//X/AQACAAAAAAD5//T/AQACAAAAAAD5//X/AQACAAAAAAD6//T/AQACAAAAAAD6//X/AQACAAAAAAD7//T/AQACAAAAAAD7//X/AQACA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QACAAAAAGAIAAIAAQACAAAAAHAIAAMAAQACAAAAAAAJAAIAAQACAAAAAGAJAAMAAQACAAAAAGAKAAIAAQACAAAAAHAKAAMAAQACAAAAAGA=") +tile_set = SubResource("TileSet_8cocw") collision_enabled = false -[node name="road_bg" type="TileMapLayer" parent="."] -tile_set = ExtResource("2_u1rh5") - -[node name="road_bg2" type="TileMapLayer" parent="."] -tile_set = ExtResource("2_u1rh5") - -[node name="road_bg_fixes" type="TileMapLayer" parent="."] -tile_set = ExtResource("2_u1rh5") - [node name="markings" type="TileMapLayer" parent="."] +visible = false z_index = 1 tile_map_data = PackedByteArray("AAAAAAAAAQAAAAAAAFAAAP//AQAAAAAAAHA=") tile_set = ExtResource("3_xmt4t") -[node name="Line2D" type="Line2D" parent="."] +[node name="Upload90656c517c9d3b6045c12e343446b97c" type="Sprite2D" parent="."] +visible = false +position = Vector2(30, -363) +rotation = -3.14159 +scale = Vector2(2.09269, 2.09269) +texture = ExtResource("3_ytr3a") + +[node name="Line2D_right_inside" type="Line2D" parent="."] z_index = 1 texture_filter = 1 -points = PackedVector2Array(-137, 119, 353, 120, 429, 83, 498, 39, 621, 8, 744, 1, 859, -10, 935, -52, 935, -178, 888, -246, 825, -299, 471, -448, 256, -445, 121, -532, -32, -502, -250, -181, -308, -42, -260, 59, -146, 119, -147, 136) +points = PackedVector2Array(-613, -385, -598, -385, -548, -437, 336, -436) width = 8.0 texture = ExtResource("4_46p8j") texture_mode = 1 script = ExtResource("6_50nf2") -[node name="road_r" type="StaticBody2D" parent="Line2D"] +[node name="road_r" type="StaticBody2D" parent="Line2D_right_inside"] collision_layer = 3 -[node name="fitting" type="Sprite2D" parent="Line2D"] +[node name="fitting" type="Sprite2D" parent="Line2D_right_inside"] texture_filter = 1 position = Vector2(259, 120) texture = ExtResource("6_lu60n") -[node name="weight" type="Sprite2D" parent="Line2D"] +[node name="weight" type="Sprite2D" parent="Line2D_right_inside"] texture = ExtResource("7_7xqft") region_enabled = true region_rect = Rect2(32, 0, 32, 32) -[node name="Line2D2" type="Line2D" parent="."] +[node name="Line2D_outer_right" type="Line2D" parent="."] z_index = 1 -points = PackedVector2Array(-97, -109, 236, -111, 298, -107, 370, -83, 452, -64, 517, -82, 661, -85, 745, -98, 784, -149, 784, -228, 466, -384, 295, -358, 207, -356, 143, -399, 106, -433, 58, -433, -177, -159, -203, -92, -176, -55, -80, -127) +texture_filter = 1 +points = PackedVector2Array(112, 128, 433, 60, 954, -659, 943, -775, 856, -851, -686, -853, -768, -769, -770, -544, -609.97, -383.731, -100, 127) +width = 8.0 +texture = ExtResource("4_46p8j") +texture_mode = 1 +script = ExtResource("6_50nf2") + +[node name="road_r" type="StaticBody2D" parent="Line2D_outer_right"] +collision_layer = 3 + +[node name="fitting" type="Sprite2D" parent="Line2D_outer_right"] +texture_filter = 1 +position = Vector2(259, 120) +texture = ExtResource("6_lu60n") + +[node name="weight" type="Sprite2D" parent="Line2D_outer_right"] +texture = ExtResource("7_7xqft") +region_enabled = true +region_rect = Rect2(32, 0, 32, 32) + +[node name="Line2D2_left_inside" type="Line2D" parent="."] +z_index = 1 +points = PackedVector2Array(-154, -319, 178, -318, 259, -237, 378, -237, 694, -552, 611, -633, -488, -633) width = 6.0 texture = ExtResource("4_46p8j") texture_mode = 1 script = ExtResource("6_50nf2") -[node name="road_l" type="StaticBody2D" parent="Line2D2"] +[node name="road_l" type="StaticBody2D" parent="Line2D2_left_inside"] collision_layer = 3 -[node name="fitting" type="Sprite2D" parent="Line2D2"] +[node name="fitting" type="Sprite2D" parent="Line2D2_left_inside"] texture_filter = 1 position = Vector2(259, 120) texture = ExtResource("6_lu60n") -[node name="weight" type="Sprite2D" parent="Line2D2"] +[node name="weight" type="Sprite2D" parent="Line2D2_left_inside"] +texture = ExtResource("7_7xqft") +region_enabled = true +region_rect = Rect2(32, 0, 32, 32) + +[node name="Line2D_rectangle" type="Line2D" parent="."] +z_index = 1 +points = PackedVector2Array(-99, -183, 126, -182, 127, -123, -100, -122, -100, -181) +closed = true +width = 6.0 +texture = ExtResource("4_46p8j") +texture_mode = 1 +script = ExtResource("6_50nf2") + +[node name="road_l" type="StaticBody2D" parent="Line2D_rectangle"] +collision_layer = 3 + +[node name="fitting" type="Sprite2D" parent="Line2D_rectangle"] +texture_filter = 1 +position = Vector2(259, 120) +texture = ExtResource("6_lu60n") + +[node name="weight" type="Sprite2D" parent="Line2D_rectangle"] texture = ExtResource("7_7xqft") region_enabled = true region_rect = Rect2(32, 0, 32, 32) @@ -262,7 +306,7 @@ collision_layer = 4 collision_mask = 4 [node name="CollisionShape2D_Fin" type="CollisionShape2D" parent="area_finish"] -position = Vector2(89.5, -1) +position = Vector2(275, -70.5) shape = SubResource("RectangleShape2D_daqun") [node name="area_cp0" type="Area2D" parent="."] @@ -270,7 +314,7 @@ collision_layer = 4 collision_mask = 4 [node name="CollisionShape2D" type="CollisionShape2D" parent="area_cp0"] -position = Vector2(536, -25) +position = Vector2(565.75, -741.5) shape = SubResource("RectangleShape2D_dltky") [node name="area_cp1" type="Area2D" parent="."] @@ -278,7 +322,7 @@ collision_layer = 4 collision_mask = 4 [node name="CollisionShape2D" type="CollisionShape2D" parent="area_cp1"] -position = Vector2(364, -411) +position = Vector2(-238.5, -535) shape = SubResource("RectangleShape2D_uys5r") [node name="area_cp2" type="Area2D" parent="."] @@ -286,9 +330,14 @@ collision_layer = 4 collision_mask = 4 [node name="CollisionShape2D" type="CollisionShape2D" parent="area_cp2"] -position = Vector2(-123, -283) +position = Vector2(-126.5, -377) shape = SubResource("RectangleShape2D_82iti") +[node name="Line2D_marking" type="Line2D" parent="."] +points = PackedVector2Array(-95, 135, 985, 117, 956, -860, -778, -864, -801, 746) +width = 3.0 +default_color = Color(1, 1, 1, 0.831373) + [node name="scenery" type="TileMapLayer" parent="."] z_index = 20 tile_set = SubResource("TileSet_s6rw7") diff --git a/scripts/car.gd b/scripts/car.gd index 4db1ad2..b16b675 100644 --- a/scripts/car.gd +++ b/scripts/car.gd @@ -81,8 +81,7 @@ var burnout:float=0 #at 0 is off @onready var ray_cast_fl: RayCast2D = $RayCast_FL @onready var ray_cast_fr: RayCast2D = $RayCast_FR -@onready var ray_cast_car_fl: RayCast2D = $RayCast_Car_FL -@onready var ray_cast_car_fr: RayCast2D = $RayCast_Car_FR + @onready var reset_timer: Timer = $resetTimer @@ -175,36 +174,43 @@ func get_input(delta:float): const distance_inf=1000 var distance_fl=distance_inf var distance_fr=distance_inf + var distance_guide_l=0 + var distance_guide_r=0 + if ray_cast_fl.is_colliding(): var origin=ray_cast_fl.global_transform.origin var collision_point = ray_cast_fl.get_collision_point() distance_fl = origin.distance_to(collision_point) var collision_object=ray_cast_fl.get_collider() - #if collision_object.name==ROAD_R_NAME: + if collision_object.name==ROAD_R_NAME: + distance_fl*=2 #fake distance when wrong side of road #print("DistanceFL "+str(distance_fl)) if ray_cast_fr.is_colliding(): var origin=ray_cast_fr.global_transform.origin var collision_point = ray_cast_fr.get_collision_point() distance_fr = origin.distance_to(collision_point) + var collision_object=ray_cast_fr.get_collider() + if collision_object.name==ROAD_L_NAME: + distance_fr*=2 #fake distance when wrong side of road #print("DistanceFR "+str(distance_fr)) + + var distance_min= min(distance_fl,distance_fr) - var turndirection = 1 if distance_fl void: + var staticbody:StaticBody2D=get_child(0) + $".".visible=false + + + var line_poly=Geometry2D.offset_polyline(points,width/2) + + for poly in line_poly: + var col = CollisionPolygon2D.new() + col.polygon=poly + staticbody.add_child(col) diff --git a/scripts/line2d_to_collisionpolygon.gd b/scripts/roadborder.gd similarity index 100% rename from scripts/line2d_to_collisionpolygon.gd rename to scripts/roadborder.gd