Handle background music

This commit is contained in:
Aaron 2011-08-20 21:40:04 +02:00
parent 2a633da757
commit a6f3e9a3e2
2 changed files with 13 additions and 5 deletions

View file

@ -28,10 +28,7 @@ Global GFXLogo.i
Global GFXTileset.i Global GFXTileset.i
; Sounds ; Sounds
Global MenuSoundStarted = 0
LoadSound(0, #DATA_PATH + "sound/menu_change.wav") LoadSound(0, #DATA_PATH + "sound/menu_change.wav")
LoadSound(1, #DATA_PATH + "sound/menu_select.wav") LoadSound(1, #DATA_PATH + "sound/menu_select.wav")
LoadSound(2, #DATA_PATH + "sound/title_song.wav")
; Images
UseJPEGImageDecoder()
Debug LoadImage(#Tile01, #DATA_PATH+"gfx/tileset01.jpg")

View file

@ -83,6 +83,17 @@ If OpenWindow(0, 0, 0, Screen\Width, Screen\Height, title, #PB_Window_ScreenCent
Define Event = WindowEvent() Define Event = WindowEvent()
Until Event = 0 Until Event = 0
; Handle the background music
If CurrentState = "MAIN_MENU" Or CurrentState = "RLY_QUIT"
If MenuSoundStarted = 0
MenuSoundStarted = PlaySound(2, #PB_Sound_MultiChannel|#PB_Sound_Loop)
SoundVolume(2, 70, MenuSoundStarted)
EndIf
Else
StopSound(2, MenuSoundStarted)
MenuSoundStarted = 0
EndIf
; Handle global events ; Handle global events
ExamineKeyboard() ExamineKeyboard()
If KeyboardReleased(#PB_Key_F) If KeyboardReleased(#PB_Key_F)