
Dim Shared As Single t_step_02
t_step_02 = Timer

Dim As String CrashBox_Path = "./data/sound/crash_box4.ogg"
CheckFilePath(CrashBox_Path)
Dim As String gathering_Path = "./data/sound/gathering.ogg"
CheckFilePath(gathering_Path)
Dim As String Colocal2_Path = "./data/sound/Colocal2.ogg"
CheckFilePath(Colocal2_Path)
Dim As String crash_hero1_Path = "./data/sound/crash_hero1.ogg"
CheckFilePath(crash_hero1_Path)
Dim As String step_stone_02_Path = "./data/sound/step_stone_02.ogg"
CheckFilePath(step_stone_02_Path)

Dim As String portal1_Path = "./data/sound/portal1.ogg"
CheckFilePath(portal1_Path)
Dim As String victory1_Path = "./data/sound/victory1.ogg"
CheckFilePath(victory1_Path)




Dim Shared As wSound CrashBox1
CrashBox1 = wSoundLoad(CrashBox_Path, FALSE)
Dim Shared As wSound gathering1
gathering1 = wSoundLoad(gathering_Path, FALSE)
Dim Shared As wSound Colocal2
Colocal2 = wSoundLoad(Colocal2_Path, FALSE)
Dim Shared As wSound crash_hero1
crash_hero1 = wSoundLoad(crash_hero1_Path, FALSE)
'Dim As wSoundBuffer crash_hero1_buf
'crash_hero1_buf = wSoundBufferLoad(crash_hero1_Path)
'crash_hero1 = wSoundCreateFromBuffer (crash_hero1_buf)
Dim Shared As wSound step_stone_02
step_stone_02 = wSoundLoad(step_stone_02_Path, FALSE)
Dim Shared As wSound portal1
portal1 = wSoundLoad(portal1_Path, FALSE)
Dim Shared As wSound victory1
victory1 = wSoundLoad(victory1_Path, FALSE)



Declare Sub CrashBox()
Declare Sub gathering()
Declare Sub Colocal_2()
Declare Sub crash_hero()
Declare Sub step_stone_2()
Declare Sub portal_1()
Declare Sub victory_1()


Dim Shared As boolean bSound = TRUE


Sub SetVolume1(ss1 As wSound)
  wSoundSetMaxVolume(ss1,1.f)
  wSoundSetVolume(ss1,1.f)
  wSoundSetRelative(ss1, TRUE)
End Sub

Sub CrashBox()
  ' Звук разрушения куба
  If Not bSound Then Exit Sub
  'If wSoundIsPlaying(CrashBox1) Then Exit Sub
  SetVolume1(CrashBox1)
  wSoundPlay(CrashBox1, FALSE)
End Sub

Sub gathering()
  ' Звук сбора кристаллов
  If Not bSound Then Exit Sub
  'If wSoundIsPlaying(gathering1) Then Exit Sub
  SetVolume1(gathering1)
  wSoundPlay(gathering1, FALSE)
End Sub

Sub Colocal_2()
  ' Звук сбора кристаллов
  If Not bSound Then Exit Sub
  If wSoundIsPlaying(Colocal2) Then Exit Sub
  SetVolume1(Colocal2)
  wSoundPlay(Colocal2, FALSE)
End Sub

Sub crash_hero()
  ' Звук падения героя
  If Not bSound Then Exit Sub
  If wSoundIsPlaying(crash_hero1) Then Exit Sub
  SetVolume1(crash_hero1)
  wSoundPlay(crash_hero1, FALSE)
End Sub

Sub step_stone_2()
  ' Звук шагов
  If Not bSound Then Exit Sub
  If t_step_02 > Timer Then Exit Sub
  t_step_02 = Timer + 0.4
  If wSoundIsPlaying(step_stone_02) Then Exit Sub
  SetVolume1(step_stone_02)
  wSoundPlay(step_stone_02, FALSE)  
End Sub

Sub portal_1()
  ' Звук входа в портал 1
  If Not bSound Then Exit Sub
  If wSoundIsPlaying(portal1) Then Exit Sub
  SetVolume1(portal1)
  wSoundPlay(portal1, FALSE)
  Do
    If Not wSoundIsPlaying(portal1) Then
      victory_1()
      Exit Do
    EndIf
  Loop
End Sub

Sub victory_1()
  ' Звук победы (уровень пройден)
  If Not bSound Then Exit Sub
  If wSoundIsPlaying(victory1) Then Exit Sub
  SetVolume1(victory1)
  wSoundPlay(victory1, FALSE)     
End Sub
