Code: Select all
Repeat : WaitWindowEvent(1) : ForEverCode: Select all
Repeat : WaitWindowEvent(1) : ForEverI believed in that one for some reason, but no.miso wrote: Sun Nov 23, 2025 5:04 pm What if :
Code: Select all
Repeat : WaitWindowEvent(1) : ForEver
Code: Select all
...
Repeat
; It's very important to process all the events remaining in the queue at each frame
;
Repeat
Event = WindowEvent()
Select Event
Case #PB_Event_Gadget
Case #PB_Event_CloseWindow
Break 2
EndSelect
Until Event = 0
...
Forever


Thanks! This is correct.ricardo_sdl wrote: Thu Nov 27, 2025 6:13 pm Nice game!
From what I read, your game doesn't use Direct X or Opengl, right? It's just a normal windows executable, which uses the Canvas widget to draw stuff to the window, correct?
And which compiler version and options are you using to generate the exe?
Code: Select all
Global gmRender = CreateMutex()
Global width = DesktopScaledX(800)
Global height = DesktopScaledY(600)
Global gImg = CreateImage(#PB_Any,width,height,32)
Global gQuit
Procedure RenderGameFrame()
Static x,y,vx,vy
If vx = 0 : vx= 1 : EndIf
If vy = 0 : vy=1 : EndIf
If StartDrawing(ImageOutput(gimg))
Box(0,0,width,height,$FFFFFFFF)
DrawText(x,y,"Hello",RGBA(0,255,0,255),$FFFFFFFF)
StopDrawing()
EndIf
If x > width Or x < 0
vx = -vx
EndIf
If y > height Or y < 0
vy = -vy
EndIf
x+vx
y+vy
EndProcedure
Procedure RenderThread(*data)
Repeat
LockMutex(gmRender)
RenderGameFrame()
UnlockMutex(gmRender)
Delay(16)
Until gQuit
EndProcedure
Procedure GetFrame(gadget)
If TryLockMutex(gmRender)
If StartDrawing(CanvasOutput(gadget))
DrawImage(ImageID(gImg),0,0)
StopDrawing()
EndIf
UnlockMutex(gmRender)
Else
Debug "blocked"
EndIf
EndProcedure
#timerDraw = 123
OpenWindow(0,0,0,800,600,"test")
CanvasGadget(1,0,0,800,600)
AddWindowTimer(0,#timerDraw,16)
CreateThread(@RenderThread(),0)
Repeat
event = WaitWindowEvent()
If Event = #PB_Event_Timer And EventTimer() = #timerDraw
GetFrame(1)
EndIf
Until event = #PB_Event_CloseWindow
gQuit = 1
Code: Select all
Global gmRender = CreateMutex()
Global gsRender = CreateSemaphore()
Global width = DesktopScaledX(800)
Global height = DesktopScaledY(600)
Global gImg = CreateImage(#PB_Any,width,height,32)
Global gQuit
Procedure RenderGameFrame()
Static x,y,vx,vy
If vx = 0 : vx= 1 : EndIf
If vy = 0 : vy=1 : EndIf
If StartDrawing(ImageOutput(gimg))
Box(0,0,width,height,$FFFFFFFF)
DrawText(x,y,"Hello",RGBA(0,255,0,255),$FFFFFFFF)
StopDrawing()
EndIf
If x > width Or x < 0
vx = -vx
EndIf
If y > height Or y < 0
vy = -vy
EndIf
x+vx
y+vy
EndProcedure
Procedure RenderThread(gadget)
Repeat
WaitSemaphore(gSrender)
If Not gquit
RenderGameFrame()
If StartDrawing(CanvasOutput(gadget))
DrawImage(ImageID(gImg),0,0)
StopDrawing()
EndIf
EndIf
Until gQuit
EndProcedure
#timerDraw = 123
OpenWindow(0,0,0,800,600,"test")
CanvasGadget(1,0,0,800,600)
AddWindowTimer(0,#timerDraw,30)
CreateThread(@RenderThread(),1)
Repeat
event = WaitWindowEvent()
If Event = #PB_Event_Timer And EventTimer() = #timerDraw
SignalSemaphore(gsRender)
EndIf
Until event = #PB_Event_CloseWindow
gquit = 1
SignalSemaphore(gsRender)