Adds sound effects
							parent
							
								
									9e5e9996df
								
							
						
					
					
						commit
						90bce4a792
					
				
										
											Binary file not shown.
										
									
								
							| 
						 | 
				
			
			@ -0,0 +1,24 @@
 | 
			
		|||
[remap]
 | 
			
		||||
 | 
			
		||||
importer="wav"
 | 
			
		||||
type="AudioStreamWAV"
 | 
			
		||||
uid="uid://dfjtssac5pr2f"
 | 
			
		||||
path="res://.godot/imported/Effects_r1_Click.wav-423d47dbcf9a575ad4e64ab33b3aacf4.sample"
 | 
			
		||||
 | 
			
		||||
[deps]
 | 
			
		||||
 | 
			
		||||
source_file="res://Audio/Effects_r1_Click.wav"
 | 
			
		||||
dest_files=["res://.godot/imported/Effects_r1_Click.wav-423d47dbcf9a575ad4e64ab33b3aacf4.sample"]
 | 
			
		||||
 | 
			
		||||
[params]
 | 
			
		||||
 | 
			
		||||
force/8_bit=false
 | 
			
		||||
force/mono=false
 | 
			
		||||
force/max_rate=false
 | 
			
		||||
force/max_rate_hz=44100
 | 
			
		||||
edit/trim=false
 | 
			
		||||
edit/normalize=false
 | 
			
		||||
edit/loop_mode=0
 | 
			
		||||
edit/loop_begin=0
 | 
			
		||||
edit/loop_end=-1
 | 
			
		||||
compress/mode=2
 | 
			
		||||
										
											Binary file not shown.
										
									
								
							| 
						 | 
				
			
			@ -0,0 +1,24 @@
 | 
			
		|||
[remap]
 | 
			
		||||
 | 
			
		||||
importer="wav"
 | 
			
		||||
type="AudioStreamWAV"
 | 
			
		||||
uid="uid://cxtqhjmqfv0pa"
 | 
			
		||||
path="res://.godot/imported/Effects_r1_Die.wav-0da4c697f1d544fc09053aec409dbab2.sample"
 | 
			
		||||
 | 
			
		||||
[deps]
 | 
			
		||||
 | 
			
		||||
source_file="res://Audio/Effects_r1_Die.wav"
 | 
			
		||||
dest_files=["res://.godot/imported/Effects_r1_Die.wav-0da4c697f1d544fc09053aec409dbab2.sample"]
 | 
			
		||||
 | 
			
		||||
[params]
 | 
			
		||||
 | 
			
		||||
force/8_bit=false
 | 
			
		||||
force/mono=false
 | 
			
		||||
force/max_rate=false
 | 
			
		||||
force/max_rate_hz=44100
 | 
			
		||||
edit/trim=false
 | 
			
		||||
edit/normalize=false
 | 
			
		||||
edit/loop_mode=0
 | 
			
		||||
edit/loop_begin=0
 | 
			
		||||
edit/loop_end=-1
 | 
			
		||||
compress/mode=2
 | 
			
		||||
										
											Binary file not shown.
										
									
								
							| 
						 | 
				
			
			@ -0,0 +1,24 @@
 | 
			
		|||
[remap]
 | 
			
		||||
 | 
			
		||||
importer="wav"
 | 
			
		||||
type="AudioStreamWAV"
 | 
			
		||||
uid="uid://c4641xah766fm"
 | 
			
		||||
path="res://.godot/imported/Effects_r1_Eat.wav-6d34890687ce907971ad8962b08e5605.sample"
 | 
			
		||||
 | 
			
		||||
[deps]
 | 
			
		||||
 | 
			
		||||
source_file="res://Audio/Effects_r1_Eat.wav"
 | 
			
		||||
dest_files=["res://.godot/imported/Effects_r1_Eat.wav-6d34890687ce907971ad8962b08e5605.sample"]
 | 
			
		||||
 | 
			
		||||
[params]
 | 
			
		||||
 | 
			
		||||
force/8_bit=false
 | 
			
		||||
force/mono=false
 | 
			
		||||
