SetVelocity can now set speed and/or angle of velocity vector

Charles Spurrill 2011-09-30 22:28:01 -07:00
parent dee103f74c
commit 9f27a89912
1 changed files with 5 additions and 0 deletions

View File

@ -62,8 +62,13 @@ global func SetSpeed(int x_dir, int y_dir, int prec)
}
// Sets an objects's speed and its direction, doesn't it?
// Can set either speed or angle of velocity, or both
global func SetVelocity(int angle, int speed, int precAng, int precSpd)
{
if(!speed)
speed = Distance(0,0, GetXDir(precSpd), GetYDir(precSpd));
if(!angle)
angle = Angle(0,0, GetXDir(precSpd), GetYDir(precSpd), precAng);
if(!precAng) precAng = 1;
var x_dir = Sin(angle, speed, precAng);
var y_dir = -Cos(angle, speed, precAng);