J'ai un petit soucis sur ce code. Lorsque je clique sur la souris, je dois cliquer très vite pour ça fonctionne correctement.
Vous auriez une idée de la boulette que j'ai dû faire pour que ce code fonctionne ?
Code : Tout sélectionner
screenwidth = 640
screenheight = 480
Global PGL_MousePointerPressed, PGL_MousePointer
Procedure GetMousePRessed()
If PGL_MousePointer = 1 And PGL_MousePointerPressed =0
PGL_MousePointerPressed = 1
ProcedureReturn 1
EndIf
EndProcedure
InitSprite()
OpenWindow(0, 0, 0, screenwidth, screenheight, "Mouse pressed", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
If OpenWindowedScreen(WindowID(0),0,0,screenwidth, screenheight)=0
MessageRequester("Error", "Can't Open Screen!", 0)
End
EndIf
CreateSprite(0,64,64)
If StartDrawing(SpriteOutput(0))
Box(0,0,64,64,RGB(255,255,25))
StopDrawing()
EndIf
y.f = 50
Repeat
PGL_EventWindow = WaitWindowEvent(1)
If PGL_EventWindow > 0 ; Or PGL_MousePointer = 1
Select PGL_EventWindow
Case #WM_RBUTTONUP,#WM_LBUTTONUP
PGL_MousePointer = 0
PGL_MousePointerPressed = 0
Case #WM_RBUTTONDOWN,#WM_LBUTTONDOWN
PGL_MousePointer = 1
EndSelect
EndIf
ClearScreen(0)
; physic
If y < screenheight -64
y + 2
EndIf
If GetMousePressed() = 1
Y = y-50
EndIf
DisplaySprite(0,150,y)
FlipBuffers()
Until PGL_EventWindow = #PB_Event_CloseWindow
Autre question :
vous connaissez un équivalent Mac et linux à #WM_LBUTTONUP, #WM_LBUTTONDOWN, etc... ?
Merci bien les z'amis.