force/max_rate=false
 | 
			
		||||
force/max_rate_hz=44100
 | 
			
		||||
edit/trim=false
 | 
			
		||||
edit/normalize=false
 | 
			
		||||
edit/loop_mode=0
 | 
			
		||||
edit/loop_begin=0
 | 
			
		||||
edit/loop_end=-1
 | 
			
		||||
compress/mode=2
 | 
			
		||||
										
											Binary file not shown.
										
									
								
							| 
						 | 
				
			
			@ -0,0 +1,24 @@
 | 
			
		|||
[remap]
 | 
			
		||||
 | 
			
		||||
importer="wav"
 | 
			
		||||
type="AudioStreamWAV"
 | 
			
		||||
uid="uid://b4gcf5s8pvjpb"
 | 
			
		||||
path="res://.godot/imported/Effects_r1_Move.wav-d5a2cb23afa314fc1f13f09b64cb16dd.sample"
 | 
			
		||||
 | 
			
		||||
[deps]
 | 
			
		||||
 | 
			
		||||
source_file="res://Audio/Effects_r1_Move.wav"
 | 
			
		||||
dest_files=["res://.godot/imported/Effects_r1_Move.wav-d5a2cb23afa314fc1f13f09b64cb16dd.sample"]
 | 
			
		||||
 | 
			
		||||
[params]
 | 
			
		||||
 | 
			
		||||
force/8_bit=false
 | 
			
		||||
force/mono=false
 | 
			
		||||
force/max_rate=false
 | 
			
		||||
force/max_rate_hz=44100
 | 
			
		||||
edit/trim=false
 | 
			
		||||
edit/normalize=false
 | 
			
		||||
edit/loop_mode=0
 | 
			
		||||
edit/loop_begin=0
 | 
			
		||||
edit/loop_end=-1
 | 
			
		||||
compress/mode=2
 | 
			
		||||
										
											Binary file not shown.
										
									
								
							| 
						 | 
				
			
			@ -0,0 +1,24 @@
 | 
			
		|||
[remap]
 | 
			
		||||
 | 
			
		||||
importer="wav"
 | 
			
		||||
type="AudioStreamWAV"
 | 
			
		||||
uid="uid://dho48gwqlu4bl"
 | 
			
		||||
path="res://.godot/imported/Effects_r1_Ouroboros.wav-e41c271322f0cf579ffc95c947018b7e.sample"
 | 
			
		||||
 | 
			
		||||
[deps]
 | 
			
		||||
 | 
			
		||||
source_file="res://Audio/Effects_r1_Ouroboros.wav"
 | 
			
		||||
dest_files=["res://.godot/imported/Effects_r1_Ouroboros.wav-e41c271322f0cf579ffc95c947018b7e.sample"]
 | 
			
		||||
 | 
			
		||||
[params]
 | 
			
		||||
 | 
			
		||||
force/8_bit=false
 | 
			
		||||
force/mono=false
 | 
			
		||||
force/max_rate=false
 | 
			
		||||
force/max_rate_hz=44100
 | 
			
		||||
edit/trim=false
 | 
			
		||||
edit/normalize=false
 | 
			
		||||
edit/loop_mode=0
 | 
			
		||||
edit/loop_begin=0
 | 
			
		||||
edit/loop_end=-1
 | 
			
		||||
compress/mode=2
 | 
			
		||||
| 
						 | 
				
			
			@ -252,6 +252,7 @@ func check_movement() -> void:
 | 
			
		|||
	var new_position : Vector2 = (position + current_direction * TILE_SIZE).snapped(Vector2.ONE * TILE_SIZE)
 | 
			
		||||
	if not int(new_position.x) in possible_x or not int(new_position.y) in possible_y:
 | 
			
		||||
		lose_game()
 | 
			
		||||
		return
 | 
			
		||||
	
 | 
			
		||||
	# Get the correct raycast for the direction we are moving
 | 
			
		||||
	var raycast_to_use : RayCast2D
 | 
			
		||||
