Add in-game audio during play and scoring

This commit is contained in:
James Skemp 2023-12-10 08:35:15 -06:00
parent 9931322539
commit 01c4522b86
5 changed files with 19 additions and 3 deletions

View File

@ -12,7 +12,7 @@ dest_files=["res://.godot/imported/engine.mp3-ec4632a4a290670a03ee4d3ad37bfce9.m
[params]
loop=false
loop=true
loop_offset=0
bpm=0
beat_count=0

View File

@ -34,6 +34,8 @@ func spawn_pipes() -> void:
func on_game_over():
#GameManager.load_main_scene()
stop_pipes()
$EngineSound.stop()
$GameOverSound.play()
func stop_pipes():

View File

@ -1,10 +1,12 @@
[gd_scene load_steps=7 format=3 uid="uid://d2had6j0ul7hn"]
[gd_scene load_steps=9 format=3 uid="uid://d2had6j0ul7hn"]
[ext_resource type="Texture2D" uid="uid://b5plspvrerf8c" path="res://assets/background/rocks_2.png" id="1_kihwf"]
[ext_resource type="Script" path="res://game/game.gd" id="1_mh8bq"]
[ext_resource type="PackedScene" uid="uid://dnu582ov5o310" path="res://plane/plane.tscn" id="2_xl0om"]
[ext_resource type="PackedScene" uid="uid://bed61tdnf2vq7" path="res://pipes/pipes.tscn" id="3_njdgd"]
[ext_resource type="PackedScene" uid="uid://bjx4v08mh6uhy" path="res://game_over/game_over.tscn" id="5_pro41"]
[ext_resource type="AudioStream" uid="uid://cyxd4egjwfkbr" path="res://assets/audio/engine.mp3" id="6_amryi"]
[ext_resource type="AudioStream" uid="uid://bmg81go7777oe" path="res://assets/audio/game_over.wav" id="7_45rto"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_1my5e"]
size = Vector2(499, 20)
@ -44,4 +46,11 @@ autostart = true
[node name="GameOver" parent="CanvasLayer" instance=ExtResource("5_pro41")]
visible = false
[node name="EngineSound" type="AudioStreamPlayer" parent="."]
stream = ExtResource("6_amryi")
autoplay = true
[node name="GameOverSound" type="AudioStreamPlayer" parent="."]
stream = ExtResource("7_45rto")
[connection signal="timeout" from="SpawnTimer" to="." method="_on_spawn_timer_timeout"]

View File

@ -27,4 +27,5 @@ func _on_laser_body_entered(body):
func player_scored() -> void:
$ScoreSound.play()
GameManager.increment_score()

View File

@ -1,8 +1,9 @@
[gd_scene load_steps=4 format=3 uid="uid://bed61tdnf2vq7"]
[gd_scene load_steps=5 format=3 uid="uid://bed61tdnf2vq7"]
[ext_resource type="PackedScene" uid="uid://cghqa6oqopnoa" path="res://laser/laser.tscn" id="1_5ih1f"]
[ext_resource type="Script" path="res://pipes/pipes.gd" id="1_7yx7d"]
[ext_resource type="PackedScene" uid="uid://c6je6eoh4he67" path="res://pipe/pipe.tscn" id="2_ww0io"]
[ext_resource type="AudioStream" uid="uid://c7tnekfxcmjhl" path="res://assets/audio/score.wav" id="4_ece2i"]
[node name="Pipes" type="Node2D"]
script = ExtResource("1_7yx7d")
@ -19,6 +20,9 @@ position = Vector2(0, 80)
[node name="VisibleOnScreenNotifier2D" type="VisibleOnScreenNotifier2D" parent="."]
position = Vector2(90, 0)
[node name="ScoreSound" type="AudioStreamPlayer" parent="."]
stream = ExtResource("4_ece2i")
[connection signal="body_entered" from="Laser" to="." method="_on_laser_body_entered"]
[connection signal="body_entered" from="UpperPipe" to="." method="_on_pipe_body_entered"]
[connection signal="body_entered" from="LowerPipe" to="." method="_on_pipe_body_entered"]