Browse Source

add pickup sounds

Arnaud Vergnet 5 months ago
parent
commit
f8a8cc959d

+ 1
- 0
mini-game/ressources/sounds/LICENCE View File

@@ -0,0 +1 @@
1
+ kenney interface sounds

BIN
mini-game/ressources/sounds/error_006.wav View File


+ 21
- 0
mini-game/ressources/sounds/error_006.wav.import View File

@@ -0,0 +1,21 @@
1
+[remap]
2
+
3
+importer="wav"
4
+type="AudioStreamSample"
5
+path="res://.import/error_006.wav-438e664d4aa9fd9a3094b65b6b14697e.sample"
6
+
7
+[deps]
8
+
9
+source_file="res://mini-game/ressources/sounds/error_006.wav"
10
+dest_files=[ "res://.import/error_006.wav-438e664d4aa9fd9a3094b65b6b14697e.sample" ]
11
+
12
+[params]
13
+
14
+force/8_bit=false
15
+force/mono=false
16
+force/max_rate=false
17
+force/max_rate_hz=44100
18
+edit/trim=false
19
+edit/normalize=false
20
+edit/loop=false
21
+compress/mode=0

BIN
mini-game/ressources/sounds/select_006.wav View File


+ 21
- 0
mini-game/ressources/sounds/select_006.wav.import View File

@@ -0,0 +1,21 @@
1
+[remap]
2
+
3
+importer="wav"
4
+type="AudioStreamSample"
5
+path="res://.import/select_006.wav-751a8b3f8c877e8e8de092e911ac7aaf.sample"
6
+
7
+[deps]
8
+
9
+source_file="res://mini-game/ressources/sounds/select_006.wav"
10
+dest_files=[ "res://.import/select_006.wav-751a8b3f8c877e8e8de092e911ac7aaf.sample" ]
11
+
12
+[params]
13
+
14
+force/8_bit=false
15
+force/mono=false
16
+force/max_rate=false
17
+force/max_rate_hz=44100
18
+edit/trim=false
19
+edit/normalize=false
20
+edit/loop=false
21
+compress/mode=0

+ 0
- 2
mini-game/scenes/players/player.gd View File

@@ -78,7 +78,6 @@ func stop():
78 78
 
79 79
 
80 80
 func hit():
81
-	print("hit")
82 81
 	current_lives -= 1
83 82
 	if current_lives > 0:
84 83
 		emit_signal("hit")
@@ -88,6 +87,5 @@ func hit():
88 87
 
89 88
 
90 89
 func bonus():
91
-	print("bonus")
92 90
 	emit_signal("score")
93 91
 

+ 22
- 5
mini-game/scenes/spawner/pickup.gd View File

@@ -5,16 +5,22 @@ export var type := "bonus" setget , get_type
5 5
 export var scroll_speed = 9
6 6
 
7 7
 onready var sprite = $Sprite
8
-onready var notifier = $notifier
8
+onready var audio_stream = $AudioStreamPlayer
9
+onready var timer = $Timer
10
+
11
+var malus_sound = preload("res://mini-game/ressources/sounds/error_006.wav")
12
+var bonus_sound = preload("res://mini-game/ressources/sounds/select_006.wav")
13
+
14
+var picked_up := false
9 15
 
10 16
 
11 17
 func _ready():
12 18
 	sprite.texture = sprite_texture
13
-	notifier.connect("screen_exited", self, "_on_screen_exited")
14 19
 
15 20
 
16
-func _on_screen_exited():
17
-	queue_free()
21
+func _on_notifier_screen_exited() -> void:
22
+	if not picked_up:
23
+		queue_free()
18 24
 
19 25
 
20 26
 func _physics_process(delta):
@@ -30,7 +36,14 @@ func move():
30 36
 
31 37
 
32 38
 func pickup():
33
-	queue_free()
39
+	picked_up = true
40
+	timer.start()
41
+	sprite.hide()
42
+	if type == "bonus":
43
+		audio_stream.stream = bonus_sound
44
+	elif type == "malus":
45
+		audio_stream.stream = malus_sound
46
+	audio_stream.play()
34 47
 
35 48
 
36 49
 func _on_Area2D_body_entered(body: Node) -> void:
@@ -40,3 +53,7 @@ func _on_Area2D_body_entered(body: Node) -> void:
40 53
 			body.bonus()
41 54
 		elif type == "malus":
42 55
 			body.hit()
56
+
57
+
58
+func _on_AudioStreamPlayer_finished() -> void:
59
+	queue_free()

+ 10
- 0
mini-game/scenes/spawner/pickup.tscn View File

@@ -20,5 +20,15 @@ scale = Vector2( 0.202437, 0.202437 )
20 20
 shape = SubResource( 1 )
21 21
 
22 22
 [node name="notifier" type="VisibilityNotifier2D" parent="."]
23
+position = Vector2( 100, 0 )
24
+
25
+[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."]
26
+
27
+[node name="Timer" type="Timer" parent="."]
28
+wait_time = 3.0
29
+one_shot = true
23 30
 
24 31
 [connection signal="body_entered" from="Area2D" to="." method="_on_Area2D_body_entered"]
32
+[connection signal="screen_exited" from="notifier" to="." method="_on_notifier_screen_exited"]
33
+[connection signal="finished" from="AudioStreamPlayer" to="." method="_on_AudioStreamPlayer_finished"]
34
+[connection signal="timeout" from="Timer" to="." method="_on_Timer_timeout"]

Loading…
Cancel
Save