Hey, I made a graph (thats all I think I can call it, but its not really a graph) and I want it so in a short script it will be able to tell if the mouse is in one of these squares. Here's the pic. I would try to figure this out myself, but it could take a long time. I figured someone else could do it alot faster, like some math-whiz.
http://i1156.photobucket.com/albums/p56 … tGraph.gif
I I don't want it to check one at a time if it is in a box, I would rather have a shorter and faster script to check it, and the way it is spaced there should be a way to do that.
NOTE: The boxes are all 60x by 75x (x,y) and for x the border and middle empty spaces are 20 pixels, the others are 15 pixels in x, and for y the top and bottom (y border) empty spaces are 15 pixels, and the spaces in between are 10 pixels. I hope you know what I'm talking about, tell me if you do not understand something.
Offline
OK, you need two variables: rx and ry for rounded x and rounded y.
You might have to play around with this for a bit but hopefully this'll work:
rx = round(mousex+40/75)*75-40
ry = round(mousey+43/83)*83-43
That should at least give a close center for each rectangle. Then to test if the mouse is actually in the rectangle:
abs(mousex-rx) < 30
abs(mousey-ry) < 37
EDIT:
This worked for the any mouse value less than 0, if the value is greater than zero, use 35 instead 40.
Last edited by AtomicBawm3 (2012-06-08 02:10:44)
Offline
AtomicBawm3 wrote:
OK, you need two variables: rx and ry for rounded x and rounded y.
You might have to play around with this for a bit but hopefully this'll work:
rx = round(mousex+40/75)*75-40
ry = round(mousey+43/83)*83-43
That should at least give a close center for each rectangle. Then to test if the mouse is actually in the rectangle:
abs(mousex-rx) < 30
abs(mousey-ry) < 37
EDIT:
This worked for the any mouse value less than 0, if the value is greater than zero, use 35 instead 40.
Thanks! I'll try this as soon as I can...
Offline