diff --git a/default_bus_layout.tres b/default_bus_layout.tres index 2fa487c..0edc9a3 100644 --- a/default_bus_layout.tres +++ b/default_bus_layout.tres @@ -13,3 +13,9 @@ bus/2/mute = false bus/2/bypass_fx = false bus/2/volume_db = -11.4678 bus/2/send = &"Master" +bus/3/name = &"Notifications" +bus/3/solo = false +bus/3/mute = false +bus/3/bypass_fx = false +bus/3/volume_db = -6.57885 +bus/3/send = &"Master" diff --git a/scenes/car.tscn b/scenes/car.tscn index 862e089..5ba4396 100644 --- a/scenes/car.tscn +++ b/scenes/car.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=37 format=3 uid="uid://0g7qqh7naniv"] +[gd_scene load_steps=47 format=3 uid="uid://0g7qqh7naniv"] [ext_resource type="Script" path="res://scripts/car_node.gd" id="1_0tin3"] [ext_resource type="Script" path="res://scripts/car.gd" id="1_i5tet"] @@ -30,6 +30,15 @@ [ext_resource type="AudioStream" uid="uid://bgsq7fchoqj8v" path="res://sounds/crashcartocar/carToCarCrash_8.mp3" id="28_esp4o"] [ext_resource type="AudioStream" uid="uid://cfqcw2mha2yp2" path="res://sounds/crashcartocar/carToCarCrash_9.mp3" id="29_b0wo4"] [ext_resource type="AudioStream" uid="uid://t0b8lpb7dtxe" path="res://sounds/crashcartocar/carToCarCrash_10.mp3" id="30_gtdxt"] +[ext_resource type="AudioStream" uid="uid://4g5dstft61qm" path="res://sounds/sliding_tires/sliding_1.mp3" id="31_q8dmo"] +[ext_resource type="AudioStream" uid="uid://dpf1q28plyv78" path="res://sounds/sliding_tires/sliding_2.mp3" id="32_e24hs"] +[ext_resource type="AudioStream" uid="uid://f7kjbgyro3wm" path="res://sounds/sliding_tires/sliding_3.mp3" id="33_t85wj"] +[ext_resource type="AudioStream" uid="uid://co3yviwjslvy3" path="res://sounds/sliding_tires/sliding_4.mp3" id="34_vggo2"] +[ext_resource type="AudioStream" uid="uid://diq4m6a8ptwsh" path="res://sounds/sliding_tires/sliding_5.mp3" id="35_on3l3"] +[ext_resource type="AudioStream" uid="uid://b6jics5gw71je" path="res://sounds/sliding_tires/sliding_6.mp3" id="36_kmjdq"] +[ext_resource type="AudioStream" uid="uid://b1ib5a0msbxtp" path="res://sounds/sliding_tires/sliding_7.mp3" id="37_dj0l2"] +[ext_resource type="AudioStream" uid="uid://cqtd0huwtmg6s" path="res://sounds/sliding_tires/sliding_8.mp3" id="38_uwebt"] +[ext_resource type="AudioStream" uid="uid://c86arger0uqdn" path="res://sounds/sliding_tires/sliding_9.mp3" id="39_4qf5g"] [sub_resource type="CapsuleShape2D" id="CapsuleShape2D_bj1hp"] radius = 8.0 @@ -104,6 +113,20 @@ stream_8/stream = ExtResource("29_b0wo4") stream_9/stream = ExtResource("30_gtdxt") stream_10/stream = ExtResource("22_2dot5") +[sub_resource type="AudioStreamRandomizer" id="AudioStreamRandomizer_evs7n"] +playback_mode = 1 +random_pitch = 1.25 +streams_count = 9 +stream_0/stream = ExtResource("31_q8dmo") +stream_1/stream = ExtResource("32_e24hs") +stream_2/stream = ExtResource("33_t85wj") +stream_3/stream = ExtResource("34_vggo2") +stream_4/stream = ExtResource("35_on3l3") +stream_5/stream = ExtResource("36_kmjdq") +stream_6/stream = ExtResource("37_dj0l2") +stream_7/stream = ExtResource("38_uwebt") +stream_8/stream = ExtResource("39_4qf5g") + [node name="Car" type="Node2D"] script = ExtResource("1_0tin3") @@ -178,5 +201,9 @@ pitch_scale = 1.27 max_polyphony = 2 bus = &"Crash" +[node name="SFXSliding" type="AudioStreamPlayer" parent="CharacterBody_Car/SFX"] +stream = SubResource("AudioStreamRandomizer_evs7n") +bus = &"Crash" + [connection signal="timeout" from="CharacterBody_Car/resetTimer" to="CharacterBody_Car" method="_on_reset_timer_timeout"] [connection signal="timeout" from="CharacterBody_Car/collisionEnableTimer" to="CharacterBody_Car" method="_on_collision_enable_timer_timeout"] diff --git a/scenes/game.tscn b/scenes/game.tscn index c21c284..53dab19 100644 --- a/scenes/game.tscn +++ b/scenes/game.tscn @@ -1,7 +1,9 @@ -[gd_scene load_steps=6 format=3 uid="uid://cotth8e5rtioe"] +[gd_scene load_steps=9 format=3 uid="uid://cotth8e5rtioe"] [ext_resource type="Script" path="res://scripts/game.gd" id="1_7syh4"] [ext_resource type="Script" path="res://scripts/times.gd" id="2_80mhm"] +[ext_resource type="AudioStream" uid="uid://cdricwi06nttp" path="res://sounds/beep/countdown_beep_high.mp3" id="3_fdp2i"] +[ext_resource type="AudioStream" uid="uid://v3eqa857k2xo" path="res://sounds/beep/countdown_beep.mp3" id="3_fv4j3"] [sub_resource type="Animation" id="Animation_ph30r"] length = 0.001 @@ -53,6 +55,42 @@ tracks/3/keys = { "update": 0, "values": [Vector2(1, 1)] } +tracks/4/type = "value" +tracks/4/imported = false +tracks/4/enabled = true +tracks/4/path = NodePath("countdown_label:visible") +tracks/4/interp = 1 +tracks/4/loop_wrap = true +tracks/4/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [true] +} +tracks/5/type = "value" +tracks/5/imported = false +tracks/5/enabled = true +tracks/5/path = NodePath("countdown_label:text") +tracks/5/interp = 1 +tracks/5/loop_wrap = true +tracks/5/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": ["3"] +} +tracks/6/type = "value" +tracks/6/imported = false +tracks/6/enabled = true +tracks/6/path = NodePath("countdown_label:self_modulate") +tracks/6/interp = 1 +tracks/6/loop_wrap = true +tracks/6/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [Color(1, 1, 1, 1)] +} [sub_resource type="Animation" id="Animation_gjxtp"] resource_name = "game_end" @@ -106,10 +144,93 @@ tracks/3/keys = { "values": [Vector2(1, 1), Vector2(1.5, 1.5)] } +[sub_resource type="Animation" id="Animation_5vgpy"] +resource_name = "game_start" +length = 4.0 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("countdown_label:visible") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0.0333333, 4), +"transitions": PackedFloat32Array(1, 1), +"update": 1, +"values": [true, false] +} +tracks/1/type = "value" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath("countdown_label:text") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/keys = { +"times": PackedFloat32Array(0, 1, 2, 3), +"transitions": PackedFloat32Array(1, 1, 1, 1), +"update": 1, +"values": ["3", "2 +", "1", "Go!"] +} +tracks/2/type = "method" +tracks/2/imported = false +tracks/2/enabled = true +tracks/2/path = NodePath("..") +tracks/2/interp = 1 +tracks/2/loop_wrap = true +tracks/2/keys = { +"times": PackedFloat32Array(3), +"transitions": PackedFloat32Array(1), +"values": [{ +"args": [], +"method": &"_on_countdown_timeout" +}] +} +tracks/3/type = "audio" +tracks/3/imported = false +tracks/3/enabled = true +tracks/3/path = NodePath("../SFX/Player_beep") +tracks/3/interp = 1 +tracks/3/loop_wrap = true +tracks/3/keys = { +"clips": [{ +"end_offset": 0.0, +"start_offset": 0.0, +"stream": ExtResource("3_fv4j3") +}, { +"end_offset": 0.0, +"start_offset": 0.0, +"stream": ExtResource("3_fv4j3") +}, { +"end_offset": 0.0, +"start_offset": 0.0, +"stream": ExtResource("3_fv4j3") +}, { +"end_offset": 0.0, +"start_offset": 0.0, +"stream": ExtResource("3_fdp2i") +}], +"times": PackedFloat32Array(0, 1, 2, 3) +} +tracks/3/use_blend = true +tracks/4/type = "value" +tracks/4/imported = false +tracks/4/enabled = true +tracks/4/path = NodePath("countdown_label:self_modulate") +tracks/4/interp = 1 +tracks/4/loop_wrap = true +tracks/4/keys = { +"times": PackedFloat32Array(0, 3.43333, 3.93333), +"transitions": PackedFloat32Array(1, 1, 1), +"update": 0, +"values": [Color(1, 1, 1, 1), Color(1, 1, 1, 1), Color(1, 1, 1, 0)] +} + [sub_resource type="AnimationLibrary" id="AnimationLibrary_wuihg"] _data = { "RESET": SubResource("Animation_ph30r"), -"game_end": SubResource("Animation_gjxtp") +"game_end": SubResource("Animation_gjxtp"), +"game_start": SubResource("Animation_5vgpy") } [node name="Game" type="Node2D"] @@ -187,5 +308,9 @@ one_shot = true wait_time = 5.0 one_shot = true -[connection signal="timeout" from="countdown" to="." method="_on_countdown_timeout"] +[node name="SFX" type="Node" parent="."] + +[node name="Player_beep" type="AudioStreamPlayer" parent="SFX"] +bus = &"Notifications" + [connection signal="timeout" from="timer_close" to="." method="_on_timer_close_timeout"] diff --git a/scripts/car.gd b/scripts/car.gd index 3641b6a..c52e5d0 100644 --- a/scripts/car.gd +++ b/scripts/car.gd @@ -202,7 +202,7 @@ func get_input(delta:float): if steer_direction<1: resetcar_steerangle=min(-resetcar_steerangle,+resetcar_steerangle) #calculate steering direction for next autoreset - +var mind=1 func calculate_steering(delta:float): var rear_wheel = position - transform.x *wheel_base/2.0 var front_wheel = position + transform.x *wheel_base/2.0 @@ -213,10 +213,18 @@ func calculate_steering(delta:float): var traction = traction_slow if velocity.length() > slip_speed: traction = traction_fast + var d = new_heading.dot(velocity.normalized()) + if d > 0: + mind=min(d,mind) + if d==mind: + print("mind="+str(mind)) velocity = velocity.lerp(new_heading * velocity.length(), traction) + if d<0.80 and velocity.length()>slip_speed and applied_engine_power>engine_power/2: + sfx.sliding(velocity.length()) + elif d<0: velocity = - new_heading * min(velocity.length(),max_speed_reverse) rotation = new_heading.angle() diff --git a/scripts/game.gd b/scripts/game.gd index ec4a93c..be11592 100644 --- a/scripts/game.gd +++ b/scripts/game.gd @@ -2,7 +2,7 @@ extends Node2D @onready var camera: Camera2D = $Camera2D @onready var countdown: Timer = $countdown -@onready var countdown_label: Label = $hud/countdown_label +#@onready var countdown_label: Label = $hud/countdown_label @onready var cars: Node = $cars @@ -35,8 +35,9 @@ var game_ended=false func _ready() -> void: Gamestate.resetTimeElapsed() - countdown.start() - countdown_label.visible=true + #countdown.start() + game_hud_animations.play("game_start") + #countdown_label.visible=true #Load Map var checkpoints :Array[String]=[] @@ -68,8 +69,8 @@ func _ready() -> void: func _process(delta: float) -> void: if running: Gamestate.addTimeElapsed(delta) - if !countdown.is_stopped(): - countdown_label.text=str(round(countdown.time_left)) + #if !countdown.is_stopped(): + # countdown_label.text=str(round(countdown.time_left)) updateCameraMovement(delta) @@ -180,7 +181,7 @@ func _on_countdown_timeout() -> void: var cars=cars.get_children() for c in cars: c.setRunning(true) - countdown_label.visible=false + #countdown_label.visible=false func _on_car_finished(playerid,finalTime) -> void: diff --git a/scripts/sfx.gd b/scripts/sfx.gd index 39b5d79..c684f94 100644 --- a/scripts/sfx.gd +++ b/scripts/sfx.gd @@ -1,6 +1,7 @@ extends Node @onready var sfx_crash: AudioStreamPlayer = $SFXCrash @onready var sfx_crash_car_to_car: AudioStreamPlayer = $SFXCrashCarToCar +@onready var sfx_sliding: AudioStreamPlayer = $SFXSliding # Called when the node enters the scene tree for the first time. @@ -23,3 +24,8 @@ func crashCarToCar(velocity): #print("Play sfx_crash_car_to_car sound v="+str(velocity)) sfx_crash_car_to_car.set_volume_db(linear_to_db(clamp(remap(velocity, 200,300,0.0,1.0),0,1))) sfx_crash_car_to_car.play() + +func sliding(velocity): + if not sfx_sliding.playing: + sfx_sliding.set_volume_db(linear_to_db(clamp(remap(velocity, 100,300,0.0,1.0),0,1))) + sfx_sliding.play() diff --git a/sounds/sliding_tires/sliding_1.mp3 b/sounds/sliding_tires/sliding_1.mp3 new file mode 100644 index 0000000..0c69a68 Binary files /dev/null and b/sounds/sliding_tires/sliding_1.mp3 differ diff --git a/sounds/sliding_tires/sliding_1.mp3.import b/sounds/sliding_tires/sliding_1.mp3.import new file mode 100644 index 0000000..aa0292a --- /dev/null +++ b/sounds/sliding_tires/sliding_1.mp3.import @@ -0,0 +1,19 @@ +[remap] + +importer="mp3" +type="AudioStreamMP3" +uid="uid://4g5dstft61qm" +path="res://.godot/imported/sliding_1.mp3-17ed35021fd9b9ef2b20a52da6bea20d.mp3str" + +[deps] + +source_file="res://sounds/sliding_tires/sliding_1.mp3" +dest_files=["res://.godot/imported/sliding_1.mp3-17ed35021fd9b9ef2b20a52da6bea20d.mp3str"] + +[params] + +loop=false +loop_offset=0 +bpm=0 +beat_count=0 +bar_beats=4 diff --git a/sounds/sliding_tires/sliding_2.mp3 b/sounds/sliding_tires/sliding_2.mp3 new file mode 100644 index 0000000..7c168c5 Binary files /dev/null and b/sounds/sliding_tires/sliding_2.mp3 differ diff --git a/sounds/sliding_tires/sliding_2.mp3.import b/sounds/sliding_tires/sliding_2.mp3.import new file mode 100644 index 0000000..d14e696 --- /dev/null +++ b/sounds/sliding_tires/sliding_2.mp3.import @@ -0,0 +1,19 @@ +[remap] + +importer="mp3" +type="AudioStreamMP3" +uid="uid://dpf1q28plyv78" +path="res://.godot/imported/sliding_2.mp3-6e04652155c151509272e44ad5be0438.mp3str" + +[deps] + +source_file="res://sounds/sliding_tires/sliding_2.mp3" +dest_files=["res://.godot/imported/sliding_2.mp3-6e04652155c151509272e44ad5be0438.mp3str"] + +[params] + +loop=false +loop_offset=0 +bpm=0 +beat_count=0 +bar_beats=4 diff --git a/sounds/sliding_tires/sliding_3.mp3 b/sounds/sliding_tires/sliding_3.mp3 new file mode 100644 index 0000000..a0ad8b6 Binary files /dev/null and b/sounds/sliding_tires/sliding_3.mp3 differ diff --git a/sounds/sliding_tires/sliding_3.mp3.import b/sounds/sliding_tires/sliding_3.mp3.import new file mode 100644 index 0000000..f0387f5 --- /dev/null +++ b/sounds/sliding_tires/sliding_3.mp3.import @@ -0,0 +1,19 @@ +[remap] + +importer="mp3" +type="AudioStreamMP3" +uid="uid://f7kjbgyro3wm" +path="res://.godot/imported/sliding_3.mp3-3116eccc604ff1c0faa380a392e0afd2.mp3str" + +[deps] + +source_file="res://sounds/sliding_tires/sliding_3.mp3" +dest_files=["res://.godot/imported/sliding_3.mp3-3116eccc604ff1c0faa380a392e0afd2.mp3str"] + +[params] + +loop=false +loop_offset=0 +bpm=0 +beat_count=0 +bar_beats=4 diff --git a/sounds/sliding_tires/sliding_4.mp3 b/sounds/sliding_tires/sliding_4.mp3 new file mode 100644 index 0000000..9d4b324 Binary files /dev/null and b/sounds/sliding_tires/sliding_4.mp3 differ diff --git a/sounds/sliding_tires/sliding_4.mp3.import b/sounds/sliding_tires/sliding_4.mp3.import new file mode 100644 index 0000000..6b227ed --- /dev/null +++ b/sounds/sliding_tires/sliding_4.mp3.import @@ -0,0 +1,19 @@ +[remap] + +importer="mp3" +type="AudioStreamMP3" +uid="uid://co3yviwjslvy3" +path="res://.godot/imported/sliding_4.mp3-6788926754b2aeec61f6f26530514ddd.mp3str" + +[deps] + +source_file="res://sounds/sliding_tires/sliding_4.mp3" +dest_files=["res://.godot/imported/sliding_4.mp3-6788926754b2aeec61f6f26530514ddd.mp3str"] + +[params] + +loop=false +loop_offset=0 +bpm=0 +beat_count=0 +bar_beats=4 diff --git a/sounds/sliding_tires/sliding_5.mp3 b/sounds/sliding_tires/sliding_5.mp3 new file mode 100644 index 0000000..771f5a7 Binary files /dev/null and b/sounds/sliding_tires/sliding_5.mp3 differ diff --git a/sounds/sliding_tires/sliding_5.mp3.import b/sounds/sliding_tires/sliding_5.mp3.import new file mode 100644 index 0000000..6c6268b --- /dev/null +++ b/sounds/sliding_tires/sliding_5.mp3.import @@ -0,0 +1,19 @@ +[remap] + +importer="mp3" +type="AudioStreamMP3" +uid="uid://diq4m6a8ptwsh" +path="res://.godot/imported/sliding_5.mp3-3881813701b1cee5bf26ca73d03e6c7e.mp3str" + +[deps] + +source_file="res://sounds/sliding_tires/sliding_5.mp3" +dest_files=["res://.godot/imported/sliding_5.mp3-3881813701b1cee5bf26ca73d03e6c7e.mp3str"] + +[params] + +loop=false +loop_offset=0 +bpm=0 +beat_count=0 +bar_beats=4 diff --git a/sounds/sliding_tires/sliding_6.mp3 b/sounds/sliding_tires/sliding_6.mp3 new file mode 100644 index 0000000..82ab607 Binary files /dev/null and b/sounds/sliding_tires/sliding_6.mp3 differ diff --git a/sounds/sliding_tires/sliding_6.mp3.import b/sounds/sliding_tires/sliding_6.mp3.import new file mode 100644 index 0000000..df156ad --- /dev/null +++ b/sounds/sliding_tires/sliding_6.mp3.import @@ -0,0 +1,19 @@ +[remap] + +importer="mp3" +type="AudioStreamMP3" +uid="uid://b6jics5gw71je" +path="res://.godot/imported/sliding_6.mp3-c43940ac3f2297a7653329b252f493ad.mp3str" + +[deps] + +source_file="res://sounds/sliding_tires/sliding_6.mp3" +dest_files=["res://.godot/imported/sliding_6.mp3-c43940ac3f2297a7653329b252f493ad.mp3str"] + +[params] + +loop=false +loop_offset=0 +bpm=0 +beat_count=0 +bar_beats=4 diff --git a/sounds/sliding_tires/sliding_7.mp3 b/sounds/sliding_tires/sliding_7.mp3 new file mode 100644 index 0000000..11aecef Binary files /dev/null and b/sounds/sliding_tires/sliding_7.mp3 differ diff --git a/sounds/sliding_tires/sliding_7.mp3.import b/sounds/sliding_tires/sliding_7.mp3.import new file mode 100644 index 0000000..f5aec28 --- /dev/null +++ b/sounds/sliding_tires/sliding_7.mp3.import @@ -0,0 +1,19 @@ +[remap] + +importer="mp3" +type="AudioStreamMP3" +uid="uid://b1ib5a0msbxtp" +path="res://.godot/imported/sliding_7.mp3-30c30e46301150687deab4e01b0716a9.mp3str" + +[deps] + +source_file="res://sounds/sliding_tires/sliding_7.mp3" +dest_files=["res://.godot/imported/sliding_7.mp3-30c30e46301150687deab4e01b0716a9.mp3str"] + +[params] + +loop=false +loop_offset=0 +bpm=0 +beat_count=0 +bar_beats=4 diff --git a/sounds/sliding_tires/sliding_8.mp3 b/sounds/sliding_tires/sliding_8.mp3 new file mode 100644 index 0000000..ff7cb52 Binary files /dev/null and b/sounds/sliding_tires/sliding_8.mp3 differ diff --git a/sounds/sliding_tires/sliding_8.mp3.import b/sounds/sliding_tires/sliding_8.mp3.import new file mode 100644 index 0000000..2975908 --- /dev/null +++ b/sounds/sliding_tires/sliding_8.mp3.import @@ -0,0 +1,19 @@ +[remap] + +importer="mp3" +type="AudioStreamMP3" +uid="uid://cqtd0huwtmg6s" +path="res://.godot/imported/sliding_8.mp3-6e6836dc0a76e9813e894faf64ac6459.mp3str" + +[deps] + +source_file="res://sounds/sliding_tires/sliding_8.mp3" +dest_files=["res://.godot/imported/sliding_8.mp3-6e6836dc0a76e9813e894faf64ac6459.mp3str"] + +[params] + +loop=false +loop_offset=0 +bpm=0 +beat_count=0 +bar_beats=4 diff --git a/sounds/sliding_tires/sliding_9.mp3 b/sounds/sliding_tires/sliding_9.mp3 new file mode 100644 index 0000000..953b999 Binary files /dev/null and b/sounds/sliding_tires/sliding_9.mp3 differ diff --git a/sounds/sliding_tires/sliding_9.mp3.import b/sounds/sliding_tires/sliding_9.mp3.import new file mode 100644 index 0000000..b13044f --- /dev/null +++ b/sounds/sliding_tires/sliding_9.mp3.import @@ -0,0 +1,19 @@ +[remap] + +importer="mp3" +type="AudioStreamMP3" +uid="uid://c86arger0uqdn" +path="res://.godot/imported/sliding_9.mp3-746f850950bdbd7ce2a66444670a334b.mp3str" + +[deps] + +source_file="res://sounds/sliding_tires/sliding_9.mp3" +dest_files=["res://.godot/imported/sliding_9.mp3-746f850950bdbd7ce2a66444670a334b.mp3str"] + +[params] + +loop=false +loop_offset=0 +bpm=0 +beat_count=0 +bar_beats=4