Some help with math involved with mouse in box
Author |
Message |
copthesaint
|
Posted: Tue Apr 06, 2010 9:52 pm Post subject: Some help with math involved with mouse in box |
|
|
Ok, so I was playing around with math, trying to find a way to see if the mouse is in the screen width and height, instead of useing mX> 0 and mX < maxx and mY > 0 and mY < maxy, so I came up with this first part, and what it does is return 1 if the mouse x and y is >0. What I am having trouble with is making the inverse to this so that I can get 1 if mouse x and y < then there max. Also it would be great if anyone posted another way they do this. Any help?
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
TheGuardian001
|
Posted: Tue Apr 06, 2010 10:17 pm Post subject: Re: Some help with math involved with mouse in box |
|
|
I'm not sure there's actually a way to do that (at least, not using succ(x))... It works for below and left of the window since the number returned by succ(x) is of the opposite sign to sqrt(x^2). But when you're above the window, both numbers are positive, meaning that it will always return 1...
Also:
may I introduce you to abs, otherwise known as the absolute value function? |
|
|
|
|
|
copthesaint
|
Posted: Tue Apr 06, 2010 11:24 pm Post subject: Re: Some help with math involved with mouse in box |
|
|
There is a way, just went back to it again, and finished it.
Well that was fun, lol. Now to find another way of doing this!
Edit: also I know abs, but I like the way I do it, because its better for visually looking at the code for me, but off course I would change that to abs later when figured everything out. |
|
|
|
|
|
|
|