;*****************************************************************************************************
; Progam name : Intro_Screen.pb
; Version     : 1.00
; Build       : 0001
; PB Version  : 5.62
; Auther      : B.J.Fernhout.
; Copyright   : None
; Date        : 2018
; Discription : Let the intro screen making a sinus wave so the word is slowly come to screen
;             :
;             :
;*****************************************************************************************************

Procedure SetWave()
  Protected x,y,d.f
  
  ;Claim screen until animation is done
  Repeat
    ClearScreen(0)
    ;Im_MainScreen
    For y = 0 To 479
      Im_TheLine = GrabImage(Im_MainScreen,#PB_Any,0,y,640,1)
      x = Sin(d)*WaveDepth
      StartDrawing(ScreenOutput())
      DrawImage(ImageID(Im_TheLine),x,y)
      StopDrawing()
      FreeImage(Im_TheLine)
      d+0.25
    Next 
    FlipBuffers()
    WaveDepth -0.5
    ;Is escape a option
    ExamineKeyboard()
    If KeyboardPushed(#PB_Key_Escape)
      Old_Step = Active_Case
      Active_Case = 25
      ProcedureReturn
    EndIf
    If KeyboardPushed(#PB_Key_Space)
      ;Player want to start the game
      Active_Case = 5
      ProcedureReturn
    EndIf 
  Until WaveDepth <= 0
  Active_case = 2
  WaveDepth = 20.0
  
EndProcedure
Procedure TurnOnSoundPlay()
  StopSound(Snd_Battle)
  PlaySound(Snd_Colums,#PB_Sound_Loop,Set_VolumeMusic)
EndProcedure
Procedure Intro()
  TurnOnSoundPlay()
  SetWave()
EndProcedure
;=====================================================================================================
; The How To call
;=====================================================================================================

Procedure HowTo()
  Protected WaitTime = ElapsedMilliseconds() + 20000
  ClearScreen(0)
  StartDrawing(ScreenOutput())
  DrawImage(ImageID(Im_HowTo),0,0)
  StopDrawing()
  FlipBuffers()
  Repeat
    ExamineKeyboard()
    If KeyboardPushed(#PB_Key_Escape)
      ;Player want to quit the game
      Old_Step = Active_Case
      Active_Case = 25
      ProcedureReturn
    EndIf
    If KeyboardPushed(#PB_Key_Space)
      ;Player want to start the game
      Active_Case = 5
      ProcedureReturn
    EndIf 
  Until ElapsedMilliseconds() > WaitTime
  Active_Case = 1  
  
EndProcedure






; IDE Options = PureBasic 5.62 (Windows - x64)
; CursorPosition = 78
; Folding = w
; EnableXP
; CompileSourceDirectory
; EnableCompileCount = 5
; EnableBuildCount = 0
; EnableExeConstant