Help with math for scaling needed
OK.....here is the question for the smart ones:
I need to scale DOWN an active object if it moves from the edges of the screen towards the center AND scale it UP if it moves from the center of the screen towards the edges. The object is a mouse pointer, so it is always has the position of the mouse X,Y. I need it to look like this: move mouse towards the center - it gets smaller, I move it away from the center - it gets bigger...kindda like 3d perspective effect.
I figured how to track the position and the distance of it relative to the center but can't figure out how to detect when the distance decrease/increase. I'd appreciate any help.
Re: Help with math for scaling needed
It's alot simpler than you'd think. Just have a counter called distance, and at the beginning of the frame, set that counter to the distance between the center and the mouse. Then, for the next line, do a comparison to see if the distance is greater than or less than the distance that it is then.
In short, compare the current distance with the distance from the previous frame.