tolord

Untitled

Nov 4th, 2015
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.71 KB | None | 0 0
  1. long Distance (Coordinates A, Coordinates B)
  2.     {
  3.         long X = Math.abs(A.getX() - B.getX());
  4.         long Y = Math.abs(A.getY() - B.getY());
  5.         if (X > GameConstants.UNIVERSE_SIZE)
  6.             X = GameConstants.UNIVERSE_SIZE - X;
  7.         if (Y > GameConstants.UNIVERSE_SIZE)
  8.             Y = GameConstants.UNIVERSE_SIZE - Y;
  9.         return X + Y - 1;
  10.     }
  11.  
  12. Coordinates getCenter (UniverseView universe)
  13.     {
  14.         long TempMax = 0, TempMin = 100;
  15.         Coordinates TempCell = null;
  16.         for (Coordinates a: universe.getMyCells ())
  17.         {
  18.             for (Cordinates b : universe.getMyCells())
  19.             {
  20.                 if (Distance (a,b) > TempMax)
  21.                     TempMax=Distance (a,b);
  22.             }
  23.             if (TempMax < TempMin)
  24.             {
  25.                 TempMin = TempMax;
  26.                 TempCell = a;
  27.             }
  28.         }
  29.         return TempCell;
  30.     }
Advertisement
Add Comment
Please, Sign In to add comment