diff --git a/scenes/map_03.tscn b/scenes/map_03.tscn index b6f5304..61d2fcc 100644 --- a/scenes/map_03.tscn +++ b/scenes/map_03.tscn @@ -3,7 +3,7 @@ [ext_resource type="Texture2D" uid="uid://bu05e161cb61k" path="res://sprites/background/spritesheet_bg.png" id="1_8lp8c"] [ext_resource type="TileSet" uid="uid://beswbm12qkkxk" path="res://sprites/spritesheet_road/bg_road.tres" id="2_jv1n3"] [ext_resource type="TileSet" uid="uid://buu8w8n61kbxf" path="res://sprites/spritesheet_road/markings.tres" id="3_42xuk"] -[ext_resource type="TileSet" uid="uid://b15864hbqomim" path="res://sprites/spritesheet_road/road.tres" id="4_hpo6d"] +[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"] @@ -214,17 +214,18 @@ tile_map_data = PackedByteArray("AAD7//b/AgAHAAIAAGD4//f/AgAHAAIAAGD3//j/AgAHAAI tile_set = ExtResource("2_jv1n3") [node name="markings" type="TileMapLayer" parent="."] +visible = false z_index = 1 tile_map_data = PackedByteArray("AAAAAAAAAQAAAAAAAFAAAP//AQAAAAAAAHA=") tile_set = ExtResource("3_42xuk") [node name="road_r" type="TileMapLayer" parent="."] -tile_map_data = PackedByteArray("AAD//wAAAgABAAAAAFAAAAAAAgABAAAAAFABAAAAAgABAAAAAFAHAP//AAAGAAIAAFAHAAAAAAAHAAIAAFAGAAAAAAAHAAMAAFAFAPv/AAACAAAAAAAGAPv/AAADAAAAAAAGAPz/AAADAAEAAAAGAP3/AAACAAAAAAAHAP3/AAADAAAAAAAHAP7/AAADAAEAAAACAAAAAgABAAAAAFADAAAAAgABAAAAAFAEAAAAAgABAAAAAFAFAAAAAgABAAAAAFAFAPn/AgADAAAAAAAEAPn/AgADAAAAAGAFAPr/AgABAAAAAAADAPn/AgABAAAAACADAPj/AgABAAAAACADAPf/AgADAAAAAHAAAPf/AgADAAAAABACAPf/AgABAAAAAHABAPf/AgABAAAAAHAAAPj/AgABAAAAABAAAPn/AgABAAAAABAAAPr/AgADAAEAABAEAP3/AAAAAAQAAFADAP3/AAAAAAUAAFADAP7/AAABAAUAAFAAAPv/AgADAAAAAEABAPv/AgABAAAAAEACAPv/AgABAAAAAEADAPv/AgABAAAAAEAEAPv/AgAFAAAAAAAEAPz/AgABAAAAABACAP7/AgAGAAIAAGACAP3/AgAAAAIAACABAPz/AgAAAAIAACABAP3/AgAGAAEAACAAAPz/AgADAAIAAFD///z/AgABAAAAAHD+//z/AgABAAAAAHD9//z/AgADAAAAABD9//3/AgABAAAAADD8//3/AgABAAAAACD8//z/AgABAAAAACD8//v/AgAFAAAAAGD9//v/AgADAAAAACD9//r/AgADAAAAAHD9//7/AgAFAAAAACD8//7/AgAFAAAAADD9//n/AgADAAAAAFD9//j/AgADAAAAAAD8//j/AgAFAAAAAED7//b/AAAGAAIAAAD8//b/AAAHAAIAAAD8//f/AAAHAAMAAAD4//f/AAAHAAMAAGD3//f/AAAHAAIAAGD3//j/AAAGAAIAAGD6//b/AAADAAEAAGD5//b/AAADAAAAAGD5//f/AAACAAAAAGD8//r/AgAFAAAAADD8//n/AgAFAAAAABD3//n/AgABAAAAADD3//r/AgADAAEAADD3//v/AgADAAIAACD3//z/AgAAAAIAAFD4//z/AgAGAAIAABD4//3/AgABAAAAADD4//7/AgABAAAAADD4////AgABAAAAADD4/wAAAgADAAAAADD5/wAAAgABAAAAAFD6/wAAAgABAAAAAFD7/wAAAgABAAAAAFD8/wAAAgABAAAAAFD9/wAAAgABAAAAAFD+/wAAAgABAAAAAFAEAPr/AgAFAAAAACADAPr/AgAFAAAAADA=") -tile_set = ExtResource("4_hpo6d") +tile_map_data = PackedByteArray("AAD+/wEAAAAAAAAAAAD//wEAAAAAAAAAAAAAAAEAAAAAAAAAAAABAAEAAAAAAAAAAAACAAEAAAAAAAAAAAADAAEAAAAAAAAAAAAEAAEAAAAAAAAAAAAFAAEAAAAAAAAAAAAGAAEAAAABAAMAAFAHAAAAAAACAAMAAFAHAAEAAAABAAIAAFAGAAAAAAAAAAMAAFAJAP7/AAAAAAIAAFAJAP//AAABAAIAAFAIAP7/AAAAAAMAAFAIAP//AAACAAMAAFAIAAAAAAABAAIAAFAHAP//AAAAAAMAAFAJAP3/AAAAAAAAAFAJAPz/AAAAAAAAAFAJAPv/AAABAAMAAAAIAPr/AAAAAAIAAAAIAPv/AAAAAAMAAAAJAPr/AAABAAIAAAAHAPr/AAAAAAAAAAAGAPr/AAAAAAAAAAAFAPr/AAAAAAAAAAAEAPr/AAAAAAAAAAADAPr/AAAAAAAAAAACAPr/AAADAAAAAGACAPv/AAADAAAAAFABAPr/AAAAAAMAADABAPv/AAAAAAIAADAAAPr/AAAAAAIAAAAAAPv/AAABAAIAADD///r/AAAAAAAAAAD+//r/AAAAAAAAAAD9//r/AAAAAAAAAAD8//r/AAABAAMAAGD8//v/AAAAAAMAAGD7//r/AAABAAIAAGD7//v/AAAAAAIAAGD8////AAAAAAMAADD8/wAAAAAAAAIAADD7////AAABAAMAADD7/wAAAAABAAIAADD9/wAAAAADAAAAAAD9/wEAAAADAAAAADD7//7/AAAAAAAAAFD7//3/AAAAAAAAAFD7//z/AAAAAAAAAFA=") +tile_set = ExtResource("5_748hi") [node name="road_l" type="TileMapLayer" parent="."] -tile_map_data = PackedByteArray("AAABAP//AgABAAAAAHAAAP//AgABAAAAAHD/////AgABAAAAAHAGAP7/AAAAAAQAAFAFAP7/AAAAAAUAAFAFAP//AAABAAUAAFAFAPz/AAAGAAAAAAAFAP3/AAAGAAEAAAAGAP3/AAAHAAEAAAACAP//AgABAAAAAHADAP//AgABAAAAAHAEAP//AgABAAAAAHAFAPv/AgABAAAAABAFAPr/AgABAAAAABAFAPn/AgAFAAAAAAAEAPn/AgAFAAAAABAEAPr/AgADAAAAAFADAPr/AgADAAAAADADAPf/AgAFAAAAAHADAPn/AgABAAAAADADAPj/AgABAAAAADACAPf/AgABAAAAAFABAPf/AgABAAAAAFAAAPf/AgAFAAAAABAAAPr/AgADAAEAAAAAAPn/AgABAAAAAAAAAPj/AgABAAAAAAAAAPv/AgAFAAAAAEABAPv/AgABAAAAAGACAPv/AgABAAAAAGADAPv/AgABAAAAAGAEAPv/AgADAAAAAAAEAP3/AAAGAAIAAFAEAP7/AAAHAAIAAFADAP7/AAAHAAMAAFAEAPz/AgABAAAAAAACAP7/AgABAAAAAFABAP7/AgAFAAIAAGAAAP7/AgAAAAIAAFD///3/AgAAAAIAAFAAAP3/AgAGAAEAAFD///z/AgAEAAIAAFD+//z/AAAAAAQAABD+//3/AAAAAAUAABD9//3/AAABAAUAABD9//7/AgADAAAAAFD8//7/AgADAAAAADD8//v/AgADAAAAAGD8//r/AgADAAAAAED9//v/AgAFAAAAACD9//r/AgAFAAAAAAD8//z/AgABAAAAADD8//3/AgABAAAAADD8//n/AgADAAAAABD8//j/AgADAAAAADD9//n/AgAFAAAAAFD9//j/AgAFAAAAAHD8//f/AgAFAAAAAHD7//f/AgABAAAAAFD6//f/AAAHAAEAAGD6//j/AAAGAAEAAGD5//j/AAAGAAAAAGD4//j/AgAFAAAAAGD4//n/AgAEAAIAACD5//n/AgAAAAIAACD6//r/AgAAAAIAACD7//v/AgAAAAIAACD7//z/AgAFAAIAABD6//v/AgAGAAEAACD5//r/AgAGAAEAACD7//3/AgABAAAAACD7//7/AgABAAAAACD7////AgAFAAAAADD8////AgABAAAAAHD9////AgABAAAAAHD+////AgABAAAAAHA=") -tile_set = ExtResource("4_hpo6d") +tile_map_data = PackedByteArray("AAD+//7/AAAAAAAAAAD///7/AAAAAAAAAAAAAP7/AAAAAAAAAAABAP7/AAAAAAAAAAACAP7/AAABAAAAAAADAP7/AAAAAAAAAAAEAP7/AAAAAAAAAAAFAP7/AAAAAAAAAAAGAP7/AAABAAMAAFAHAP3/AAAAAAIAAFAHAP7/AAABAAIAAFAGAP3/AAAAAAMAAFAGAPv/AAAAAAIAAAAGAPz/AAAAAAMAAAAHAPv/AAABAAIAAAAHAPz/AAABAAMAAAAEAPv/AAADAAAAAGAFAPv/AAAAAAAAAAAEAPz/AAADAAAAAFADAPz/AAAAAAAAAAACAPz/AAAAAAAAAAABAPz/AAAAAAAAAAAAAPz/AAAAAAAAAAD///z/AAAAAAAAAAD+//z/AAAAAAAAAAD9//z/AAADAAAAAGD9//7/AAADAAAAADD9//3/AAAAAAAAAFA=") +tile_set = ExtResource("5_748hi") [node name="area_finish" type="Area2D" parent="."] collision_layer = 4 diff --git a/scripts/car.gd b/scripts/car.gd index be81119..7d448c4 100644 --- a/scripts/car.gd +++ b/scripts/car.gd @@ -12,6 +12,7 @@ var checkpointtimes :Array[float]=[] const ROAD_R_NAME="road_r" const ROAD_L_NAME="road_l" +const CAR_NAME="CharacterBody_Car" const COLLISION_SLOWDOWN_CAR=1.01 @@ -52,6 +53,15 @@ var resetcar_movingspeed=resetcar_stoppedspeed+10 #stop timer when above this sp var resetcar_distance=128 #196 is roughly when car is in the middle of a two wide road var resetcar_steerangle=120 +# other car avoidance +var avoid_car_distance_far=100 +var avoid_car_distance_close=50 +var avoid_car_steeringangle_far=0 +var avoid_car_steeringangle_close=50 +var avoid_car_mininum_space=50 #how much space RayCast_FL/R must have for avoidance to start. +var avoidance_steeringangle:float=0 #actual set steering angle to avoid car +var avoidance_turndirection:int=0 + #Effects const BURNOUT_KEEP_ON_AFTER_START=1 @@ -71,6 +81,9 @@ 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 @onready var ray_cast_car: RayCast2D = $RayCast_Car #for tracking markers @@ -158,7 +171,7 @@ func apply_friction(): func get_input(delta:float): - + # Check RayCast to Road const distance_inf=1000 var distance_fl=distance_inf var distance_fr=distance_inf @@ -178,9 +191,11 @@ func get_input(delta:float): var distance_min= min(distance_fl,distance_fr) + var turndirection = 1 if distance_fl