diff --git a/README.md b/README.md index 2eba42e..c36ca25 100644 --- a/README.md +++ b/README.md @@ -12,3 +12,21 @@ Game is available on [Itch.io](https://esensar.itch.io/bugged-racing). Game source code is licensed under [MIT license](/LICENSE). Assets are licensed under [Creative Commons Attribution 4.0 International License](http://creativecommons.org/licenses/by/4.0/). + +## Credits + +This game includes assets from [opengameart.org](opengameart.org), [freesound.org](freesound.org) and other sources. + +### Sounds + +#### Wind sounds + +[Wind sounds](/assets/wind woosh loop.ogg) used in the game is available on [opengameart.org](https://opengameart.org/content/wind-whoosh-loop) under CC0 license (public domain). + +#### Engine sounds + +[Engine sounds](/assets/engine.wav) used in the game is available on [freesound.org](https://freesound.org/people/MarlonHJ/sounds/242740/) under CC0 license (public domain). + +#### Tire sounds + +[Tire sounds](/assets/tires_squal_loop.wav) used in the game is available on [opengameart.org](https://opengameart.org/content/car-tire-squeal-skid-loop) under [CC-BY 3.0 license](https://creativecommons.org/licenses/by/3.0/). Sound is provided by [audible-edge (Tom Haigh)](http://www.freesound.org/people/audible-edge/) and submitted by [qubodup](https://opengameart.org/users/qubodup) diff --git a/assets/engine.wav b/assets/engine.wav new file mode 100644 index 0000000..89b5de1 Binary files /dev/null and b/assets/engine.wav differ diff --git a/assets/engine.wav.import b/assets/engine.wav.import new file mode 100644 index 0000000..8ce7cf2 --- /dev/null +++ b/assets/engine.wav.import @@ -0,0 +1,21 @@ +[remap] + +importer="wav" +type="AudioStreamSample" +path="res://.import/engine.wav-cc4df8df683a7f5419ef7019228b045a.sample" + +[deps] + +source_file="res://assets/engine.wav" +dest_files=[ "res://.import/engine.wav-cc4df8df683a7f5419ef7019228b045a.sample" ] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop=true +compress/mode=0 diff --git a/assets/tires_squal_loop.wav b/assets/tires_squal_loop.wav new file mode 100644 index 0000000..d1dc68f Binary files /dev/null and b/assets/tires_squal_loop.wav differ diff --git a/assets/tires_squal_loop.wav.import b/assets/tires_squal_loop.wav.import new file mode 100644 index 0000000..14af1c6 --- /dev/null +++ b/assets/tires_squal_loop.wav.import @@ -0,0 +1,21 @@ +[remap] + +importer="wav" +type="AudioStreamSample" +path="res://.import/tires_squal_loop.wav-6f4aaa09ee4bdf0eca94aed4cc79779d.sample" + +[deps] + +source_file="res://assets/tires_squal_loop.wav" +dest_files=[ "res://.import/tires_squal_loop.wav-6f4aaa09ee4bdf0eca94aed4cc79779d.sample" ] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop=true +compress/mode=0 diff --git a/assets/wind woosh loop.ogg b/assets/wind woosh loop.ogg new file mode 100644 index 0000000..4444b6c Binary files /dev/null and b/assets/wind woosh loop.ogg differ diff --git a/assets/wind woosh loop.ogg.import b/assets/wind woosh loop.ogg.import new file mode 100644 index 0000000..aaa91c0 --- /dev/null +++ b/assets/wind woosh loop.ogg.import @@ -0,0 +1,15 @@ +[remap] + +importer="ogg_vorbis" +type="AudioStreamOGGVorbis" +path="res://.import/wind woosh loop.ogg-843e7b8cdfc6f4a378e2da0a4cb7290b.oggstr" + +[deps] + +source_file="res://assets/wind woosh loop.ogg" +dest_files=[ "res://.import/wind woosh loop.ogg-843e7b8cdfc6f4a378e2da0a4cb7290b.oggstr" ] + +[params] + +loop=true +loop_offset=0 diff --git a/menu/about.tscn b/menu/about.tscn index 0cb8230..a6120e7 100644 --- a/menu/about.tscn +++ b/menu/about.tscn @@ -46,7 +46,7 @@ scroll_horizontal_enabled = false [node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/ScrollContainer"] margin_right = 800.0 -margin_bottom = 1974.0 +margin_bottom = 2300.0 size_flags_horizontal = 3 [node name="Title" type="Label" parent="MarginContainer/ScrollContainer/VBoxContainer"] @@ -139,20 +139,78 @@ __meta__ = { "_edit_use_anchors_": false } -[node name="Label7" type="Label" parent="MarginContainer/ScrollContainer/VBoxContainer"] +[node name="Label17" type="Label" parent="MarginContainer/ScrollContainer/VBoxContainer"] margin_top = 490.0 margin_right = 800.0 margin_bottom = 508.0 custom_fonts/font = SubResource( 2 ) +text = "Credits:" +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="Label20" type="Label" parent="MarginContainer/ScrollContainer/VBoxContainer"] +margin_top = 516.0 +margin_right = 800.0 +margin_bottom = 534.0 +custom_fonts/font = SubResource( 2 ) +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="Label23" type="RichTextLabel" parent="MarginContainer/ScrollContainer/VBoxContainer"] +margin_top = 542.0 +margin_right = 800.0 +margin_bottom = 782.0 +size_flags_vertical = 0 +custom_fonts/normal_font = SubResource( 2 ) +bbcode_enabled = true +bbcode_text = "This game includes assets from [url=https://opengameart.org]opengameart.org[/url], [url=https://freesound.org]freesound.org[/url] and other sources. + +- Sounds: + +Wind sound used in the game is available on [url=https://opengameart.org/content/wind-whoosh-loop]opengameart.org[/url] under CC0 license (public domain). + +Engine sound used in the game is available on [url=https://freesound.org/people/MarlonHJ/sounds/242740/]freesound.org[/url] under CC0 license (public domain). + +Tire sound used in the game is available on [url=https://opengameart.org/content/car-tire-squeal-skid-loop]opengameart.org[/url] under [url=https://creativecommons.org/licenses/by/3.0/]CC-BY 3.0 license[/url]. Sound is provided by [url=http://www.freesound.org/people/audible-edge/]audible-edge (Tom Haigh)[/url] and submitted by [url=https://opengameart.org/users/qubodup]qubodup[/url]" +text = "This game includes assets from opengameart.org, freesound.org and other sources. + +- Sounds: + +Wind sound used in the game is available on opengameart.org under CC0 license (public domain). + +Engine sound used in the game is available on freesound.org under CC0 license (public domain). + +Tire sound used in the game is available on opengameart.org under CC-BY 3.0 license. Sound is provided by audible-edge (Tom Haigh) and submitted by qubodup" +fit_content_height = true +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="Label21" type="Label" parent="MarginContainer/ScrollContainer/VBoxContainer"] +margin_top = 790.0 +margin_right = 800.0 +margin_bottom = 808.0 +custom_fonts/font = SubResource( 2 ) +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="Label7" type="Label" parent="MarginContainer/ScrollContainer/VBoxContainer"] +margin_top = 816.0 +margin_right = 800.0 +margin_bottom = 834.0 +custom_fonts/font = SubResource( 2 ) text = "Open source licences:" __meta__ = { "_edit_use_anchors_": false } [node name="Label8" type="Label" parent="MarginContainer/ScrollContainer/VBoxContainer"] -margin_top = 516.0 +margin_top = 842.0 margin_right = 800.0 -margin_bottom = 534.0 +margin_bottom = 860.0 custom_fonts/font = SubResource( 2 ) align = 1 __meta__ = { @@ -160,9 +218,9 @@ __meta__ = { } [node name="Label11" type="RichTextLabel" parent="MarginContainer/ScrollContainer/VBoxContainer"] -margin_top = 542.0 +margin_top = 868.0 margin_right = 800.0 -margin_bottom = 562.0 +margin_bottom = 888.0 custom_fonts/normal_font = SubResource( 2 ) bbcode_enabled = true bbcode_text = "Godot Engine (also available in [url=https://godotengine.org/license]web version[/url]):" @@ -170,9 +228,9 @@ text = "Godot Engine (also available in web version):" fit_content_height = true [node name="Label9" type="Label" parent="MarginContainer/ScrollContainer/VBoxContainer"] -margin_top = 570.0 +margin_top = 896.0 margin_right = 800.0 -margin_bottom = 1092.0 +margin_bottom = 1418.0 custom_fonts/font = SubResource( 2 ) text = " This game uses Godot Engine, available under the following license: @@ -190,9 +248,9 @@ __meta__ = { } [node name="Label12" type="Label" parent="MarginContainer/ScrollContainer/VBoxContainer"] -margin_top = 1100.0 +margin_top = 1426.0 margin_right = 800.0 -margin_bottom = 1118.0 +margin_bottom = 1444.0 custom_fonts/font = SubResource( 2 ) align = 1 __meta__ = { @@ -200,9 +258,9 @@ __meta__ = { } [node name="Label10" type="RichTextLabel" parent="MarginContainer/ScrollContainer/VBoxContainer"] -margin_top = 1126.0 +margin_top = 1452.0 margin_right = 800.0 -margin_bottom = 1206.0 +margin_bottom = 1532.0 custom_fonts/normal_font = SubResource( 2 ) bbcode_enabled = true bbcode_text = "[url=https://www.freetype.org/]FreeType[/url]: @@ -214,9 +272,9 @@ text = "FreeType: fit_content_height = true [node name="Label13" type="Label" parent="MarginContainer/ScrollContainer/VBoxContainer"] -margin_top = 1214.0 +margin_top = 1540.0 margin_right = 800.0 -margin_bottom = 1232.0 +margin_bottom = 1558.0 custom_fonts/font = SubResource( 2 ) align = 1 __meta__ = { @@ -224,9 +282,9 @@ __meta__ = { } [node name="Label14" type="RichTextLabel" parent="MarginContainer/ScrollContainer/VBoxContainer"] -margin_top = 1240.0 +margin_top = 1566.0 margin_right = 800.0 -margin_bottom = 1660.0 +margin_bottom = 1986.0 custom_fonts/normal_font = SubResource( 2 ) bbcode_enabled = true bbcode_text = "[url=http://enet.bespin.org/]ENet[/url]: @@ -252,9 +310,9 @@ text = "ENet: fit_content_height = true [node name="Label15" type="Label" parent="MarginContainer/ScrollContainer/VBoxContainer"] -margin_top = 1668.0 +margin_top = 1994.0 margin_right = 800.0 -margin_bottom = 1686.0 +margin_bottom = 2012.0 custom_fonts/font = SubResource( 2 ) align = 1 __meta__ = { @@ -262,9 +320,9 @@ __meta__ = { } [node name="Label16" type="RichTextLabel" parent="MarginContainer/ScrollContainer/VBoxContainer"] -margin_top = 1694.0 +margin_top = 2020.0 margin_right = 800.0 -margin_bottom = 1974.0 +margin_bottom = 2300.0 custom_fonts/normal_font = SubResource( 2 ) bbcode_enabled = true bbcode_text = "[url=https://tls.mbed.org/]MBedTLS[/url]: @@ -293,6 +351,7 @@ fit_content_height = true [connection signal="meta_clicked" from="MarginContainer/ScrollContainer/VBoxContainer/Label3" to="." method="_on_link_meta_clicked"] [connection signal="meta_clicked" from="MarginContainer/ScrollContainer/VBoxContainer/Label19" to="." method="_on_link_meta_clicked"] [connection signal="meta_clicked" from="MarginContainer/ScrollContainer/VBoxContainer/Label18" to="." method="_on_link_meta_clicked"] +[connection signal="meta_clicked" from="MarginContainer/ScrollContainer/VBoxContainer/Label23" to="." method="_on_link_meta_clicked"] [connection signal="meta_clicked" from="MarginContainer/ScrollContainer/VBoxContainer/Label11" to="." method="_on_link_meta_clicked"] [connection signal="meta_clicked" from="MarginContainer/ScrollContainer/VBoxContainer/Label10" to="." method="_on_link_meta_clicked"] [connection signal="meta_clicked" from="MarginContainer/ScrollContainer/VBoxContainer/Label14" to="." method="_on_link_meta_clicked"] diff --git a/menu/main_menu.gd b/menu/main_menu.gd index 59a3977..f60e962 100644 --- a/menu/main_menu.gd +++ b/menu/main_menu.gd @@ -19,7 +19,7 @@ func _on_MultiplayerButton_pressed() -> void: func _on_ExitButton_pressed() -> void: - get_tree().quit() + get_tree().notification(MainLoop.NOTIFICATION_WM_QUIT_REQUEST) func _on_SettingsButton_pressed() -> void: diff --git a/player/vehicle_controller.gd b/player/vehicle_controller.gd index 5a1ab23..16b37eb 100644 --- a/player/vehicle_controller.gd +++ b/player/vehicle_controller.gd @@ -50,9 +50,7 @@ func _physics_process(delta: float) -> void: var steering_factor = steering_sensitivity if abs(_input_sink.inputs.steering) > abs(steering_input): - print("detected returning: %s, %s" % [steering_factor, return_speed]) steering_factor *= return_speed - print("updated turn speed: %s" % steering_factor) _input_sink.inputs.steering = move_toward( _input_sink.inputs.steering, steering_input, lerp(delta, 1, steering_factor) diff --git a/settings/global_settings.gd b/settings/global_settings.gd index 9b704a7..fdd6ed6 100644 --- a/settings/global_settings.gd +++ b/settings/global_settings.gd @@ -1,6 +1,6 @@ extends Node -var auto_clutch: bool = false +var auto_clutch: bool = true var automatic_transmission: bool = true var steering_sensitivity = 1.0 var return_speed = 2.0 @@ -17,6 +17,23 @@ var _config: Dictionary func _ready() -> void: _config = read_json_file("res://info.json") + get_tree().set_auto_accept_quit(false) + var stored_config = read_json_file("user://settings.json") + if stored_config.has("hidden"): + selected_camera = stored_config["hidden"].get("selected_camera", 0) + + if stored_config.has("gameplay"): + multiplayer_name = stored_config["gameplay"].get("multiplayer_name", "Player") + + if stored_config.has("controls"): + auto_clutch = stored_config["controls"].get("auto_clutch", true) + automatic_transmission = stored_config["controls"].get("automatic_transmission", true) + steering_sensitivity = stored_config["controls"].get("steering_sensitivity", 1.0) + return_speed = stored_config["controls"].get("return_speed", 2.0) + throttle_sensitivity = stored_config["controls"].get("throttle_sensitivity", 1.0) + brake_sensitivity = stored_config["controls"].get("brake_sensitivity", 1.0) + steering_deadzone_inner = stored_config["controls"].get("steering_deadzone_inner", 1.0) + steering_deadzone_outer = stored_config["controls"].get("steering_deadzone_outer", 1.0) func read_json_file(file_path: String) -> Dictionary: @@ -43,3 +60,32 @@ func get_version_string() -> String: var minor = version["minor"] var patch = version["patch"] return "%d.%d.%d" % [major, minor, patch] + + +func save_settings() -> void: + save_json_file("user://settings.json", to_dictionary()) + + +func to_dictionary() -> Dictionary: + return { + "hidden": {"selected_camera": selected_camera}, + "gameplay": {"multiplayer_name": multiplayer_name}, + "controls": + { + "auto_clutch": auto_clutch, + "automatic_transmission": automatic_transmission, + "steering_sensitivity": steering_sensitivity, + "return_speed": return_speed, + "throttle_sensitivity": throttle_sensitivity, + "brake_sensitivity": brake_sensitivity, + "steering_deadzone_inner": steering_deadzone_inner, + "steering_deadzone_outer": steering_deadzone_outer, + } + } + + +# Handle quit +func _notification(what): + if what == MainLoop.NOTIFICATION_WM_QUIT_REQUEST: + save_settings() + get_tree().quit() # default behavior diff --git a/vehicles/beetlecar.tscn b/vehicles/beetlecar.tscn index e4660b9..55f37e9 100644 --- a/vehicles/beetlecar.tscn +++ b/vehicles/beetlecar.tscn @@ -6,21 +6,16 @@ [ext_resource path="res://vehicles/pedal.gd" type="Script" id=4] [ext_resource path="res://vehicles/meter.gd" type="Script" id=5] [ext_resource path="res://vehicles/steering_controller.gd" type="Script" id=6] +[ext_resource path="res://assets/engine.wav" type="AudioStream" id=7] +[ext_resource path="res://assets/wind woosh loop.ogg" type="AudioStream" id=8] [sub_resource type="Curve" id=3] _data = [ Vector2( 0, 0 ), 0.0, 3.60634, 0, 1, Vector2( 0.15566, 0.561364 ), 1.56017, 1.56017, 0, 0, Vector2( 0.830189, 1 ), 0.0, 0.0, 0, 0, Vector2( 1, 0 ), 0.0, 0.0, 0, 0 ] -[sub_resource type="Curve" id=4] -_data = [ Vector2( 0, 0.492045 ), 0.0, 0.0, 0, 0, Vector2( 0.15566, 1 ), 0.0, 0.0, 0, 0, Vector2( 0.212264, 0 ), 0.0, 0.0, 0, 0, Vector2( 0.29717, 1 ), 0.0, 0.0, 0, 0, Vector2( 0.410377, 0 ), 0.0, 0.0, 0, 0, Vector2( 0.481132, 0.701136 ), 0.0, 0.0, 0, 0, Vector2( 0.566038, 0.282955 ), 0.0, 0.0, 0, 0, Vector2( 0.589623, 0.6375 ), 0.0, 0.0, 0, 0, Vector2( 0.660377, 0.373864 ), 0.0, 0.0, 0, 0, Vector2( 0.669811, 0.5375 ), 0.0, 0.0, 0, 0, Vector2( 0.764151, 0.0284091 ), 0.0, 0.0, 0, 0, Vector2( 0.811321, 1 ), 0.0, 0.0, 0, 0, Vector2( 0.938679, 0 ), 0.0, 0.0, 0, 0, Vector2( 1, 1 ), 0.0, 0.0, 0, 0 ] - [sub_resource type="CapsuleShape" id=11] radius = 0.394377 height = 2.03536 -[sub_resource type="AudioStreamGenerator" id=2] -mix_rate = 5500.0 -buffer_length = 1.0 - [sub_resource type="Curve" id=9] _data = [ Vector2( 0, 1 ), 0.0, 0.0, 0, 0, Vector2( 1, 0.493182 ), 0.0, 0.0, 0, 0 ] @@ -46,27 +41,31 @@ radial_segments = 4 rings = 3 [node name="beetlecar" groups=["car"] instance=ExtResource( 2 )] -mass = 340.0 +mass = 750.0 script = ExtResource( 1 ) -max_steer_input = 40.0 -max_engine_force = 100.0 -max_brake_force = 60.0 +max_steer_input = 35.0 +max_engine_force = 650.0 +max_brake_force = 90.0 base_engine_pitch = 0.38 -gear_ratios = [ 2.99, 2.5, 1.98, 1.56, 1.32, 1.12 ] -final_drive = 4.0 -max_rpm = 8000.0 -gear_switch_time = 0.5 +expected_max_speed = 170.0 +drag_factor = 1.55 +downforce_factor = 0.2 +gear_ratios = [ 6.67, 4.95, 3.65, 2.78, 2.25 ] +final_drive = 2.5 +max_rpm = 8500.0 +gear_switch_time = 0.3 power_curve = SubResource( 3 ) -sound_curve = SubResource( 4 ) +automatic_gear_up_threshold = 0.85 [node name="rear_right" parent="." index="0"] use_as_traction = true wheel_roll_influence = 0.01 wheel_radius = 0.38 wheel_rest_length = 0.3 -wheel_friction_slip = 12.0 +wheel_friction_slip = 2.0 suspension_travel = 0.3 suspension_stiffness = 12.0 +suspension_max_force = 4000.0 damping_compression = 0.75 damping_relaxation = 0.8 @@ -97,9 +96,10 @@ use_as_traction = true wheel_roll_influence = 0.01 wheel_radius = 0.38 wheel_rest_length = 0.3 -wheel_friction_slip = 12.0 +wheel_friction_slip = 2.0 suspension_travel = 0.3 suspension_stiffness = 12.0 +suspension_max_force = 4000.0 damping_compression = 0.75 damping_relaxation = 0.8 @@ -111,9 +111,10 @@ use_as_steering = true wheel_roll_influence = 0.01 wheel_radius = 0.38 wheel_rest_length = 0.3 -wheel_friction_slip = 10.0 +wheel_friction_slip = 1.95 suspension_travel = 0.3 suspension_stiffness = 12.0 +suspension_max_force = 4000.0 damping_compression = 0.75 damping_relaxation = 0.8 @@ -123,9 +124,10 @@ use_as_steering = true wheel_roll_influence = 0.01 wheel_radius = 0.38 wheel_rest_length = 0.3 -wheel_friction_slip = 10.0 +wheel_friction_slip = 1.95 suspension_travel = 0.3 suspension_stiffness = 12.0 +suspension_max_force = 4000.0 damping_compression = 0.75 damping_relaxation = 0.8 @@ -138,8 +140,8 @@ shape = SubResource( 11 ) [node name="engine_sound_player" type="AudioStreamPlayer3D" parent="." index="7"] transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.14201, 0.968668 ) -stream = SubResource( 2 ) -unit_db = 14.0 +stream = ExtResource( 7 ) +pitch_scale = 0.1 bus = "Sound" [node name="Smoke" type="Particles" parent="." index="8"] @@ -173,6 +175,10 @@ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.535274, 1.89154 ) [node name="static_follow" type="Position3D" parent="." index="16"] transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.59115, -3.01375 ) +[node name="wind_sound_player" type="AudioStreamPlayer3D" parent="." index="17"] +transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.08447, 1.12391 ) +stream = ExtResource( 8 ) + [connection signal="brake_updated" from="." to="chassis/cockpit/brake_pedal" method="_on_value_updated"] [connection signal="clutch_updated" from="." to="chassis/cockpit/clutch_pedal" method="_on_value_updated"] [connection signal="rpm_updated" from="." to="chassis/cockpit/rpm_meter" method="_on_value_updated"] diff --git a/vehicles/buggy.tscn b/vehicles/buggy.tscn index e362e64..b8ac02d 100644 --- a/vehicles/buggy.tscn +++ b/vehicles/buggy.tscn @@ -5,21 +5,17 @@ [ext_resource path="res://vehicles/vehicle.gd" type="Script" id=3] [ext_resource path="res://vehicles/steering_controller.gd" type="Script" id=4] [ext_resource path="res://vehicles/meter.gd" type="Script" id=5] +[ext_resource path="res://assets/engine.wav" type="AudioStream" id=6] [ext_resource path="res://vehicles/pedal.gd" type="Script" id=7] +[ext_resource path="res://assets/wind woosh loop.ogg" type="AudioStream" id=8] [sub_resource type="Curve" id=2] _data = [ Vector2( 0, 0 ), 0.0, 0.0, 0, 0, Vector2( 0.0660377, 0.243255 ), 0.0, 0.0, 0, 0, Vector2( 0.25, 0.563636 ), 4.02975, 4.02975, 0, 0, Vector2( 0.518868, 0.761364 ), 3.22818, 3.22818, 0, 0, Vector2( 0.849057, 1 ), 0.0, 0.0, 0, 0, Vector2( 1, 0 ), 0.0, 0.0, 0, 0 ] -[sub_resource type="Curve" id=4] -_data = [ Vector2( 0, 0 ), 0.0, 0.0, 0, 0, Vector2( 0.0849057, 1 ), 0.0, 0.0, 0, 0, Vector2( 0.15566, 0.746591 ), 0.0, 0.0, 0, 0, Vector2( 0.349057, 1 ), 0.0, 0.0, 0, 0, Vector2( 0.382075, 0 ), 0.0, 0.0, 0, 0, Vector2( 0.400943, 1 ), 0.0, 0.0, 0, 0, Vector2( 0.438679, 0 ), 0.0, 0.0, 0, 0, Vector2( 1, 1 ), 0.0, 0.0, 0, 0 ] - [sub_resource type="CapsuleShape" id=11] radius = 0.452181 height = 2.78888 -[sub_resource type="AudioStreamGenerator" id=3] -mix_rate = 5500.0 - [sub_resource type="Curve" id=8] _data = [ Vector2( 0, 1 ), 0.0, 0.0, 0, 0, Vector2( 1, 0.205682 ), 0.0, 0.0, 0, 0 ] @@ -45,16 +41,18 @@ radial_segments = 4 rings = 3 [node name="buggy" groups=["car"] instance=ExtResource( 1 )] -mass = 400.0 +mass = 1400.0 script = ExtResource( 3 ) -max_engine_force = 160.0 -max_brake_force = 80.0 +max_engine_force = 550.0 +max_brake_force = 220.0 throttle_power = 10000.0 max_rpm_loss_ps = 4000.0 base_engine_pitch = 0.45 +drag_factor = 1.65 +downforce_factor = 1.1 gear_ratios = [ 3.8, 2.7, 2.2, 1.75, 1.4, 1.2 ] +max_rpm = 5000.0 power_curve = SubResource( 2 ) -sound_curve = SubResource( 4 ) automatic_gear_up_threshold = 0.85 automatic_gear_down_threshold = 0.4 @@ -90,7 +88,7 @@ use_as_traction = true use_as_steering = true wheel_radius = 0.6 wheel_rest_length = 0.68 -wheel_friction_slip = 2.0 +wheel_friction_slip = 2.25 suspension_travel = 1.2 suspension_stiffness = 4.5 suspension_max_force = 14000.0 @@ -107,7 +105,7 @@ use_as_traction = true use_as_steering = true wheel_radius = 0.6 wheel_rest_length = 0.68 -wheel_friction_slip = 2.0 +wheel_friction_slip = 2.25 suspension_travel = 1.2 suspension_stiffness = 4.5 suspension_max_force = 14000.0 @@ -121,7 +119,7 @@ transform = Transform( -1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 ) use_as_traction = true wheel_radius = 0.6 wheel_rest_length = 0.68 -wheel_friction_slip = 1.9 +wheel_friction_slip = 2.05 suspension_travel = 1.2 suspension_stiffness = 4.5 suspension_max_force = 14000.0 @@ -133,7 +131,7 @@ transform = Transform( 1, 0, 0, 0, 1, -1.50996e-07, 0, 1.50996e-07, 1, -0.950755 use_as_traction = true wheel_radius = 0.6 wheel_rest_length = 0.68 -wheel_friction_slip = 1.9 +wheel_friction_slip = 2.05 suspension_travel = 1.2 suspension_stiffness = 4.5 suspension_max_force = 14000.0 @@ -144,9 +142,9 @@ damping_relaxation = 0.94 transform = Transform( -1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 ) [node name="engine_sound_player" type="AudioStreamPlayer3D" parent="." index="7"] -transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.14201, 0.968668 ) -stream = SubResource( 3 ) -unit_db = 14.0 +transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.14201, -1.46122 ) +stream = ExtResource( 6 ) +pitch_scale = 0.1 bus = "Sound" [node name="Smoke" type="Particles" parent="." index="8"] @@ -179,6 +177,10 @@ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.811448, 1.79879 ) [node name="static_follow" type="Position3D" parent="." index="16"] transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.15146, -4.84184 ) +[node name="wind_sound_player" type="AudioStreamPlayer3D" parent="." index="17"] +transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.39214, 1.12139 ) +stream = ExtResource( 8 ) + [connection signal="brake_updated" from="." to="chassis/cockpit/brake_pedal" method="_on_value_updated"] [connection signal="clutch_updated" from="." to="chassis/cockpit/clutch_pedal" method="_on_value_updated"] [connection signal="rpm_updated" from="." to="chassis/cockpit/rpm_meter" method="_on_value_updated"] diff --git a/vehicles/bugmobile.tscn b/vehicles/bugmobile.tscn index 8bc2e46..f6c409a 100644 --- a/vehicles/bugmobile.tscn +++ b/vehicles/bugmobile.tscn @@ -6,20 +6,16 @@ [ext_resource path="res://vehicles/steering_controller.gd" type="Script" id=4] [ext_resource path="res://vehicles/pedal.gd" type="Script" id=5] [ext_resource path="res://vehicles/meter.gd" type="Script" id=6] +[ext_resource path="res://assets/engine.wav" type="AudioStream" id=7] +[ext_resource path="res://assets/wind woosh loop.ogg" type="AudioStream" id=8] [sub_resource type="Curve" id=18] _data = [ Vector2( 0, 0 ), 0.0, 0.0, 0, 0, Vector2( 0.179245, 0.584091 ), 4.91185, 4.91185, 0, 0, Vector2( 0.603774, 0.954545 ), 6.05975, 6.05975, 0, 0, Vector2( 0.806604, 0.989773 ), 0.0, 0.0, 0, 0, Vector2( 1, 0 ), 0.0, 0.0, 0, 0 ] -[sub_resource type="Curve" id=19] -_data = [ Vector2( 0, 0 ), 0.0, 0.0, 0, 0, Vector2( 0.127358, 1 ), 0.0, 0.0, 0, 0, Vector2( 0.174528, 0.65 ), 0.0, 0.0, 0, 0, Vector2( 0.212264, 1 ), 0.0, 0.0, 0, 0, Vector2( 0.353774, 0.35 ), 0.0, 0.0, 0, 0, Vector2( 0.363208, 0.968182 ), 0.0, 0.0, 0, 0, Vector2( 0.485849, 0.313636 ), 0.0, 0.0, 0, 0, Vector2( 0.627358, 0.140909 ), 0.0, 0.0, 0, 0, Vector2( 0.721698, 0.259091 ), 0.0, 0.0, 0, 0, Vector2( 0.745283, 0.623864 ), 0.0, 0.0, 0, 0, Vector2( 0.872642, 0.794318 ), 0.0, 0.0, 0, 0, Vector2( 0.915094, 0.248864 ), 0.0, 0.0, 0, 0, Vector2( 0.933962, 0.5125 ), 0.0, 0.0, 0, 0, Vector2( 1, 0 ), 0.0, 0.0, 0, 0 ] - [sub_resource type="CapsuleShape" id=20] radius = 0.274866 height = 2.75974 -[sub_resource type="AudioStreamGenerator" id=12] -mix_rate = 5500.0 - [sub_resource type="Gradient" id=13] offsets = PoolRealArray( 0, 0.5, 1 ) colors = PoolColorArray( 0, 0.278431, 0.270588, 1, 0.356863, 0.764706, 0.670588, 1, 1, 1, 1, 1 ) @@ -53,38 +49,39 @@ radial_segments = 4 rings = 3 [node name="bugmobile" groups=["car"] instance=ExtResource( 2 )] -mass = 600.0 +mass = 1900.0 script = ExtResource( 3 ) -max_engine_force = 320.0 -max_brake_force = 95.0 +max_engine_force = 1400.0 +max_brake_force = 230.0 throttle_power = 8000.0 max_rpm_loss_ps = 2200.0 base_engine_pitch = 0.65 +drag_factor = 0.85 +downforce_factor = 1.8 gear_ratios = [ 3.5, 2.95, 2.64, 2.0, 1.67, 1.42 ] final_drive = 4.36 max_rpm = 9000.0 power_curve = SubResource( 18 ) -sound_curve = SubResource( 19 ) [node name="rear_left" parent="." index="0"] use_as_traction = true wheel_radius = 0.52 wheel_rest_length = 0.47 -wheel_friction_slip = 8.0 -suspension_travel = 0.4 -suspension_stiffness = 9.0 -suspension_max_force = 7000.0 +wheel_friction_slip = 5.54 +suspension_travel = 0.35 +suspension_stiffness = 12.0 +suspension_max_force = 10000.0 damping_compression = 0.87 damping_relaxation = 0.9 [node name="front_left" parent="." index="2"] use_as_steering = true wheel_radius = 0.35 -wheel_rest_length = 0.45 -wheel_friction_slip = 7.0 -suspension_travel = 0.45 -suspension_stiffness = 12.0 -suspension_max_force = 7000.0 +wheel_rest_length = 0.47 +wheel_friction_slip = 4.45 +suspension_travel = 0.55 +suspension_stiffness = 15.0 +suspension_max_force = 15000.0 damping_compression = 0.9 damping_relaxation = 0.92 @@ -111,11 +108,11 @@ needle_path = NodePath("speed_needle") [node name="front_right" parent="." index="4"] use_as_steering = true wheel_radius = 0.35 -wheel_rest_length = 0.45 -wheel_friction_slip = 7.0 -suspension_travel = 0.45 -suspension_stiffness = 12.0 -suspension_max_force = 7000.0 +wheel_rest_length = 0.47 +wheel_friction_slip = 4.45 +suspension_travel = 0.55 +suspension_stiffness = 15.0 +suspension_max_force = 15000.0 damping_compression = 0.9 damping_relaxation = 0.92 @@ -123,10 +120,10 @@ damping_relaxation = 0.92 use_as_traction = true wheel_radius = 0.52 wheel_rest_length = 0.47 -wheel_friction_slip = 8.0 -suspension_travel = 0.4 -suspension_stiffness = 9.0 -suspension_max_force = 7000.0 +wheel_friction_slip = 5.54 +suspension_travel = 0.35 +suspension_stiffness = 12.0 +suspension_max_force = 10000.0 damping_compression = 0.87 damping_relaxation = 0.9 @@ -136,8 +133,8 @@ shape = SubResource( 20 ) [node name="engine_sound_player" type="AudioStreamPlayer3D" parent="." index="7"] transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.791119, -2.27857 ) -stream = SubResource( 12 ) -unit_db = 14.0 +stream = ExtResource( 7 ) +pitch_scale = 0.1 bus = "Sound" [node name="Smoke" type="Particles" parent="." index="8"] @@ -170,6 +167,10 @@ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.605405, 1.5324 ) [node name="static_follow" type="Position3D" parent="." index="16"] transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.88984, -4.78212 ) +[node name="wind_sound_player" type="AudioStreamPlayer3D" parent="." index="17"] +transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.18462, 0.791153 ) +stream = ExtResource( 8 ) + [connection signal="brake_updated" from="." to="chassis/cockpit/brake_pedal" method="_on_value_updated"] [connection signal="clutch_updated" from="." to="chassis/cockpit/clutch_pedal" method="_on_value_updated"] [connection signal="rpm_updated" from="." to="chassis/cockpit/steering_controller/rpm_meter" method="_on_value_updated"] diff --git a/vehicles/tire_smoke.gd b/vehicles/tire_smoke.gd index fd69dc4..4cd7985 100644 --- a/vehicles/tire_smoke.gd +++ b/vehicles/tire_smoke.gd @@ -7,24 +7,19 @@ onready var sound_playback: AudioStreamPlayback = $tire_sound_player.get_stream_ func _ready() -> void: _update_sound(1) - # sound_player.play() + sound_player.playing = true + sound_player.stream_paused = true func update(skidinfo: float) -> void: _update_sound(skidinfo) - if skidinfo < 0.5: + if skidinfo < 0.25: emitting = true + sound_player.stream_paused = false else: emitting = false + sound_player.stream_paused = true func _update_sound(skidinfo: float) -> void: - sound_player.pitch_scale = 1 + (1 - skidinfo) - var to_fill = sound_playback.get_frames_available() - var factor = (1 - skidinfo) * 2 - if to_fill <= 0: - return - while to_fill > 0: - sound_playback.push_frame(Vector2(1.0, 1.0) * factor) - factor += 1 - to_fill -= 1 + sound_player.pitch_scale = 1 + pow(skidinfo, 2) - skidinfo / 3 diff --git a/vehicles/tire_smoke.tscn b/vehicles/tire_smoke.tscn index a198a33..cfad9f9 100644 --- a/vehicles/tire_smoke.tscn +++ b/vehicles/tire_smoke.tscn @@ -1,6 +1,7 @@ [gd_scene load_steps=8 format=2] [ext_resource path="res://vehicles/tire_smoke.gd" type="Script" id=1] +[ext_resource path="res://assets/tires_squal_loop.wav" type="AudioStream" id=2] [sub_resource type="Curve" id=1] _data = [ Vector2( 0, 1 ), 0.0, 0.0, 0, 0, Vector2( 1, 0.0170454 ), 0.0, 0.0, 0, 0 ] @@ -25,9 +26,6 @@ material = SubResource( 4 ) radial_segments = 4 rings = 4 -[sub_resource type="AudioStreamGenerator" id=6] -mix_rate = 5000.0 - [node name="tire_smoke" type="Particles"] transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.541801, 0 ) emitting = false @@ -39,8 +37,7 @@ draw_pass_1 = SubResource( 5 ) script = ExtResource( 1 ) [node name="tire_sound_player" type="AudioStreamPlayer3D" parent="."] -stream = SubResource( 6 ) -unit_db = 25.0 -unit_size = 2.0 +stream = ExtResource( 2 ) +max_db = 1.0 bus = "Sound" area_mask = 2 diff --git a/vehicles/vehicle.gd b/vehicles/vehicle.gd index 632d7b1..9f01211 100644 --- a/vehicles/vehicle.gd +++ b/vehicles/vehicle.gd @@ -21,6 +21,9 @@ export(float) var max_rpm_loss_ps = 3000.0 export(float) var base_engine_pitch = 0.5 export(float) var expected_max_speed = 200 +export(float) var drag_factor = 1.0 +export(float) var downforce_factor = 1.0 + export(Array) var gear_ratios = [3.4, 2.5, 2.0, 1.5, 1.25] export(float) var reverse_ratio = -3 export(float) var final_drive = 3.45 @@ -54,7 +57,7 @@ onready var rrsmoke: TireSmoke = $rr_tire_smoke onready var rlsmoke: TireSmoke = $rl_tire_smoke onready var engine_sound_player: AudioStreamPlayer3D = $engine_sound_player -onready var engine_sound_playback: AudioStreamPlayback = $engine_sound_player.get_stream_playback() +onready var wind_sound_player: AudioStreamPlayer3D = $wind_sound_player onready var max_steer_input_rad: float = deg2rad(max_steer_input) @@ -89,6 +92,7 @@ func _ready(): _generate_engine_sound(0) engine_sound_player.play() + wind_sound_player.play() func get_cockpit_position() -> Node: @@ -198,6 +202,13 @@ func _physics_process(delta: float): if GlobalSettings.auto_clutch or GlobalSettings.automatic_transmission: clutch_position = 1 - min(rpm, auto_clutch_rpm_limit) / auto_clutch_rpm_limit + if throttle == 0.0 and linear_velocity.length() < 1: + clutch_position = 1 + + apply_central_impulse(linear_velocity * -1 * drag_factor) + apply_central_impulse( + linear_velocity.length() * -1 * global_transform.basis.y * downforce_factor + ) if gear_timer > 0: clutch_position = 1 @@ -220,6 +231,7 @@ func _physics_process(delta: float): var power_factor = power_curve.interpolate_baked(rpm_factor) _generate_engine_sound(rpm_factor) + _generate_wind_sound(speed) # Transfer to transmission var transmission_input = power_factor * (1 - clutch_position) * _get_gear_ratio() @@ -259,22 +271,12 @@ func _physics_process(delta: float): func _generate_engine_sound(rpm_factor): engine_sound_player.pitch_scale = base_engine_pitch + 2 * rpm_factor - var to_fill = engine_sound_playback.get_frames_available() - var factor = rpm_factor - if to_fill <= 0: - return - var fill_segment = 1.0 / to_fill - var fill_percent = 0.0 - while to_fill > 0: - engine_sound_playback.push_frame(Vector2(1.0, 1.0) * factor) - factor += ( - cos(factor) - * sin(factor) - * (1 + to_fill % 2) - * ((sound_curve.interpolate_baked(fill_percent) - 0.5) * 2) - ) - to_fill -= 1 - fill_percent += fill_segment + engine_sound_player.unit_db = 1 + 2 * rpm_factor + + +func _generate_wind_sound(speed): + wind_sound_player.pitch_scale = 1 + speed / 150 + wind_sound_player.unit_db = pow(speed, 2) / 1500 * (0.5 + drag_factor) - 20 func _synchronize():