Remarque: J'ai utilisé ton code, j'ai juste ajouté quelques code.
2 solutions
Première solution avec un compteur
Code : Tout sélectionner
EnableExplicit
If InitSprite()=0 Or InitKeyboard()=0 Or InitSound()=0
MessageRequester("Erreur", "Impossible d'initialiser le jeux ")
End
EndIf
;--- Les Constantes
Enumeration Windows
#Main_Window
EndEnumeration
Enumeration texte
#TexteRejouer
EndEnumeration
Global gEvent,gWidth=800,gHeight=600,gfont
gFont = LoadFont(0, "Arial", 18, #PB_Font_Bold )
Global Currentime,TimeElapsed,Chrono=1000 ; 1000 millisecondes soit une seconde
;---Création de la surface du jeu
OpenWindow(#Main_Window,0,0,gWidth,gHeight,"test",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(#Main_Window),0,0,gWidth,gHeight)
Procedure Affichetext()
CreateSprite(#TexteRejouer,90,50,#PB_Sprite_AlphaBlending)
StartDrawing(SpriteOutput(#TexteRejouer))
DrawingFont(gFont)
DrawText(0,10,"TEST ",RGBA(255,255,255,255),RGBA(0,0,0,0));
StopDrawing()
EndProcedure
Affichetext()
; On relève le temps avent la boucle principale
Currentime=ElapsedMilliseconds()
Repeat
Repeat
gEvent=WindowEvent()
Select gEvent
Case #PB_Event_CloseWindow
End
EndSelect
Until gEvent=0
;--- Partie 2D
ClearScreen(RGB(0, 0, 0))
; ICi je calcul le temps écoulé
TimeElapsed=ElapsedMilliseconds()-Currentime
; Ici je teste que le temps est inférieur à la limite décidée
If TimeElapsed<Chrono
DisplayTransparentSprite(#TexteRejouer, 150, 10)
EndIf
ExamineKeyboard()
FlipBuffers()
Until KeyboardReleased(#PB_Key_Escape)
End
Deuxième solution en utilisant un WindwosTime
Code : Tout sélectionner
EnableExplicit
If InitSprite()=0 Or InitKeyboard()=0 Or InitSound()=0
MessageRequester("Erreur", "Impossible d'initialiser le jeux ")
End
EndIf
;--- Les Constantes
Enumeration Windows
#Main_Window
EndEnumeration
#Timer=0
Enumeration texte
#TexteRejouer
EndEnumeration
Global gEvent,gWidth=800,gHeight=600,gfont
Global DisplayTxtOn=#True
gFont = LoadFont(0, "Arial", 18, #PB_Font_Bold )
; Une procédure qu sera appelée quand le temps est écoulé
Procedure CallBackTimer()
DisplayTxtOn=#False
RemoveWindowTimer(#Main_Window,#Timer)
EndProcedure
;---Création de la surface du jeu
OpenWindow(#Main_Window,0,0,gWidth,gHeight,"test",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(#Main_Window),0,0,gWidth,gHeight)
; J'atoute un timer à la fenêtre
AddWindowTimer(#Main_Window,#Timer,1000)
BindEvent(#PB_Event_Timer,@CallBackTimer(),#Main_Window)
Procedure Affichetext()
CreateSprite(#TexteRejouer,90,50,#PB_Sprite_AlphaBlending)
StartDrawing(SpriteOutput(#TexteRejouer))
DrawingFont(gFont)
DrawText(0,10,"TEST ",RGBA(255,255,255,255),RGBA(0,0,0,0));
StopDrawing()
EndProcedure
Affichetext()
Repeat
Repeat
gEvent=WindowEvent()
Select gEvent
Case #PB_Event_CloseWindow
End
EndSelect
Until gEvent=0
;--- Partie 2D
ClearScreen(RGB(0, 0, 0))
; Je n'afiche le texte que si le flag est vrai
If DisplayTxtOn=#True
DisplayTransparentSprite(#TexteRejouer, 150, 10)
EndIf
ExamineKeyboard()
FlipBuffers()
Until KeyboardReleased(#PB_Key_Escape)
End