Missing mouse selection
Posted: Sun Mar 03, 2024 1:38 am
I have this partial code
What I am finding is that mouse downs (clicks) are sometimes but not always missed. I tried inserting various times in the commented Sleep function with varied success. Is there a better way to not miss mouse clicks. I used the Double Buffer to reduce flickering.
The game has a grid of tiles 18 wide and 8 high and the play is to select two matching tiles - similar to Mahjong. At the moment I am just trying to get the interface working satisfactorily. On Windows 10 64 bit.Thanks for any help.
Code: Select all
Function displayGrid()
For x = 0 To 19
For y = 0 To 9
If playGrid[x][y] <>0
DisplayBrush(playGrid[x][y],(x-1)*40+gapWidth,(y-1)*56+gapWidth)
EndIf
Next
If sel1.active<>0
SetLineWidth(5)
Box((gridX-1)*40+gapWidth,(gridY-1)*56+gapWidth,40,56,#RED)
EndIf
Next
EndFunction
Function chkMousePos()
x=MouseX() /*Get the mouse coords*/
y=MouseY()
/*find the gri x and y for where the mouse is*/
gridX = Round((x - gapWidth)/40 + 0.5)
gridY = Round((y - gapHeight)/56 + 0.55)
;DebugPrint("x: " .. gridX .. " y: " .. gridY)
If playGrid[gridX][gridY]<>0
If sel1.active = 0
sel1.active = 1
Else
sel1.active = 0
EndIf
EndIf
EndFunction
Repeat
BeginDoubleBuffer()
displayGrid()
;Sleep(100)
If IsLeftMouse() = True
chkMousePos()
EndIf
Flip()
EndDoubleBuffer()
ForeverThe game has a grid of tiles 18 wide and 8 high and the play is to select two matching tiles - similar to Mahjong. At the moment I am just trying to get the interface working satisfactorily. On Windows 10 64 bit.Thanks for any help.