Browse Source

add pickup sounds

Arnaud Vergnet 2 years ago
parent
commit
f8a8cc959d

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

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

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

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
 
78
 
79
 
79
 
80
 func hit():
80
 func hit():
81
-	print("hit")
82
 	current_lives -= 1
81
 	current_lives -= 1
83
 	if current_lives > 0:
82
 	if current_lives > 0:
84
 		emit_signal("hit")
83
 		emit_signal("hit")
88
 
87
 
89
 
88
 
90
 func bonus():
89
 func bonus():
91
-	print("bonus")
92
 	emit_signal("score")
90
 	emit_signal("score")
93
 
91
 

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

5
 export var scroll_speed = 9
5
 export var scroll_speed = 9
6
 
6
 
7
 onready var sprite = $Sprite
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
 func _ready():
17
 func _ready():
12
 	sprite.texture = sprite_texture
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
 func _physics_process(delta):
26
 func _physics_process(delta):
30
 
36
 
31
 
37
 
32
 func pickup():
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
 func _on_Area2D_body_entered(body: Node) -> void:
49
 func _on_Area2D_body_entered(body: Node) -> void:
40
 			body.bonus()
53
 			body.bonus()
41
 		elif type == "malus":
54
 		elif type == "malus":
42
 			body.hit()
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
 shape = SubResource( 1 )
20
 shape = SubResource( 1 )
21
 
21
 
22
 [node name="notifier" type="VisibilityNotifier2D" parent="."]
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
 [connection signal="body_entered" from="Area2D" to="." method="_on_Area2D_body_entered"]
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