| 
						 | 
				
			
			@ -269,6 +270,7 @@ func check_movement() -> void:
 | 
			
		|||
	
 | 
			
		||||
	# If we found nothing, stop processing collision
 | 
			
		||||
	if object_in_path == null:
 | 
			
		||||
		SoundPlayer.play_sound("move")
 | 
			
		||||
		return
 | 
			
		||||
		
 | 
			
		||||
	# If we found a snake part, then either end the game or perform an ouroboros maneouvre
 | 
			
		||||
| 
						 | 
				
			
			@ -282,6 +284,7 @@ func check_movement() -> void:
 | 
			
		|||
		else:
 | 
			
		||||
			lose_game()
 | 
			
		||||
	if object_in_path is Fruit:
 | 
			
		||||
		SoundPlayer.play_sound("eat")
 | 
			
		||||
		queued_growth += object_in_path.growth_amount
 | 
			
		||||
		object_in_path.respawn()
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -319,12 +322,14 @@ func extend() -> void:
 | 
			
		|||
func lose_game(from_lack_of_space : bool = false) -> void:
 | 
			
		||||
	
 | 
			
		||||
	# You lose!
 | 
			
		||||
	SoundPlayer.play_sound("die")
 | 
			
		||||
	if !from_lack_of_space:
 | 
			
		||||
		state = States.DEAD
 | 
			
		||||
		on_death.emit()
 | 
			
		||||
	game_over_menu.visible = true
 | 
			
		||||
 | 
			
		||||
func ouroboros() -> void:
 | 
			
		||||
	SoundPlayer.play_sound("ouroboros")
 | 
			
		||||
	if state == States.OUROBOROS:
 | 
			
		||||
		state = States.OLD_OUROBOROS
 | 
			
		||||
	elif state == States.ALIVE:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,29 @@
 | 
			
		|||
extends Node
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
const sounds : Dictionary[String, AudioStream] = {"click": preload("res://Audio/Effects_r1_Click.wav"),
 | 
			
		||||
													"die": preload("res://Audio/Effects_r1_Die.wav"),
 | 
			
		||||
													"eat": preload("res://Audio/Effects_r1_Eat.wav"),
 | 
			
		||||
													"move": preload("res://Audio/Effects_r1_Move.wav"),
 | 
			
		||||
													"ouroboros": preload("res://Audio/Effects_r1_Ouroboros.wav")}
 | 
			
		||||
 | 
			
		||||
var players : Dictionary[String, AudioStreamPlayer] = {}
 | 
			
		||||
 | 
			
		||||
func _enter_tree() -> void:
 | 
			
		||||
	get_tree().node_added.connect(_on_node_added)
 | 
			
		||||
 | 
			
		||||
func _ready() -> void:
 | 
			
		||||
	for sound in sounds.keys():
 | 
			
		||||
		players[sound] = AudioStreamPlayer.new()
 | 
			
		||||
		players[sound].stream = sounds[sound]
 | 
			
		||||
		add_child(players[sound])
 | 
			
		||||
 | 
			
		||||
func play_sound(sound: String):
 | 
			
		||||
	if sound in sounds.keys():
 | 
			
		||||
		players[sound].play()
 | 
			
		||||
 | 
			
		||||
func _on_node_added(node:Node) -> void:
 | 
			
		||||
	if node is Button:
 | 
			
		||||
		# If the added node is a button we connect to its mouse_entered and pressed signals
 | 
			
		||||
		# and play a sound
 | 
			
		||||
		node.pressed.connect(play_sound.bind("click"))
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1 @@
 | 
			
		|||
uid://dop75ba4rrbd8
 | 
			
		||||
| 
						 | 
				
			
			@ -20,6 +20,7 @@ config/icon="res://icon.svg"
 | 
			
		|||
GridManager="*res://Scripts/grid_manager.gd"
 | 
			
		||||
GameManager="*res://Scripts/game_manager.gd"
 | 
			
		||||
MusicPlayer="*res://Scenes/music_player.tscn"
 | 
			
		||||
SoundPlayer="*res://Scripts/sound_player.gd"
 | 
			
		||||
 | 
			
		||||
[display]
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue