Browse Source

Added support for multiple random music themes

pull/4/head
TechieDamien 1 year ago
parent
commit
88eb0ef8f8
  1. BIN
      Audio/Music/Streaming2_draft_r2_session.ogg
  2. 15
      Audio/Music/Streaming2_draft_r2_session.ogg.import
  3. 2
      Scenes/RootNode.tscn
  4. 16
      Scripts/AudioStreamPlayer.gd
  5. 1
      Scripts/RootNode.gd

BIN
Audio/Music/Streaming2_draft_r2_session.ogg

15
Audio/Music/Streaming2_draft_r2_session.ogg.import

@ -0,0 +1,15 @@
[remap]
importer="ogg_vorbis"
type="AudioStreamOGGVorbis"
path="res://.import/Streaming2_draft_r2_session.ogg-979b5a41f4df6d7ab3dc1c40adf88c6b.oggstr"
[deps]
source_file="res://Audio/Music/Streaming2_draft_r2_session.ogg"
dest_files=[ "res://.import/Streaming2_draft_r2_session.ogg-979b5a41f4df6d7ab3dc1c40adf88c6b.oggstr" ]
[params]
loop=true
loop_offset=0

2
Scenes/RootNode.tscn

@ -34,3 +34,5 @@ stream = ExtResource( 5 )
autoplay = true
bus = "Music"
script = ExtResource( 4 )
[connection signal="finished" from="AudioStreamPlayer" to="AudioStreamPlayer" method="_on_finished"]

16
Scripts/AudioStreamPlayer.gd

@ -4,14 +4,20 @@ var mute_status : bool = false
var main_theme : AudioStreamOGGVorbis = preload("res://Audio/Music/SpaceMainTheme_r1_session.ogg")
var combat_theme : AudioStreamOGGVorbis = preload("res://Audio/Music/CombatThemeLBRY_r1_session.ogg")
var streaming_2 : AudioStreamOGGVorbis = preload("res://Audio/Music/Streaming2_draft_r2_session.ogg")
var music_dict = {"main" : main_theme, "combat" : combat_theme}
var music_dict = {"main" : [ main_theme ], "combat" : [ combat_theme, streaming_2 ]}
var current_music_array : String = "main"
func switch_theme(name : String) -> void:
if name in music_dict.keys():
stream = music_dict[name]
var music_list = music_dict[name]
music_list.shuffle()
stream = music_list[0]
current_music_array = name
else:
get_parent().console_print("Could not find music of name, " + name)
get_parent().console_print("Could not find music array of name, " + name)
playing = true
func _process(delta : float) -> void:
@ -22,3 +28,7 @@ func _process(delta : float) -> void:
AudioServer.set_bus_mute(AudioServer.get_bus_index("Master"), true)
mute_status = !mute_status
func _on_finished():
switch_theme(current_music_array)

1
Scripts/RootNode.gd

@ -12,6 +12,7 @@ var name_dict = {}
var color_dict = {}
func _ready() -> void:
randomize()
get_tree().connect("connected_to_server", self, "_connected_to_server")
get_tree().connect("server_disconnected", self, "_server_disconnected")
get_tree().connect("connection_failed", self, "_connection_failed")

Loading…
Cancel
Save