Distance

From Game Editor

Jump to: navigation, search

double distance(double x1, double y1, double x2, double y2);

distance returns the distance between point (x1,y1) and (x2,y2).


Example: Shoot bullets if the player comes in range.

turret -> Draw Actor -> Script Editor

if(distance(x, y, player.x, player.y)<200)
{
    timer++;
    if(timer>=30)
    {
        CreateActor("bullet", "bullet", "(none)", "(none)", 0, 0, false);
        timer=0;
    }
}