As some of you may have realised the Game Maker functions are mostly simplifications of math which deals with the coordinate system in which Game Maker order its objects. Here are how to replace the lengthdir functions, just as an example:
x=objplayer.x+lengthdir_x(distance,direction);
y=objplayer.y+lengthdir_y(distance,direction);
x=objplayer.x+distance*cos(direction*(pi/180));
y=objplayer.y+distance*sin(direction*(pi/180));
My point is merely to show how simple the functions might be, if you know the math behind them. Also I wanted to prove that if you want to become a good programmer, then you better be good at math, and like to study math.
<b>I have been corrected...</b>
No. As commented sin and cos does not work with direction. They work with radians.
Radians are calculated like this; degrees*(pi/180)
...I have now implemented it in the code above!
.
Users logged in:
Comments
Loading comments...