des bruits de pas

tralala
This commit is contained in:
Thomas
2025-03-31 17:24:16 +02:00
parent b091bb96db
commit 6517dd744e
16 changed files with 102 additions and 39 deletions

Binary file not shown.

View File

@@ -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

View File

@@ -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

View File

@@ -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"]

View File

@@ -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

View File

@@ -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"]

View File

@@ -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()
func _on_load_from_game_state() -> void:
$AudioStreamPlayer2D.play(GameState.float_thomas_music_position)
func _on_audio_stream_player_2d_finished() -> void:
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:
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

View File

@@ -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"]

View File

@@ -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

View File

@@ -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)

View File

@@ -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")

View File

@@ -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():

View File

@@ -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")

View File

@@ -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"]

View File

@@ -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)

View File

@@ -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"]