Using mouse to check square position ?

Blitz3D Forums/Blitz3D Beginners Area/Using mouse to check square position ?

767pilot(Posted 2005) [#1]
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


Perturbatio(Posted 2005) [#2]
xpos = MouseX()/32
ypos = MouseY()/32


jfk EO-11110(Posted 2005) [#3]
isn't this rounding the result?

maybe you need to:

xpos=floor(mousex()/32)
ypos=floor(mousey()/32)

not sure right now :)


Perturbatio(Posted 2005) [#4]

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