Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- long Distance (Coordinates A, Coordinates B)
- {
- long X = Math.abs(A.getX() - B.getX());
- long Y = Math.abs(A.getY() - B.getY());
- if (X > GameConstants.UNIVERSE_SIZE)
- X = GameConstants.UNIVERSE_SIZE - X;
- if (Y > GameConstants.UNIVERSE_SIZE)
- Y = GameConstants.UNIVERSE_SIZE - Y;
- return X + Y - 1;
- }
- Coordinates getCenter (UniverseView universe)
- {
- long TempMax = 0, TempMin = 100;
- Coordinates TempCell = null;
- for (Coordinates a: universe.getMyCells ())
- {
- for (Cordinates b : universe.getMyCells())
- {
- if (Distance (a,b) > TempMax)
- TempMax=Distance (a,b);
- }
- if (TempMax < TempMin)
- {
- TempMin = TempMax;
- TempCell = a;
- }
- }
- return TempCell;
- }
Advertisement
Add Comment
Please, Sign In to add comment