Hi all. I am currently making a game and I need to figure out a point from a start xy, a distance and an angle. Would anyone know how to do this.
cheers
Matt
Assuming that the angle is anticlockwise from positive x-axis and you are using the normal cartesean coordinates (if it's computer screen coordinates the y has to be negated), the formulae are:
x=startx+dist*cos(angle)
y=starty+dist*sin(angle)
Quote from: Gilbet V7000a on Sun 08/03/2009 09:35:07
(if it's computer screen coordinates the y has to be negated)
If you're working in screen coordinates, the above formulae require the angle to be measured clockwise; if you are measuring the angle anticlockwise, then you need these instead:
x = startx + dist * cos(angle)
y = starty - dist * sin(angle)
Additionally, you
might need to convert the angle from degrees to radians (I don't remember whether AGS trigonometric functions work in radians or degrees). Look up "cos" or "sin" in the AGS manual to see if this is necessary. If so, then I think it explains there how to do the conversion.
Probably might need an Abs function as well. I recall doing something similar and the scripting an Abs function came in really handy.
Well, abs is really nothing more than:
float Math_Abs ( float value )
{
if ( value < 0.0f )
return -value;
return value;
}
So it's very easy to work around which is probably the reason why it doesn't have much priority.
EDIT: Sorry, misunderstood your post there. :) (I could've sworn I was in the AGS next version feature suggestion thread).
No harm done. Show off!!! :D :D :D