diff --git a/assest/fx/Running on Concrete with Tennis Shoes.ogg b/assest/fx/Running on Concrete with Tennis Shoes.ogg new file mode 100644 index 0000000..5b45a82 Binary files /dev/null and b/assest/fx/Running on Concrete with Tennis Shoes.ogg differ diff --git a/assest/fx/Running on Concrete with Tennis Shoes.ogg.import b/assest/fx/Running on Concrete with Tennis Shoes.ogg.import new file mode 100644 index 0000000..bc5dda8 --- /dev/null +++ b/assest/fx/Running on Concrete with Tennis Shoes.ogg.import @@ -0,0 +1,19 @@ +[remap] + +importer="oggvorbisstr" +type="AudioStreamOggVorbis" +uid="uid://bwja5fpawbgjq" +path="res://.godot/imported/Running on Concrete with Tennis Shoes.ogg-449625040c9614f99c697bcaa74e8272.oggvorbisstr" + +[deps] + +source_file="res://assest/fx/Running on Concrete with Tennis Shoes.ogg" +dest_files=["res://.godot/imported/Running on Concrete with Tennis Shoes.ogg-449625040c9614f99c697bcaa74e8272.oggvorbisstr"] + +[params] + +loop=true +loop_offset=0.0 +bpm=0.0 +beat_count=0 +bar_beats=4 diff --git a/buildings/bakery.gd b/buildings/bakery.gd index cc95bbf..59acf7b 100644 --- a/buildings/bakery.gd +++ b/buildings/bakery.gd @@ -2,5 +2,5 @@ extends TileMapLayer func do_trap(): GameState.position_bakery = Vector2(506.361, 843.8615) - GameState._game.switch_scene("bakery") + GameState._game.switch_to("bakery") GameState.hasVisitedBakery = true diff --git a/caracters/bob/bob.tscn b/caracters/bob/bob.tscn index d9c0281..cbd89ff 100644 --- a/caracters/bob/bob.tscn +++ b/caracters/bob/bob.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=19 format=3 uid="uid://bleadp4yrdgj"] +[gd_scene load_steps=20 format=3 uid="uid://bleadp4yrdgj"] [ext_resource type="Script" path="res://caracters/human.gd" id="1_x3vfc"] [ext_resource type="AnimationNodeStateMachine" uid="uid://ddr1ltkievtku" path="res://animations/human/human_state_machine.tres" id="2_86nrf"] @@ -12,6 +12,7 @@ [ext_resource type="Resource" uid="uid://vg4mssby1i6p" path="res://caracters/bob/bob.dialogue" id="9_d5408"] [ext_resource type="PackedScene" uid="uid://dn10ervwv15oo" path="res://UI/clues/bubble_clue.tscn" id="10_rm4iv"] [ext_resource type="PackedScene" uid="uid://cjm4k0fv7eger" path="res://caracters/human_pathfinder.tscn" id="11_ubech"] +[ext_resource type="AudioStream" uid="uid://bwja5fpawbgjq" path="res://assest/fx/Running on Concrete with Tennis Shoes.ogg" id="13_7opcx"] [sub_resource type="CapsuleShape2D" id="CapsuleShape2D_a4vmx"] radius = 5.0 @@ -99,6 +100,11 @@ position = Vector2(44, -38) [node name="pathFinder" parent="." instance=ExtResource("11_ubech")] +[node name="FeetSound" type="AudioStreamPlayer2D" parent="."] +stream = ExtResource("13_7opcx") +autoplay = true +stream_paused = true + [connection signal="start_intracting" from="." to="npcControler" method="_on_character_body_2d_start_intracting"] [connection signal="area_entered" from="detector" to="." method="_on_area_2d_area_entered"] [connection signal="body_entered" from="detector" to="." method="_on_area_2d_body_entered"] diff --git a/caracters/human.gd b/caracters/human.gd index b8a61ec..77f4858 100644 --- a/caracters/human.gd +++ b/caracters/human.gd @@ -12,6 +12,7 @@ var humanInteractionTarget: Human = null @onready var animation_player := $AnimationPlayer @onready var state_machine := animation_tree.get("parameters/HumanState/playback") as AnimationNodeStateMachinePlayback @onready var interactionZone : InteractionZone = $"interaction zone" +@onready var feetSound = $FeetSound var interactionClueFor : Human var interactionPaused= false @@ -64,6 +65,9 @@ func _physics_process(delta): # compute the direction the player wants to look at if velocity: last_facing_direction = velocity.normalized() + feetSound.stream_paused = false + else: + feetSound.stream_paused = true updateFacingDirectionInAnimationTree() @@ -109,3 +113,5 @@ func disable_interaction_clue(): func _on_load_from_game_state() -> void: emit_signal("loadFromGameState") + feetSound.play() + feetSound.stream_paused = true diff --git a/caracters/musicians/Thomas.tscn b/caracters/musicians/Thomas.tscn index e62aecb..8ef6976 100644 --- a/caracters/musicians/Thomas.tscn +++ b/caracters/musicians/Thomas.tscn @@ -2,7 +2,22 @@ [ext_resource type="Texture2D" uid="uid://0yybe0v6bkv1" path="res://assest/musicians/Subway_Busker_2_48x48.png" id="1_dq5dt"] [ext_resource type="Script" path="res://caracters/musicians/thomas.gd" id="1_it5tv"] -[ext_resource type="AudioStream" uid="uid://bdj7nbrv8f53m" path="res://assest/music/balade du grand nord.ogg" id="2_6pcth"] +[ext_resource type="AudioStream" uid="uid://bpm1d70babypo" path="res://assest/music/chartreuse blues.ogg" id="3_redb5"] + +[sub_resource type="Animation" id="Animation_2qywv"] +length = 0.001 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("Sprite2D:frame") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [0] +} [sub_resource type="Animation" id="Animation_k8n4u"] resource_name = "play" @@ -21,21 +36,6 @@ tracks/0/keys = { "values": [0, 1, 2, 3, 4, 6, 7, 6, 7, 8, 9, 10, 11] } -[sub_resource type="Animation" id="Animation_2qywv"] -length = 0.001 -tracks/0/type = "value" -tracks/0/imported = false -tracks/0/enabled = true -tracks/0/path = NodePath("Sprite2D:frame") -tracks/0/interp = 1 -tracks/0/loop_wrap = true -tracks/0/keys = { -"times": PackedFloat32Array(0), -"transitions": PackedFloat32Array(1), -"update": 1, -"values": [0] -} - [sub_resource type="AnimationLibrary" id="AnimationLibrary_v18ad"] _data = { "RESET": SubResource("Animation_2qywv"), @@ -64,11 +64,11 @@ rotation = 1.5708 shape = SubResource("CapsuleShape2D_0816g") [node name="AudioStreamPlayer2D" type="AudioStreamPlayer2D" parent="."] -stream = ExtResource("2_6pcth") +stream = ExtResource("3_redb5") volume_db = 1.0 autoplay = true -max_distance = 1000.0 -attenuation = 2.0 +stream_paused = true +playback_type = 1 parameters/looping = false [connection signal="finished" from="AudioStreamPlayer2D" to="." method="_on_audio_stream_player_2d_finished"] diff --git a/caracters/musicians/thomas.gd b/caracters/musicians/thomas.gd index 40ce14a..b625a88 100644 --- a/caracters/musicians/thomas.gd +++ b/caracters/musicians/thomas.gd @@ -6,7 +6,7 @@ var songs = [ "res://assest/music/balade du grand nord.ogg", ] -var current_song = -1 +var current_song = 0 func _ready() -> void: $AnimationPlayer.play("play") @@ -14,15 +14,19 @@ func _ready() -> void: func _process(delta: float) -> void: if $AudioStreamPlayer2D.get_playback_position() != 0: GameState.float_thomas_music_position = $AudioStreamPlayer2D.get_playback_position() + var stream : AudioStream = $AudioStreamPlayer2D.stream + if stream: + var l = stream.get_length() + if is_zero_approx(l - GameState.float_thomas_music_position): + play_next_song() func _on_load_from_game_state() -> void: - $AudioStreamPlayer2D.play(GameState.float_thomas_music_position) - -func _on_audio_stream_player_2d_finished() -> void: - play_next_song() + if GameState.float_thomas_music_position > 1: + $AudioStreamPlayer2D.seek(GameState.float_thomas_music_position) + print("resume from pause ", songs[current_song], "at ", GameState.float_thomas_music_position) + $AudioStreamPlayer2D.stream_paused = false func play_next_song(): - $AudioStreamPlayer2D.stop() current_song += 1 if current_song == songs.size(): current_song = 0 @@ -30,4 +34,7 @@ func play_next_song(): $AudioStreamPlayer2D.stream= load(songs[current_song]); GameState.float_thomas_music_position = 0 $AudioStreamPlayer2D.play(GameState.float_thomas_music_position) - $AnimationPlayer.play("play") + + +func _on_outside_unload_from_screen() -> void: + $AudioStreamPlayer2D.stream_paused = true diff --git a/caracters/player/player.tscn b/caracters/player/player.tscn index 9681db9..ab609b4 100644 --- a/caracters/player/player.tscn +++ b/caracters/player/player.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=13 format=3 uid="uid://vclpg4e4ql54"] +[gd_scene load_steps=14 format=3 uid="uid://vclpg4e4ql54"] [ext_resource type="Script" path="res://caracters/human.gd" id="1_l1sti"] [ext_resource type="Script" path="res://caracters/player/player_controler.gd" id="1_oapm5"] @@ -7,6 +7,7 @@ [ext_resource type="PackedScene" uid="uid://cg4dhp7qe68pt" path="res://animations/human/human.tscn" id="4_rsj36"] [ext_resource type="PackedScene" uid="uid://brh7cqaxc13ie" path="res://zindex/ZIndexControler.tscn" id="5_pb07x"] [ext_resource type="PackedScene" uid="uid://cjm4k0fv7eger" path="res://caracters/human_pathfinder.tscn" id="7_g6pgs"] +[ext_resource type="AudioStream" uid="uid://bwja5fpawbgjq" path="res://assest/fx/Running on Concrete with Tennis Shoes.ogg" id="8_73an3"] [sub_resource type="CapsuleShape2D" id="CapsuleShape2D_a4vmx"] radius = 5.0 @@ -95,6 +96,12 @@ collide_with_bodies = false [node name="PathFinder" parent="." instance=ExtResource("7_g6pgs")] can_walk_on_roads = true +[node name="FeetSound" type="AudioStreamPlayer" parent="."] +stream = ExtResource("8_73an3") +autoplay = true +stream_paused = true +playback_type = 1 + [connection signal="loadFromGameState" from="." to="controleur" method="_on_character_body_2d_load_from_game_state"] [connection signal="area_entered" from="Area2D" to="." method="_on_area_2d_area_entered"] [connection signal="area_entered" from="Area2D" to="controleur" method="_on_declencheur"] diff --git a/export_presets.cfg b/export_presets.cfg index 044695b..e6d9de9 100644 --- a/export_presets.cfg +++ b/export_presets.cfg @@ -3,7 +3,7 @@ name="Web" platform="Web" runnable=true -advanced_options=false +advanced_options=true dedicated_server=false custom_features="" export_filter="all_resources" @@ -21,7 +21,7 @@ script_export_mode=2 custom_template/debug="" custom_template/release="" variant/extensions_support=false -variant/thread_support=false +variant/thread_support=true vram_texture_compression/for_desktop=false vram_texture_compression/for_mobile=false html/export_icon=true diff --git a/game_state.gd b/game_state.gd index 4bdeb18..e2ac5ac 100644 --- a/game_state.gd +++ b/game_state.gd @@ -10,7 +10,7 @@ var hasVisitedBakery = false var isPlayerDeaf = false -var float_thomas_music_position = 5 +var float_thomas_music_position = 0 var current_scene = "outside" var position_outside = Vector2(-171, -253) diff --git a/scenes/bakery.gd b/scenes/bakery.gd index 5f1409f..e8ed28c 100644 --- a/scenes/bakery.gd +++ b/scenes/bakery.gd @@ -1,6 +1,7 @@ extends Node2D signal loadFromGameState +signal unloadFromScreen # Called when the node enters the scene tree for the first time. func _ready() -> void: @@ -9,3 +10,6 @@ func _ready() -> void: func load_from_game_state(): $Bakery/player.set_feet_global_position(GameState.position_bakery) emit_signal("loadFromGameState") + +func unload(): + emit_signal("unloadFromScreen") diff --git a/scenes/game.gd b/scenes/game.gd index ba4a206..723ba9e 100644 --- a/scenes/game.gd +++ b/scenes/game.gd @@ -17,7 +17,10 @@ func _ready() -> void: func start_game(): menu = get_child(0) - switch_scene(GameState.current_scene) + switch_to(GameState.current_scene) + +func switch_to(to: String): + call_deferred("switch_scene", to) func switch_scene(to: String): var prev = get_child(0) @@ -32,8 +35,12 @@ func switch_scene(to: String): if bakery == null: bakery = dest_bakery.instantiate() scene = bakery - add_child(scene) - remove_child(prev) + scene.unload() + call_deferred("add_child", scene) + call_deferred("remove_child", prev) + call_deferred("init_scence", scene) + +func init_scence(scene): scene.load_from_game_state() func open_menu(): diff --git a/scenes/outside.gd b/scenes/outside.gd index 94c1f2b..731cbb7 100644 --- a/scenes/outside.gd +++ b/scenes/outside.gd @@ -1,6 +1,7 @@ extends Node2D signal loadFromGameState +signal unloadFromScreen # Called when the node enters the scene tree for the first time. func _ready() -> void: @@ -8,3 +9,6 @@ func _ready() -> void: func load_from_game_state(): emit_signal("loadFromGameState") + +func unload(): + emit_signal("unloadFromScreen") diff --git a/scenes/outside.tscn b/scenes/outside.tscn index 8d9cb6d..443d1c6 100644 --- a/scenes/outside.tscn +++ b/scenes/outside.tscn @@ -73,3 +73,4 @@ position = Vector2(-142, -510) [connection signal="loadFromGameState" from="." to="world/player" method="_on_load_from_game_state"] [connection signal="loadFromGameState" from="." to="Thomas" method="_on_load_from_game_state"] +[connection signal="unloadFromScreen" from="." to="Thomas" method="_on_outside_unload_from_screen"] diff --git a/vehicules/car.gd b/vehicules/car.gd index f393f57..97cbd9c 100644 --- a/vehicules/car.gd +++ b/vehicules/car.gd @@ -29,7 +29,10 @@ func _ready() -> void: # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta: float) -> void: - $AudioStreamPlayer2D.pitch_scale = current_speed / speed + var pitch = current_speed / speed + if is_zero_approx(pitch): + pitch = 0.01 + $AudioStreamPlayer2D.pitch_scale = pitch $ZIndexControler/ShapeCast2D.enabled = !$CollisionHorizontal.disabled var accelerationStep = (speed * delta / timeToChangeVelocity) diff --git a/vehicules/car.tscn b/vehicules/car.tscn index 323b460..c228280 100644 --- a/vehicules/car.tscn +++ b/vehicules/car.tscn @@ -563,7 +563,6 @@ debugLabel = NodePath("Label") texture = ExtResource("4_0kman") hframes = 12 vframes = 4 -frame = 46 [node name="AnimationPlayer" type="AnimationPlayer" parent="."] root_node = NodePath("../..") @@ -589,7 +588,6 @@ shape = SubResource("CapsuleShape2D_l8rwt") position = Vector2(1, 2) rotation = -3.14159 shape = SubResource("CapsuleShape2D_l8rwt") -disabled = true [node name="Label" type="Label" parent="."] offset_left = 72.0 @@ -606,8 +604,9 @@ target_position = Vector2(1, -32) [node name="AudioStreamPlayer2D" type="AudioStreamPlayer2D" parent="."] stream = ExtResource("4_o8ske") -volume_db = -20.8 +volume_db = -15.359 autoplay = true attenuation = 2.0 +playback_type = 1 [connection signal="finished" from="AudioStreamPlayer2D" to="." method="_on_audio_stream_player_2d_finished"]