Pourriez vous tester (j'ai une petite config...)
La même chose mais non bloquant lors du redimensionnement ou deplacement. Par contre la valeur du delay ligne 29 doit être augmenter. Peut être une erreur de programmation de ma pars... je ne suis vraiment pas familiarisé avec les Semaphore
Code : Tout sélectionner
#MainWin = 0
#ScreenWin = 1
Global ScreenW = 2048
Global ScreenH = 2048
Global Thread
Global ThreadSemaphore = CreateSemaphore()
InitSprite()
Procedure UpdateScreen()
WaitSemaphore(ThreadSemaphore)
ResizeGadget(0, #PB_Ignore, #PB_Ignore, WindowWidth(#MainWin), WindowHeight(#MainWin))
SignalSemaphore(ThreadSemaphore)
EndProcedure
Procedure Scrolling(nul)
Repeat
WaitSemaphore(ThreadSemaphore)
TrySemaphore(ThreadSemaphore)
DisplaySprite(101, x, 0)
DisplaySprite(101, ScreenW + x, 0)
x - 1
If x <= 0 - ScreenW
X = 0
EndIf
FlipBuffers()
SignalSemaphore(ThreadSemaphore)
Delay(20) ; 3
ForEver
EndProcedure
If OpenWindow(#MainWin, 0, 0, 400, 300, Str(ScreenW) + " x " + Str(ScreenH), #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_SizeGadget | #PB_Window_MaximizeGadget)
MDIGadget(0, 0, 0, WindowWidth(#MainWin), WindowHeight(#MainWin), 0, 0, #PB_MDI_BorderLess )
OpenWindowedScreen(GadgetID(0), 0, 0, ScreenW, ScreenH)
CreateSprite(101, ScreenW, ScreenH, #PB_Sprite_AlphaBlending)
If StartDrawing(SpriteOutput(101) )
For I = 1 To 1000
x = Random(ScreenW)
y = Random(ScreenH)
r = 50 + Random(50)
c = RGB(Random(255), Random(255), Random(255) )
Circle(x, y, r, c)
Circle(x - ScreenW, y, r, c)
Circle(x + ScreenW, y, r, c)
Next
StopDrawing()
EndIf
x = 0
DisplaySprite(101, x, 0)
DisplaySprite(101, ScreenW + x, 0)
FlipBuffers()
BindEvent(#PB_Event_SizeWindow, @UpdateScreen())
Thread = CreateThread(@Scrolling(),0)
SignalSemaphore(ThreadSemaphore)
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
KillThread(Thread) : FreeSemaphore(ThreadSemaphore)
EndIf
Et maintenant sans Thread
Code : Tout sélectionner
#MainWin = 0
#ScreenWin = 1
Global ScreenW = 2048
Global ScreenH = 2048
Global Thread
Global ThreadSemaphore = CreateSemaphore()
InitSprite()
Procedure UpdateScreen()
ResizeGadget(0, #PB_Ignore, #PB_Ignore, WindowWidth(#MainWin), WindowHeight(#MainWin))
EndProcedure
Procedure Scrolling()
Static x
DisplaySprite(101, x, 0)
DisplaySprite(101, ScreenW + x, 0)
x - 1
If x <= 0 - ScreenW
X = 0
EndIf
FlipBuffers()
EndProcedure
If OpenWindow(#MainWin, 0, 0, 400, 300, Str(ScreenW) + " x " + Str(ScreenH), #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_SizeGadget | #PB_Window_MaximizeGadget)
AddWindowTimer(#MainWin,1,1)
MDIGadget(0, 0, 0, WindowWidth(#MainWin), WindowHeight(#MainWin), 0, 0, #PB_MDI_BorderLess )
OpenWindowedScreen(GadgetID(0), 0, 0, ScreenW, ScreenH,0,0,0,#PB_Screen_NoSynchronization)
CreateSprite(101, ScreenW, ScreenH, #PB_Sprite_AlphaBlending)
If StartDrawing(SpriteOutput(101) )
For I = 1 To 1000
x = Random(ScreenW)
y = Random(ScreenH)
r = 50 + Random(50)
c = RGB(Random(255), Random(255), Random(255) )
Circle(x, y, r, c)
Circle(x - ScreenW, y, r, c)
Circle(x + ScreenW, y, r, c)
Next
StopDrawing()
EndIf
x = 0
DisplaySprite(101, x, 0)
DisplaySprite(101, ScreenW + x, 0)
FlipBuffers()
BindEvent(#PB_Event_SizeWindow, @UpdateScreen())
BindEvent(#PB_Event_Timer,@Scrolling())
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf