PirateTreasureHunt/scenes/MusicPlayer.gd

23 lines
610 B
GDScript

extends AudioStreamPlayer
onready var songs = [
preload("res://audio/music/edit_looperman-l-2353443-0126764-yungkimchi-adventure-synthwave-arp.mp3"),
preload("res://audio/music/edit_looperman-l-2648038-0125430-imthewizzy-adventure.mp3"),
preload("res://audio/music/edit_looperman-l-2762820-0244446-nick-mira-type-8bit-adventure.mp3")
]
# Called when the node enters the scene tree for the first time.
func _ready():
pass
func _on_World_level_started():
if songs == null:
return
stop()
var rng = RandomNumberGenerator.new()
rng.randomize()
stream = songs[rng.randi() % len(songs)]
play()