Skip to content

Commit

Permalink
Issue-139: Loop music tracks, Add cicadas track to Main Menu
Browse files Browse the repository at this point in the history
  • Loading branch information
Tysterman74 committed Dec 18, 2024
1 parent 67856e9 commit fab9dbb
Show file tree
Hide file tree
Showing 13 changed files with 50 additions and 18 deletions.
4 changes: 4 additions & 0 deletions #Scenes/SceneScripts/MainMenu.gd
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ var continue_button: TextureButton

#on opening the main menu we grab the focus of the start button
func _ready() -> void:
AudioManager.start_music(GlobalEnums.MusicTrack.MAIN_MENU)
$"Menu buttons/Continue".grab_focus()
$"game version".text = ProjectSettings.get_setting("application/config/version")
for child in get_node("Menu buttons").get_children():
Expand All @@ -22,11 +23,13 @@ func _on_start_pressed() -> void:
if SaveManager.has_saved_data():
start_new_game_dialog.show()
else:
AudioManager.stop_music()
_init_managers()
SceneManager.goto_scene("res://#Scenes/MapUI.tscn")

func _on_continue_pressed() -> void:
if SaveManager.has_saved_data():
AudioManager.stop_music()
PlayerManager.load_player()
MapManager.load_map_data()
XpManager.load_data()
Expand Down Expand Up @@ -55,6 +58,7 @@ func _on_credits_pressed() -> void:

func _on_start_new_game_dialog_confirmed() -> void:
SaveManager.clear_data()
AudioManager.stop_music()
_init_managers()
SceneManager.goto_scene("res://#Scenes/MapUI.tscn")

Expand Down
13 changes: 4 additions & 9 deletions #Scenes/SceneScripts/TestingScene.gd
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,15 @@ func _ready() -> void:
PhaseManager.initialize_game()

func _play_music() -> void:
var number_of_floors: float = MapManager.get_floors()

# Offset by 1 since it's reading from an array
var current_player_floor: float = PlayerManager.player_position.y + 1

var percentage_complete: float = (current_player_floor / number_of_floors) * 100
var percentage_complete: float = MapManager.get_map_percent_with_player_position()
var music_track: GlobalEnums.MusicTrack
if percentage_complete <= 33:
if MapManager.is_on_last_floor():
music_track = GlobalEnums.MusicTrack.BOSS
elif percentage_complete <= 33:
music_track = GlobalEnums.MusicTrack.AREA_ONE
elif percentage_complete > 33 and percentage_complete <= 66:
music_track = GlobalEnums.MusicTrack.AREA_TWO
elif percentage_complete > 66 and percentage_complete <= 99:
music_track = GlobalEnums.MusicTrack.AREA_THREE
else:
music_track = GlobalEnums.MusicTrack.BOSS

AudioManager.start_music(music_track)
2 changes: 1 addition & 1 deletion Audio/Battle/area_1.wav.import
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_mode=2
edit/loop_begin=0
edit/loop_end=-1
compress/mode=0
2 changes: 1 addition & 1 deletion Audio/Battle/area_2.wav.import
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_mode=2
edit/loop_begin=0
edit/loop_end=-1
compress/mode=0
2 changes: 1 addition & 1 deletion Audio/Battle/area_3.wav.import
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_mode=2
edit/loop_begin=0
edit/loop_end=-1
compress/mode=0
2 changes: 1 addition & 1 deletion Audio/Battle/boss_1.wav.import
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_mode=2
edit/loop_begin=0
edit/loop_end=-1
compress/mode=0
Binary file added Audio/MainMenu/cicadas.wav
Binary file not shown.
24 changes: 24 additions & 0 deletions Audio/MainMenu/cicadas.wav.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[remap]

importer="wav"
type="AudioStreamWAV"
uid="uid://dn4vvohka34oa"
path="res://.godot/imported/cicadas.wav-dcbeb09c6e6173bc4f40cabe17efe450.sample"

[deps]

source_file="res://Audio/MainMenu/cicadas.wav"
dest_files=["res://.godot/imported/cicadas.wav-dcbeb09c6e6173bc4f40cabe17efe450.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=2
edit/loop_begin=0
edit/loop_end=-1
compress/mode=0
2 changes: 1 addition & 1 deletion Audio/World/heal.wav.import
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_mode=2
edit/loop_begin=0
edit/loop_end=-1
compress/mode=0
2 changes: 1 addition & 1 deletion Audio/World/shop.wav.import
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_mode=2
edit/loop_begin=0
edit/loop_end=-1
compress/mode=0
1 change: 1 addition & 0 deletions Global/Global_Enums.gd
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ enum MusicTrack {
BOSS,
HEAL,
SHOP,
MAIN_MENU,
NO_TRACK
}

Expand Down
5 changes: 4 additions & 1 deletion Managers/AudioManager.gd
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@ var battle_area_3: AudioStream = preload("res://Audio/Battle/area_3.wav")
var boss: AudioStream = preload("res://Audio/Battle/boss_1.wav")
var heal_event: AudioStream = preload("res://Audio/World/heal.wav")
var shop_event: AudioStream = preload("res://Audio/World/shop.wav")
var main_menu: AudioStream = preload("res://Audio/MainMenu/cicadas.wav")

var music_dictionary: Dictionary = {
GlobalEnums.MusicTrack.AREA_ONE: battle_area_1,
GlobalEnums.MusicTrack.AREA_TWO: battle_area_2,
GlobalEnums.MusicTrack.AREA_THREE: battle_area_3,
GlobalEnums.MusicTrack.BOSS: boss,
GlobalEnums.MusicTrack.HEAL: heal_event,
GlobalEnums.MusicTrack.SHOP: shop_event
GlobalEnums.MusicTrack.SHOP: shop_event,
GlobalEnums.MusicTrack.MAIN_MENU: main_menu
}

# SFX
Expand All @@ -31,6 +33,7 @@ var sfx_stream: AudioStreamPlayer2D = AudioStreamPlayer2D.new()
var current_song: GlobalEnums.MusicTrack = GlobalEnums.MusicTrack.NO_TRACK

func _ready() -> void:
music_stream
add_child(music_stream)
add_child(sfx_stream)

Expand Down
9 changes: 7 additions & 2 deletions Managers/MapManager.gd
Original file line number Diff line number Diff line change
Expand Up @@ -301,5 +301,10 @@ func get_map_percent_with_player_position() -> float:
var player_y_floor: int = player_position.y
return (player_y_floor as float / number_of_floors as float) * 100

func get_floors() -> int:
return map_width_array.size()
func is_on_last_floor() -> bool:
var number_of_floors: int = map_width_array.size()

# Add one since we want to compare the number of floors and player position is zero-index based
var player_position_y: int = PlayerManager.player_position.y + 1

return number_of_floors == player_position_y

0 comments on commit fab9dbb

Please sign in to comment.