Get next X,Y of direction (angle)?

BlitzPlus Forums/BlitzPlus Programming/Get next X,Y of direction (angle)?

WillKoh(Posted 2003) [#1]
How does one get the next x,y for movement along a hypothetical line the starts at a given x,y but continues in eternity pointing a certain angle from the start x,y?

Also, how do I get the angle of two pixels compared to each other (for example the one under left foot and the one under right foot of character) to detirmine proper tilt of character in relation to ground?


Michael Reitzenstein(Posted 2003) [#2]
x = x + cos( angle ) * speed
y = y + sin( angle ) * speed

angle = atan2( y2 - y1, x2 - x1 )


darklordz(Posted 2003) [#3]
Ahh you beat me to it....I was looking it up in my forumula book...


WillKoh(Posted 2003) [#4]
Thanx. I knew it was something with those mystic cos and tan ;-)


Réno(Posted 2003) [#5]
Thank you Michael !!!