From a9351e06215092a415a7f8295e06cb7df5256a0c Mon Sep 17 00:00:00 2001 From: Manuel Date: Sun, 1 Oct 2023 18:46:42 +0200 Subject: [PATCH 1/8] Update gitattributes --- .gitattributes | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitattributes b/.gitattributes index d87dcff..430478a 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,9 +1,8 @@ # Normalize EOL for all files that Git considers text files. * text=auto eol=lf - # Track files for Git LFS assets/**/*.wav filter=lfs diff=lfs merge=lfs -text +assets/**/*.ogg filter=lfs diff=lfs merge=lfs -text assets/**/*.psd filter=lfs diff=lfs merge=lfs -text -assets/**/*.png filter=lfs diff=lfs merge=lfs -text assets/**/*.otf filter=lfs diff=lfs merge=lfs -text assets/**/*.ttf filter=lfs diff=lfs merge=lfs -text From b464cb5dd40f8398a9981c57f5bacd5b197d6d9a Mon Sep 17 00:00:00 2001 From: mtrx Date: Sun, 1 Oct 2023 20:19:18 +0200 Subject: [PATCH 2/8] added and imported music and engine sounds --- assets/sounds/music/death by waveshaper.wav | 3 +++ .../music/death by waveshaper.wav.import | 24 +++++++++++++++++++ assets/sounds/sfx/engine_loop.wav | 3 +++ assets/sounds/sfx/engine_loop.wav.import | 24 +++++++++++++++++++ icon.svg.import | 2 +- src/game/level1.tscn | 8 ++++++- src/game/player.tscn | 8 ++++++- 7 files changed, 69 insertions(+), 3 deletions(-) create mode 100644 assets/sounds/music/death by waveshaper.wav create mode 100644 assets/sounds/music/death by waveshaper.wav.import create mode 100644 assets/sounds/sfx/engine_loop.wav create mode 100644 assets/sounds/sfx/engine_loop.wav.import diff --git a/assets/sounds/music/death by waveshaper.wav b/assets/sounds/music/death by waveshaper.wav new file mode 100644 index 0000000..27fe10d --- /dev/null +++ b/assets/sounds/music/death by waveshaper.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c2ca2978ecbdd78206fbadbb42840140bb8ce5571da1010b2b73205572ec5d32 +size 27648182 diff --git a/assets/sounds/music/death by waveshaper.wav.import b/assets/sounds/music/death by waveshaper.wav.import new file mode 100644 index 0000000..f2872df --- /dev/null +++ b/assets/sounds/music/death by waveshaper.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://dh5jxxwim7ra8" +path="res://.godot/imported/death by waveshaper.wav-51c938cbbb32e2797b875bc10a7238da.sample" + +[deps] + +source_file="res://assets/sounds/music/death by waveshaper.wav" +dest_files=["res://.godot/imported/death by waveshaper.wav-51c938cbbb32e2797b875bc10a7238da.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_mode=2 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=0 diff --git a/assets/sounds/sfx/engine_loop.wav b/assets/sounds/sfx/engine_loop.wav new file mode 100644 index 0000000..7b543ca --- /dev/null +++ b/assets/sounds/sfx/engine_loop.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e29c9250034f511f5fd460b7587b2c374876923a33ecb46ef6a0eb674c0f2613 +size 6144236 diff --git a/assets/sounds/sfx/engine_loop.wav.import b/assets/sounds/sfx/engine_loop.wav.import new file mode 100644 index 0000000..282d9e5 --- /dev/null +++ b/assets/sounds/sfx/engine_loop.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://cc4ffx6b0xjvk" +path="res://.godot/imported/engine_loop.wav-259955cdefdf44f318b80661126b8c7f.sample" + +[deps] + +source_file="res://assets/sounds/sfx/engine_loop.wav" +dest_files=["res://.godot/imported/engine_loop.wav-259955cdefdf44f318b80661126b8c7f.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_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=0 diff --git a/icon.svg.import b/icon.svg.import index f2b876d..c0e29db 100644 --- a/icon.svg.import +++ b/icon.svg.import @@ -16,9 +16,9 @@ dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.cte [params] compress/mode=0 +compress/high_quality=false compress/lossy_quality=0.7 compress/hdr_compression=1 -compress/bptc_ldr=0 compress/normal_map=0 compress/channel_pack=0 mipmaps/generate=false diff --git a/src/game/level1.tscn b/src/game/level1.tscn index 2dabe48..09fd3f3 100644 --- a/src/game/level1.tscn +++ b/src/game/level1.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=9 format=3 uid="uid://c77xk0mywwt5f"] +[gd_scene load_steps=10 format=3 uid="uid://c77xk0mywwt5f"] [ext_resource type="Script" path="res://src/game/level.gd" id="1_hv75i"] [ext_resource type="PackedScene" uid="uid://ckau5s2tsb3oc" path="res://src/game/player.tscn" id="2_5nf51"] @@ -7,6 +7,7 @@ [ext_resource type="Texture2D" uid="uid://ds0un04pocx6i" path="res://assets/track90.png" id="3_jtw40"] [ext_resource type="Texture2D" uid="uid://dmcrms0qu0mtt" path="res://assets/finish2.png" id="4_rxurh"] [ext_resource type="Texture2D" uid="uid://bq151lkkfdlf4" path="res://assets/sign.png" id="7_g24mp"] +[ext_resource type="AudioStream" uid="uid://dh5jxxwim7ra8" path="res://assets/sounds/music/death by waveshaper.wav" id="8_vdrjw"] [sub_resource type="Curve2D" id="Curve2D_ll8bj"] _data = { @@ -77,5 +78,10 @@ color = Color(1, 0.0627451, 0.694118, 1) energy = 20.0 texture = ExtResource("7_g24mp") +[node name="level_music" type="AudioStreamPlayer" parent="."] +stream = ExtResource("8_vdrjw") +volume_db = -29.953 +autoplay = true + [connection signal="distance_changed" from="." to="CanvasLayer/hud" method="_on_level_distance_changed"] [connection signal="speed_changed" from="player" to="CanvasLayer/hud" method="_on_player_speed_changed"] diff --git a/src/game/player.tscn b/src/game/player.tscn index a13bdb4..6e79158 100644 --- a/src/game/player.tscn +++ b/src/game/player.tscn @@ -1,8 +1,9 @@ -[gd_scene load_steps=5 format=3 uid="uid://ckau5s2tsb3oc"] +[gd_scene load_steps=6 format=3 uid="uid://ckau5s2tsb3oc"] [ext_resource type="Script" path="res://src/game/player_controller.gd" id="1_g4ij8"] [ext_resource type="Texture2D" uid="uid://d1t1g7hyil82v" path="res://assets/spracer.png" id="2_xal47"] [ext_resource type="Texture2D" uid="uid://ceqcsof04vhqs" path="res://assets/light.png" id="3_qosw5"] +[ext_resource type="AudioStream" uid="uid://cc4ffx6b0xjvk" path="res://assets/sounds/sfx/engine_loop.wav" id="4_4ajo8"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_w2nj7"] size = Vector2(36, 20) @@ -38,3 +39,8 @@ rotation = 1.5708 ignore_rotation = false rotation_smoothing_enabled = true rotation_smoothing_speed = 10.0 + +[node name="engine_sounds" type="AudioStreamPlayer" parent="."] +stream = ExtResource("4_4ajo8") +volume_db = -40.467 +autoplay = true From d35c97905aa58bc427ebbce9b6309e99c263eb52 Mon Sep 17 00:00:00 2001 From: mtrx Date: Sun, 1 Oct 2023 20:20:59 +0200 Subject: [PATCH 3/8] renamed the music file because fuck empty spaces --- .../{death by waveshaper.wav => death_by_waveshaper.wav} | 0 ...waveshaper.wav.import => death_by_waveshaper.wav.import} | 6 +++--- src/game/level1.tscn | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) rename assets/sounds/music/{death by waveshaper.wav => death_by_waveshaper.wav} (100%) rename assets/sounds/music/{death by waveshaper.wav.import => death_by_waveshaper.wav.import} (51%) diff --git a/assets/sounds/music/death by waveshaper.wav b/assets/sounds/music/death_by_waveshaper.wav similarity index 100% rename from assets/sounds/music/death by waveshaper.wav rename to assets/sounds/music/death_by_waveshaper.wav diff --git a/assets/sounds/music/death by waveshaper.wav.import b/assets/sounds/music/death_by_waveshaper.wav.import similarity index 51% rename from assets/sounds/music/death by waveshaper.wav.import rename to assets/sounds/music/death_by_waveshaper.wav.import index f2872df..63b9e36 100644 --- a/assets/sounds/music/death by waveshaper.wav.import +++ b/assets/sounds/music/death_by_waveshaper.wav.import @@ -3,12 +3,12 @@ importer="wav" type="AudioStreamWAV" uid="uid://dh5jxxwim7ra8" -path="res://.godot/imported/death by waveshaper.wav-51c938cbbb32e2797b875bc10a7238da.sample" +path="res://.godot/imported/death_by_waveshaper.wav-567c957cfc006d82d2a62bba8a331108.sample" [deps] -source_file="res://assets/sounds/music/death by waveshaper.wav" -dest_files=["res://.godot/imported/death by waveshaper.wav-51c938cbbb32e2797b875bc10a7238da.sample"] +source_file="res://assets/sounds/music/death_by_waveshaper.wav" +dest_files=["res://.godot/imported/death_by_waveshaper.wav-567c957cfc006d82d2a62bba8a331108.sample"] [params] diff --git a/src/game/level1.tscn b/src/game/level1.tscn index 09fd3f3..9a402a2 100644 --- a/src/game/level1.tscn +++ b/src/game/level1.tscn @@ -7,7 +7,7 @@ [ext_resource type="Texture2D" uid="uid://ds0un04pocx6i" path="res://assets/track90.png" id="3_jtw40"] [ext_resource type="Texture2D" uid="uid://dmcrms0qu0mtt" path="res://assets/finish2.png" id="4_rxurh"] [ext_resource type="Texture2D" uid="uid://bq151lkkfdlf4" path="res://assets/sign.png" id="7_g24mp"] -[ext_resource type="AudioStream" uid="uid://dh5jxxwim7ra8" path="res://assets/sounds/music/death by waveshaper.wav" id="8_vdrjw"] +[ext_resource type="AudioStream" uid="uid://dh5jxxwim7ra8" path="res://assets/sounds/music/death_by_waveshaper.wav" id="8_ppkte"] [sub_resource type="Curve2D" id="Curve2D_ll8bj"] _data = { @@ -79,7 +79,7 @@ energy = 20.0 texture = ExtResource("7_g24mp") [node name="level_music" type="AudioStreamPlayer" parent="."] -stream = ExtResource("8_vdrjw") +stream = ExtResource("8_ppkte") volume_db = -29.953 autoplay = true From 5db669e428c20d4b24f7280da692acbd3d5fbc16 Mon Sep 17 00:00:00 2001 From: KingGurke Date: Sun, 1 Oct 2023 21:04:33 +0200 Subject: [PATCH 4/8] Added auto pitch-shift to engine sound --- src/game/player_controller.gd | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/game/player_controller.gd b/src/game/player_controller.gd index 430953a..9b3a210 100644 --- a/src/game/player_controller.gd +++ b/src/game/player_controller.gd @@ -70,10 +70,15 @@ func _process(delta): if !Input.is_action_pressed("brake"): momentum = Vector2(1,0).rotated(rotation) * momentum.length() - camera.position = Vector2((momentum.length() / max_speed) * camera_offset, 0) + camera.position = Vector2(get_speed_proportion() * camera_offset, 0) camera.rotation_degrees = momentum.angle() + 90 + $engine_sounds.pitch_scale = get_speed_proportion() * 1.2 + if momentum.length() > max_speed: momentum = momentum.normalized() * max_speed speed_changed.emit(momentum.length()) move_and_collide(momentum * delta) + +func get_speed_proportion(): + return (momentum.length() / max_speed) From 7805ce1c328c62890d13ef85f3e2937d4dd3adb0 Mon Sep 17 00:00:00 2001 From: KingGurke Date: Sun, 1 Oct 2023 21:06:56 +0200 Subject: [PATCH 5/8] fixed engine sound errors --- src/game/player_controller.gd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/game/player_controller.gd b/src/game/player_controller.gd index 9b3a210..73cfaa7 100644 --- a/src/game/player_controller.gd +++ b/src/game/player_controller.gd @@ -73,7 +73,7 @@ func _process(delta): camera.position = Vector2(get_speed_proportion() * camera_offset, 0) camera.rotation_degrees = momentum.angle() + 90 - $engine_sounds.pitch_scale = get_speed_proportion() * 1.2 + $engine_sounds.pitch_scale = get_speed_proportion() + .2 if momentum.length() > max_speed: momentum = momentum.normalized() * max_speed From fa8861d6a1d3946a6c4ff3b24cf8765ec4059afb Mon Sep 17 00:00:00 2001 From: mtrx Date: Sun, 1 Oct 2023 21:07:09 +0200 Subject: [PATCH 6/8] implemented death sounds --- assets/sounds/sfx/damage.wav | 3 +++ assets/sounds/sfx/damage.wav.import | 24 ++++++++++++++++++++++++ assets/sounds/sfx/death_sound.wav | 3 +++ assets/sounds/sfx/death_sound.wav.import | 24 ++++++++++++++++++++++++ src/game/level.gd | 4 ++++ src/game/player.tscn | 12 +++++++++++- 6 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 assets/sounds/sfx/damage.wav create mode 100644 assets/sounds/sfx/damage.wav.import create mode 100644 assets/sounds/sfx/death_sound.wav create mode 100644 assets/sounds/sfx/death_sound.wav.import diff --git a/assets/sounds/sfx/damage.wav b/assets/sounds/sfx/damage.wav new file mode 100644 index 0000000..632a773 --- /dev/null +++ b/assets/sounds/sfx/damage.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3ff3a8d723fbfb1f55647f11699550b2e231a5d0d019363af080ef7d4761c60c +size 6531664 diff --git a/assets/sounds/sfx/damage.wav.import b/assets/sounds/sfx/damage.wav.import new file mode 100644 index 0000000..7174bf2 --- /dev/null +++ b/assets/sounds/sfx/damage.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://c7laud048l1is" +path="res://.godot/imported/damage.wav-8c4919c614aee00fc00121daa2bc247e.sample" + +[deps] + +source_file="res://assets/sounds/sfx/damage.wav" +dest_files=["res://.godot/imported/damage.wav-8c4919c614aee00fc00121daa2bc247e.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_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=0 diff --git a/assets/sounds/sfx/death_sound.wav b/assets/sounds/sfx/death_sound.wav new file mode 100644 index 0000000..35b7fb3 --- /dev/null +++ b/assets/sounds/sfx/death_sound.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3b917e1df02f73c7e23e4e062cfec4182ada3ad1c82dfaf69f4ac8ccf458d956 +size 9315610 diff --git a/assets/sounds/sfx/death_sound.wav.import b/assets/sounds/sfx/death_sound.wav.import new file mode 100644 index 0000000..1a483c3 --- /dev/null +++ b/assets/sounds/sfx/death_sound.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://c6dy6nea6vaa4" +path="res://.godot/imported/death_sound.wav-74c3ac4e551e080446bef315f79faff8.sample" + +[deps] + +source_file="res://assets/sounds/sfx/death_sound.wav" +dest_files=["res://.godot/imported/death_sound.wav-74c3ac4e551e080446bef315f79faff8.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_mode=1 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=0 diff --git a/src/game/level.gd b/src/game/level.gd index 420caeb..3e81c09 100644 --- a/src/game/level.gd +++ b/src/game/level.gd @@ -96,5 +96,9 @@ func get_total_distance(): return lap_distance + last_offset func game_over(): + running = false + $player/death_sound.play() print_debug("final score: ", get_total_distance()) + await get_tree().create_timer(3).timeout + get_tree().reload_current_scene() #temp diff --git a/src/game/player.tscn b/src/game/player.tscn index 6e79158..4db5106 100644 --- a/src/game/player.tscn +++ b/src/game/player.tscn @@ -1,9 +1,11 @@ -[gd_scene load_steps=6 format=3 uid="uid://ckau5s2tsb3oc"] +[gd_scene load_steps=8 format=3 uid="uid://ckau5s2tsb3oc"] [ext_resource type="Script" path="res://src/game/player_controller.gd" id="1_g4ij8"] [ext_resource type="Texture2D" uid="uid://d1t1g7hyil82v" path="res://assets/spracer.png" id="2_xal47"] [ext_resource type="Texture2D" uid="uid://ceqcsof04vhqs" path="res://assets/light.png" id="3_qosw5"] [ext_resource type="AudioStream" uid="uid://cc4ffx6b0xjvk" path="res://assets/sounds/sfx/engine_loop.wav" id="4_4ajo8"] +[ext_resource type="AudioStream" uid="uid://c7laud048l1is" path="res://assets/sounds/sfx/damage.wav" id="5_rvolc"] +[ext_resource type="AudioStream" uid="uid://c6dy6nea6vaa4" path="res://assets/sounds/sfx/death_sound.wav" id="6_i0vg5"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_w2nj7"] size = Vector2(36, 20) @@ -44,3 +46,11 @@ rotation_smoothing_speed = 10.0 stream = ExtResource("4_4ajo8") volume_db = -40.467 autoplay = true + +[node name="damage_sounds" type="AudioStreamPlayer" parent="."] +stream = ExtResource("5_rvolc") +volume_db = -25.297 + +[node name="death_sound" type="AudioStreamPlayer" parent="."] +stream = ExtResource("6_i0vg5") +volume_db = -25.297 From 131f2472b796af71d4b93e64d7c365ab71115819 Mon Sep 17 00:00:00 2001 From: KingGurke Date: Sun, 1 Oct 2023 21:22:37 +0200 Subject: [PATCH 7/8] Added death "animation" --- src/game/level.gd | 1 + src/game/player_controller.gd | 77 ++++++++++++++++++----------------- 2 files changed, 41 insertions(+), 37 deletions(-) diff --git a/src/game/level.gd b/src/game/level.gd index 3e81c09..fc8bdad 100644 --- a/src/game/level.gd +++ b/src/game/level.gd @@ -97,6 +97,7 @@ func get_total_distance(): func game_over(): running = false + player.dead = true $player/death_sound.play() print_debug("final score: ", get_total_distance()) await get_tree().create_timer(3).timeout diff --git a/src/game/player_controller.gd b/src/game/player_controller.gd index 73cfaa7..d8c38d1 100644 --- a/src/game/player_controller.gd +++ b/src/game/player_controller.gd @@ -25,6 +25,7 @@ extends StaticBody2D # variables var momentum: Vector2 #var direction = 0 # 1 for forward, 0 for standing still, -1 for reverse +var dead = false signal speed_changed(new_speed) @@ -35,46 +36,48 @@ func _ready(): # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta): - var acc_d = acc * delta - var dec_d = dec * delta - var rev_d = rev * delta - var turn_d = turn_speed * delta - var brake_d = brake_strength * delta - var turn_factor = 1 - - if momentum.length() > dec_d: - momentum -= momentum.normalized()*dec_d - else: - momentum = Vector2(0,0) - - if Input.is_action_pressed("accelerate"): - momentum += acc_d * Vector2(1,0).rotated(rotation) - -# if Input.is_action_pressed("reverse"): -# print_debug("reverse vector: ", rev_d * Vector2(-1,0).rotated(rotation)) -# momentum += rev_d * Vector2(-1,0).rotated(rotation) -# print_debug("momentum vector = ", momentum) - - if Input.is_action_pressed("brake"): - turn_factor = drift_factor - if momentum.length() > brake_d: - momentum -= momentum.normalized() * brake_d + if !dead: + var acc_d = acc * delta + var dec_d = dec * delta + var rev_d = rev * delta + var turn_d = turn_speed * delta + var brake_d = brake_strength * delta + var turn_factor = 1 + + if momentum.length() > dec_d: + momentum -= momentum.normalized()*dec_d else: momentum = Vector2(0,0) - - if Input.is_action_pressed("left"): - rotate(turn_d*turn_factor*-1) - if Input.is_action_pressed("right"): - rotate(turn_d*turn_factor) - if !Input.is_action_pressed("brake"): - momentum = Vector2(1,0).rotated(rotation) * momentum.length() - - camera.position = Vector2(get_speed_proportion() * camera_offset, 0) - camera.rotation_degrees = momentum.angle() + 90 - - $engine_sounds.pitch_scale = get_speed_proportion() + .2 - + if Input.is_action_pressed("accelerate"): + momentum += acc_d * Vector2(1,0).rotated(rotation) + + # if Input.is_action_pressed("reverse"): + # print_debug("reverse vector: ", rev_d * Vector2(-1,0).rotated(rotation)) + # momentum += rev_d * Vector2(-1,0).rotated(rotation) + # print_debug("momentum vector = ", momentum) + + if Input.is_action_pressed("brake"): + turn_factor = drift_factor + if momentum.length() > brake_d: + momentum -= momentum.normalized() * brake_d + else: + momentum = Vector2(0,0) + + if Input.is_action_pressed("left"): + rotate(turn_d*turn_factor*-1) + if Input.is_action_pressed("right"): + rotate(turn_d*turn_factor) + + if !Input.is_action_pressed("brake"): + momentum = Vector2(1,0).rotated(rotation) * momentum.length() + + camera.position = Vector2(get_speed_proportion() * camera_offset, 0) + camera.rotation_degrees = momentum.angle() + 90 + + $engine_sounds.pitch_scale = get_speed_proportion() + .2 + else: + rotate(PI*delta) if momentum.length() > max_speed: momentum = momentum.normalized() * max_speed speed_changed.emit(momentum.length()) From 687604fc054965ceb81bf5299befc599e0bb90ed Mon Sep 17 00:00:00 2001 From: KingGurke Date: Sun, 1 Oct 2023 21:31:28 +0200 Subject: [PATCH 8/8] Added slowdown during death --- src/game/player_controller.gd | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/game/player_controller.gd b/src/game/player_controller.gd index d8c38d1..a362dbb 100644 --- a/src/game/player_controller.gd +++ b/src/game/player_controller.gd @@ -36,19 +36,19 @@ func _ready(): # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta): + var dec_d = dec * delta + if momentum.length() > dec_d: + momentum -= momentum.normalized()*dec_d + else: + momentum = Vector2(0,0) + if !dead: var acc_d = acc * delta - var dec_d = dec * delta var rev_d = rev * delta var turn_d = turn_speed * delta var brake_d = brake_strength * delta var turn_factor = 1 - if momentum.length() > dec_d: - momentum -= momentum.normalized()*dec_d - else: - momentum = Vector2(0,0) - if Input.is_action_pressed("accelerate"): momentum += acc_d * Vector2(1,0).rotated(rotation) @@ -77,7 +77,7 @@ func _process(delta): $engine_sounds.pitch_scale = get_speed_proportion() + .2 else: - rotate(PI*delta) + rotate(PI*delta * get_speed_proportion()) if momentum.length() > max_speed: momentum = momentum.normalized() * max_speed speed_changed.emit(momentum.length())