PirateTreasureHunt/scenes/MusicPlayer.gd

23 lines
595 B
GDScript
Raw Normal View History

2021-07-21 22:08:42 +02:00
extends AudioStreamPlayer
onready var songs = [
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"),
preload("res://audio/music/yas_looperman-l-2550509-0151182-goin-on-an-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()