Example #1
0
 public double distance_sq(GameEntity other)
 {
     float xdiff = other.Position.X - Position.X;
     float ydiff = other.Position.Y - Position.Y;
     return xdiff * xdiff + ydiff * ydiff;
 }
Example #2
0
 // Returns true if the other entity is within the specified range
 public bool inRange(GameEntity other, int range)
 {
     return distance(other) <= range;
 }
Example #3
0
 // Calculates the euclidean distance between the entities
 public double distance(GameEntity other)
 {
     if (other == null) return 0.0;
     return (other.Position - Position).Length();
 }