Using mouse to check square position ?
Blitz3D Forums/Blitz3D Beginners Area/Using mouse to check square position ?
| ||
Hi If I have a grid of tiles, say 15 across by 15 down and 32*32 pixels wide, and I want to use the mouse to find out which square tile I am over how do I do it please? Many thanks Graham |
| ||
xpos = MouseX()/32 ypos = MouseY()/32 |
| ||
isn't this rounding the result? maybe you need to: xpos=floor(mousex()/32) ypos=floor(mousey()/32) not sure right now :) |
| ||
isn't this rounding the result? It will round correctly. :) Graphics 800,600,0,2 SetBuffer BackBuffer() While Not KeyDown(1) Cls xpos = MouseX()/32 ypos = MouseY()/32 Text (10,10, "X: "+xpos+" Y: "+ypos) Flip Wend End |