;*****************************************************************************************************
; Progam name : GameOverQuit.pb
; Version     : 1.00
; Build       : 0001
; PB Version  : 5.62
; Auther      : B.J.Fernhout.
; Copyright   : None
; Date        : 2018
; Discription : Execute the game over work here and if its needed also the quit procedure.
;             :
;             :
;*****************************************************************************************************

;=====================================================================================================
; Game over and is the player the best player
;=====================================================================================================
Procedure ShowGameOver()
  Protected X.f,test.i
  Protected Backup_Screen
  ;Shift text ove screen
  x=-150
  FlipBuffers()
  Backup_Screen = GrabSprite(#PB_Any,0,0,640,480)
  ;test = GrabImage(ScreenID,#PB_Any,0,0,640,480)
  CycleTime_Start = ElapsedMilliseconds()
  Repeat
    ClearScreen(0)
    DisplaySprite(Backup_Screen,0,0)
    ;StartDrawing(ScreenOutput())
    ;DrawImage(ImageID(Backup_Screen),0,0)
    ;DrawingMode(#PB_2DDrawing_AlphaBlend)
    ;RGBA(0,0,0,0)
    ;DrawAlphaImage(ImageID(im_Game_Over),140,x)
    DisplayTransparentSprite(Im_Game_Over,140,x)
    x + ((MoveTopScore + 0.05)* CycleTime_Verschil)
    StopDrawing()
    FlipBuffers()
    ;Calculate the time use to cycle trough this code for smooth animation
    CycleTime_End = ElapsedMilliseconds()
    CycleTime_Verschil = CycleTime_End - CycleTime_Start
    CycleTime_Start = CycleTime_End
  Until x >= 200

EndProcedure
Procedure ReloadTable()
  
  If HighScoreIn = #False
    LoadTable()
  EndIf
  
EndProcedure
Procedure DoGameOver()
  
  ShowGameOver()
  ReloadTable()
  InsertPlayer(TestScore())
  
EndProcedure


;=====================================================================================================
; Quit the game maybe here
;=====================================================================================================
Procedure DoQuit()
  
  DisplayTransparentSprite(Im_Cursor,MouseX(),MouseY())
  If MSGBox(220,200,200,75,RGB(5,199,33) ,RGB(28,15,193),"Exit Colums","Do you want to stop?",6)=2
    End
  Else
    Terminate_Game = #False
    Active_Case = Old_Step
  EndIf
 
EndProcedure



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