Distance

From Game Editor

Revision as of 00:48, 4 May 2011 by Skydereign (Talk | contribs)
(diff) ← Older revision | Current revision (diff) | Newer revision → (diff)
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;
    }
}