extends Node

# Persistent background music player
var music_player: AudioStreamPlayer

func _ready():
	# Create audio player
	music_player = AudioStreamPlayer.new()
	music_player.stream = preload("res://assets/sounds/music.mp3")
	music_player.bus = &"Master"
	music_player.volume_db = -15.0  # Lower volume (moderate level)
	add_child(music_player)
	
	# Play music if not already playing
	if not music_player.playing:
		music_player.play()

func set_volume(volume_db: float):
	"""Adjust music volume"""
	music_player.volume_db = volume_db

func stop_music():
	"""Stop the music"""
	music_player.stop()

func play_music():
	"""Resume music playback"""
	if not music_player.playing:
		music_player.play()
