فهرست منبع

consistent formatting, removed logging

Kajetan Johannes Hammerle 5 سال پیش
والد
کامیت
5e0613507e
49فایلهای تغییر یافته به همراه1062 افزوده شده و 1655 حذف شده
  1. 3 7
      src/pathgame/Main.java
  2. 12 21
      src/pathgame/PathGame.java
  3. 20 10
      src/pathgame/algorithm/Coord.java
  4. 45 66
      src/pathgame/algorithm/DijkstraMagic.java
  5. 12 6
      src/pathgame/algorithm/ExtraPath.java
  6. 42 20
      src/pathgame/algorithm/Node2D.java
  7. 17 10
      src/pathgame/algorithm/OddDegreeList.java
  8. 30 18
      src/pathgame/algorithm/Permutation.java
  9. 8 4
      src/pathgame/algorithm/SaleRoute.java
  10. 31 44
      src/pathgame/algorithm/TravellingSalesAlg.java
  11. 20 12
      src/pathgame/algorithm/TreeEdge.java
  12. 9 12
      src/pathgame/gameplay/Facing.java
  13. 5 10
      src/pathgame/gameplay/Gamestate.java
  14. 1 2
      src/pathgame/gameplay/Gamestates.java
  15. 13 21
      src/pathgame/gameplay/Keys.java
  16. 19 40
      src/pathgame/gameplay/Level.java
  17. 7 14
      src/pathgame/gameplay/MinusStepsValues.java
  18. 57 125
      src/pathgame/gameplay/Player.java
  19. 18 36
      src/pathgame/gameplay/PlayerAbilities.java
  20. 12 17
      src/pathgame/gameplay/menu/AfterScoreMenu.java
  21. 13 28
      src/pathgame/gameplay/menu/BaseMenu.java
  22. 10 15
      src/pathgame/gameplay/menu/CharacterMenu.java
  23. 14 19
      src/pathgame/gameplay/menu/EscMenu.java
  24. 10 14
      src/pathgame/gameplay/menu/MainMenu.java
  25. 14 30
      src/pathgame/gameplay/menu/Menu.java
  26. 5 10
      src/pathgame/gameplay/menu/MenuButton.java
  27. 11 23
      src/pathgame/gameplay/menu/OptionMenu.java
  28. 0 118
      src/pathgame/logging/Logger.java
  29. 27 55
      src/pathgame/rendering/Camera.java
  30. 10 19
      src/pathgame/rendering/HUDRenderer.java
  31. 17 35
      src/pathgame/rendering/LevelRenderer.java
  32. 21 39
      src/pathgame/rendering/MenuRenderer.java
  33. 22 51
      src/pathgame/rendering/PlayerRenderer.java
  34. 18 37
      src/pathgame/rendering/ScoreMenuRenderer.java
  35. 10 11
      src/pathgame/rendering/StaticTextureProvider.java
  36. 47 89
      src/pathgame/rendering/TileMapRenderer.java
  37. 19 22
      src/pathgame/rendering/TileRenderer.java
  38. 27 27
      src/pathgame/rendering/TileTexture.java
  39. 5 4
      src/pathgame/rendering/TileTextureProvider.java
  40. 36 49
      src/pathgame/tilemap/HighMap.java
  41. 108 113
      src/pathgame/tilemap/Tile.java
  42. 6 9
      src/pathgame/tilemap/TileHomeTown.java
  43. 60 68
      src/pathgame/tilemap/TileMap.java
  44. 136 224
      src/pathgame/tilemap/TileMapGenerator.java
  45. 6 9
      src/pathgame/tilemap/TilePort.java
  46. 3 3
      src/pathgame/tilemap/TileRenderType.java
  47. 6 9
      src/pathgame/tilemap/TileTown.java
  48. 3 4
      src/pathgame/tilemap/TileType.java
  49. 17 26
      src/pathgame/tilemap/Tiles.java

+ 3 - 7
src/pathgame/Main.java

@@ -2,15 +2,11 @@ package pathgame;
 
 import me.hammerle.snuviengine.api.Engine;
 
-public class Main
-{
-    public static void main(String[] args)
-    {
+public class Main {
+    public static void main(String[] args) {
         Engine.init("Path Game", 1024, 768);
-        
         Engine.setNanosPerTick(50_000_000);
-        
         PathGame game = new PathGame();
         Engine.start(game);
-    }    
+    }
 }

+ 12 - 21
src/pathgame/PathGame.java

@@ -10,51 +10,42 @@ import pathgame.gameplay.menu.Menu;
 import pathgame.rendering.LevelRenderer;
 import pathgame.rendering.MenuRenderer;
 
-public class PathGame implements IGame
-{
+public class PathGame implements IGame {
     private final Gamestate gamestate = new Gamestate();
 
     private final Level level = new Level();
     private final LevelRenderer levelRenderer = new LevelRenderer();
-    
+
     private final Menu menu = new Menu();
     private final MenuRenderer menuRenderer = new MenuRenderer();
 
-    public PathGame()
-    {
+    public PathGame() {
     }
 
     @Override
-    public void tick()
-    {
+    public void tick() {
         level.tick(gamestate);
         levelRenderer.tick(level, gamestate);
-        
+
         menu.tick(gamestate, level);
-        
-        if(Keys.TEST_KEY.getTime() == 1)
-        {
+
+        if(Keys.TEST_KEY.getTime() == 1) {
             //level.nextLevel();
             level.getPlayer().win(level.getMap());
         }
     }
 
     @Override
-    public void renderTick(Renderer r, float lag)
-    {
-        if(gamestate.is(Gamestates.MENU))
-        {
+    public void renderTick(Renderer r, float lag) {
+        if(gamestate.is(Gamestates.MENU)) {
             levelRenderer.renderTick(r, 0.0f, level, gamestate);
             menuRenderer.renderTick(r, 0.0f, menu);
-        }
-        else
-        {
+        } else {
             levelRenderer.renderTick(r, lag, level, gamestate);
         }
     }
 
     @Override
-    public void onStop()
-    {
+    public void onStop() {
     }
-}
+}

+ 20 - 10
src/pathgame/algorithm/Coord.java

@@ -1,13 +1,15 @@
 package pathgame.algorithm;
 
-/** Simple class for storing 2D x and y coordinates
+/**
+ * Simple class for storing 2D x and y coordinates
  *
  */
 public class Coord {
     private int x, y;
     private boolean isBoatTile = false;
 
-    /** Create new coordinate with given x and y value
+    /**
+     * Create new coordinate with given x and y value
      *
      * @param x position of Coord
      * @param y position of Coord
@@ -17,7 +19,8 @@ public class Coord {
         this.y = y;
     }
 
-    /** Creates new cooridnate with given x and y value and sets isBoatTile to given value
+    /**
+     * Creates new cooridnate with given x and y value and sets isBoatTile to given value
      *
      * @param x position of Coord
      * @param y position of Coord
@@ -29,7 +32,8 @@ public class Coord {
         this.isBoatTile = isBoatTile;
     }
 
-    /** Returns x position of Coord
+    /**
+     * Returns x position of Coord
      *
      * @return x position
      */
@@ -37,7 +41,8 @@ public class Coord {
         return x;
     }
 
-    /** Returns y position of Coord
+    /**
+     * Returns y position of Coord
      *
      * @return y position
      */
@@ -45,7 +50,8 @@ public class Coord {
         return y;
     }
 
-    /** Adds given value to x position of Coord
+    /**
+     * Adds given value to x position of Coord
      *
      * @param x value to be added to x position
      */
@@ -53,7 +59,8 @@ public class Coord {
         this.x += x;
     }
 
-    /** Adds given value to y position of Coord
+    /**
+     * Adds given value to y position of Coord
      *
      * @param y value to be added to y position
      */
@@ -61,7 +68,8 @@ public class Coord {
         this.y += y;
     }
 
-    /** Sets x and y position of Coord to given values
+    /**
+     * Sets x and y position of Coord to given values
      *
      * @param x new x position of Coord
      * @param y new y position of Coord
@@ -71,7 +79,8 @@ public class Coord {
         this.y = y;
     }
 
-    /** Returns isBoatTile, which is true if Coord is part of a boat path
+    /**
+     * Returns isBoatTile, which is true if Coord is part of a boat path
      *
      * @return isBoatTile of Coord
      */
@@ -79,7 +88,8 @@ public class Coord {
         return isBoatTile;
     }
 
-    /** Sets isBoatTile to given value
+    /**
+     * Sets isBoatTile to given value
      *
      * @param isBoatTile value isBoatTile gets set to
      */

+ 45 - 66
src/pathgame/algorithm/DijkstraMagic.java

@@ -7,7 +7,9 @@ import pathgame.tilemap.Tiles;
 import java.util.ArrayList;
 import pathgame.gameplay.Player;
 
-/** Class that takes a TileMap, finds all towns in it and generates a table of shortest paths between each town using the Dijkstra algorithm
+/**
+ * Class that takes a TileMap, finds all towns in it and generates a table of shortest paths between each town using the
+ * Dijkstra algorithm
  *
  */
 public class DijkstraMagic {
@@ -21,7 +23,8 @@ public class DijkstraMagic {
     private Node2D[][] weightMap;
     private ArrayList<ArrayList<SaleRoute>> salesPitch = new ArrayList<>();
 
-    /** Generates a table of shortest paths between each town in the given TileMap
+    /**
+     * Generates a table of shortest paths between each town in the given TileMap
      *
      * @param map TileMap that the algorithm should use
      * @param player that is traversing the map
@@ -34,7 +37,6 @@ public class DijkstraMagic {
         setup(player);
 
         //printWeightMap();
-
         for(int i = 0; i < ports.size(); i++) {
             doMagic(i, false);
         }
@@ -46,7 +48,8 @@ public class DijkstraMagic {
         //printDijkstraResult();
     }
 
-    /** Returns the generated table of Dijkstra results
+    /**
+     * Returns the generated table of Dijkstra results
      *
      * @return generated table of Dijkstra results
      */
@@ -61,8 +64,7 @@ public class DijkstraMagic {
 
         if(forTown) {
             origin = towns.get(fromIndex);
-        }
-        else {
+        } else {
             origin = ports.get(fromIndex);
         }
 
@@ -91,8 +93,7 @@ public class DijkstraMagic {
 
             if(weightMap[c.getX()][c.getY()].isBlocked() && forTown) {
                 tileQ.remove(leastIndex);
-            }
-            else {
+            } else {
                 dijkstraForTownOrPort(tileQ.get(leastIndex).getX(), tileQ.get(leastIndex).getY(), tileQ, leastIndex, forTown);
             }
         }
@@ -100,8 +101,7 @@ public class DijkstraMagic {
             //printPathMap();
             //printPorts();
             makeListForPitch(fromIndex);
-        }
-        else {
+        } else {
             addPortsPaths(fromIndex);
         }
 
@@ -111,17 +111,17 @@ public class DijkstraMagic {
     private void dijkstraForTownOrPort(int posX, int posY, ArrayList<Coord> tileQ, int qIndex, boolean forTown) {
         int prevCost = weightMap[posX][posY].getCostSoFar();
 
-        if(posX < weightMap.length-1) {
-            adjacent(posX+1, posY, prevCost, 'w', null, -1, tileQ, forTown);
+        if(posX < weightMap.length - 1) {
+            adjacent(posX + 1, posY, prevCost, 'w', null, -1, tileQ, forTown);
         }
         if(posX > 0) {
-            adjacent(posX-1, posY, prevCost, 'e', null, -1, tileQ, forTown);
+            adjacent(posX - 1, posY, prevCost, 'e', null, -1, tileQ, forTown);
         }
-        if(posY < weightMap[0].length-1) {
-            adjacent(posX, posY+1, prevCost, 'n', null, -1, tileQ, forTown);
+        if(posY < weightMap[0].length - 1) {
+            adjacent(posX, posY + 1, prevCost, 'n', null, -1, tileQ, forTown);
         }
         if(posY > 0) {
-            adjacent(posX, posY-1, prevCost, 's', null, -1, tileQ, forTown);
+            adjacent(posX, posY - 1, prevCost, 's', null, -1, tileQ, forTown);
         }
 
         if(forTown) {
@@ -155,8 +155,7 @@ public class DijkstraMagic {
             if(!weightMap[posX][posY].isBlocked()) {
                 adjacentCalc(posX, posY, prevCost, dir, boatPath, extraInd, tileQ, forTown);
             }
-        }
-        else {
+        } else {
             TileType type = weightMap[posX][posY].getType();
 
             if(type == TileType.SHALLOW_WATER || type == TileType.DEEP_WATER || type == TileType.PORT) {
@@ -170,13 +169,11 @@ public class DijkstraMagic {
         if(forTown) {
             if(extraPath == null) {
                 newCost += weightMap[posX][posY].getWeight();
-            }
-            else {
+            } else {
                 newCost += extraPath.getPathWeight();
             }
 
-        }
-        else {
+        } else {
             newCost += WATER_WEIGHT;
         }
 
@@ -184,8 +181,7 @@ public class DijkstraMagic {
             weightMap[posX][posY].setCostSoFar(newCost);
             if(extraPath == null) {
                 weightMap[posX][posY].setPrevOfPath(dir);
-            }
-            else {
+            } else {
                 weightMap[posX][posY].setPrevBoatPath(extraInd);
             }
         }
@@ -199,7 +195,7 @@ public class DijkstraMagic {
     private void addPortsPaths(int fromIndex) {
         Coord origin = ports.get(fromIndex);
 
-        for(int i = fromIndex+1; i < ports.size(); i++) {
+        for(int i = fromIndex + 1; i < ports.size(); i++) {
             Coord nextPort = ports.get(i);
 
             if(weightMap[nextPort.getX()][nextPort.getY()].getCostSoFar() < Integer.MAX_VALUE) {
@@ -222,44 +218,38 @@ public class DijkstraMagic {
             int extraInd = weightMap[curPos.getX()][curPos.getY()].getPrevBoatPath();
             if(forTown) {
                 coordList.add(new Coord(curPos.getX(), curPos.getY()));
-            }
-            else {
+            } else {
                 coordList.add(new Coord(curPos.getX(), curPos.getY(), true));
             }
 
             if(dir == 'n') {
                 curPos.changeY(-1);
-            }
-            else if(dir == 'e') {
+            } else if(dir == 'e') {
                 curPos.changeX(1);
-            }
-            else if(dir == 's') {
+            } else if(dir == 's') {
                 curPos.changeY(1);
-            }
-            else if(dir == 'w') {
+            } else if(dir == 'w') {
                 curPos.changeX(-1);
-            }
-            else if(extraInd != -1 && forTown) {
+            } else if(extraInd != -1 && forTown) {
                 ExtraPath extraPath = weightMap[curPos.getX()][curPos.getY()].getExtraPaths().get(extraInd);
 
                 curPos.setCoord(extraPath.getDestX(), extraPath.getDestY());
                 coordList.addAll(extraPath.getPathCoords());
-            }
-            else {
+            } else {
                 break;
             }
         }
 
         if(!forTown) {
             coordList.remove(0);
-            coordList.remove(coordList.size()-1);
+            coordList.remove(coordList.size() - 1);
         }
     }
 
     private void makeListForPitch(int fromIndex) {
         ArrayList<SaleRoute> listForPitch = new ArrayList<>();
 
-        for(int i = fromIndex+1; i < towns.size(); i++) {
+        for(int i = fromIndex + 1; i < towns.size(); i++) {
             ArrayList<Coord> listForRoute = new ArrayList<>();
             Coord curPos = new Coord(towns.get(i).getX(), towns.get(i).getY());
             int totalCost = weightMap[curPos.getX()][curPos.getY()].getCostSoFar();
@@ -274,7 +264,7 @@ public class DijkstraMagic {
 
     private void resetWeightMap() {
         for(int x = 0; x < weightMap.length; x++) {
-            for (int y = 0; y < weightMap[0].length; y++) {
+            for(int y = 0; y < weightMap[0].length; y++) {
                 weightMap[x][y].setCostSoFar(Integer.MAX_VALUE);
                 weightMap[x][y].setQAdded(false);
                 weightMap[x][y].setPrevOfPath('\0');
@@ -294,8 +284,7 @@ public class DijkstraMagic {
                 if(map.getTile(x, y).getId() == TOWN_ID || map.getTile(x, y).getId() == START_ID) {
                     towns.add(new Coord(x, y));
                     weightMap[x][y].setTown(true);
-                }
-                else if(map.getTile(x, y).getId() == PORT_ID) {
+                } else if(map.getTile(x, y).getId() == PORT_ID) {
                     ports.add(new Coord(x, y));
                 }
 
@@ -323,18 +312,14 @@ public class DijkstraMagic {
                 int cost = weightMap[x][y].getCostSoFar();
                 if(cost == Integer.MAX_VALUE) {
                     System.out.print("- ");
-                }
-                else {
+                } else {
                     if(weightMap[x][y].getType() == TileType.PORT) {
                         System.out.print(ANSI_RED + cost + " " + ANSI_RESET);
-                    }
-                    else if (weightMap[x][y].getType() == TileType.SHALLOW_WATER) {
+                    } else if(weightMap[x][y].getType() == TileType.SHALLOW_WATER) {
                         System.out.print(ANSI_BLUE + cost + " " + ANSI_RESET);
-                    }
-                    else if (weightMap[x][y].isTown()) {
+                    } else if(weightMap[x][y].isTown()) {
                         System.out.print(ANSI_PURPLE + cost + " " + ANSI_RESET);
-                    }
-                    else {
+                    } else {
                         System.out.print(cost + " ");
                     }
 
@@ -350,19 +335,18 @@ public class DijkstraMagic {
     private void printDijkstraResult() {
         System.out.println();
 
-        String ANSI_RESET  = "\u001B[0m";
+        String ANSI_RESET = "\u001B[0m";
         String ANSI_BLUE = "\u001B[34m";
 
         for(int origNum = 0; origNum < salesPitch.size(); origNum++) {
-            for (int lNum = 0; lNum < salesPitch.get(origNum).size(); lNum++) {
+            for(int lNum = 0; lNum < salesPitch.get(origNum).size(); lNum++) {
                 System.out.print("Total Cost: " + salesPitch.get(origNum).get(lNum).getTotalCost() + "   ");
 
-                for (int lInd = 0; lInd < salesPitch.get(origNum).get(lNum).getPath().size(); lInd++) {
+                for(int lInd = 0; lInd < salesPitch.get(origNum).get(lNum).getPath().size(); lInd++) {
                     Coord c = salesPitch.get(origNum).get(lNum).getPath().get(lInd);
                     if(c.isBoatTile()) {
                         System.out.print(ANSI_BLUE + c.getX() + "/" + c.getY() + " " + ANSI_RESET);
-                    }
-                    else {
+                    } else {
                         System.out.print(c.getX() + "/" + c.getY() + " ");
                     }
                 }
@@ -382,7 +366,7 @@ public class DijkstraMagic {
                     ArrayList<ExtraPath> extraPaths = weightMap[x][y].getExtraPaths();
 
                     System.out.println(x + "/" + y);
-                    for (int i = 0; i < extraPaths.size(); i++) {
+                    for(int i = 0; i < extraPaths.size(); i++) {
                         System.out.println("port id: " + i + ", " + extraPaths.get(i).getDestX() + "/" + extraPaths.get(i).getDestY());
                     }
                     System.out.println();
@@ -396,8 +380,7 @@ public class DijkstraMagic {
             for(int x = 0; x < weightMap.length; x++) {
                 if(weightMap[x][y].hasExtraPaths()) {
                     System.out.print(weightMap[x][y].getPrevBoatPath() + " ");
-                }
-                else {
+                } else {
                     System.out.print(weightMap[x][y].getPrevOfPath() + " ");
                 }
             }
@@ -419,17 +402,13 @@ public class DijkstraMagic {
                 TileType type = weightMap[x][y].getType();
                 if(weightMap[x][y].isTown()) {
                     System.out.print(ANSI_RED + "T " + ANSI_RESET);
-                }
-                else if(type == TileType.PORT) {
+                } else if(type == TileType.PORT) {
                     System.out.print(ANSI_CYAN + "P " + ANSI_RESET);
-                }
-                else if(type == TileType.SHALLOW_WATER) {
+                } else if(type == TileType.SHALLOW_WATER) {
                     System.out.print(ANSI_BLUE + "s " + ANSI_RESET);
-                }
-                else if(type == TileType.DEEP_WATER) {
+                } else if(type == TileType.DEEP_WATER) {
                     System.out.print(ANSI_BLUE + "d " + ANSI_RESET);
-                }
-                else {
+                } else {
                     System.out.print(cost + " ");
                 }
             }

+ 12 - 6
src/pathgame/algorithm/ExtraPath.java

@@ -2,7 +2,8 @@ package pathgame.algorithm;
 
 import java.util.ArrayList;
 
-/** Class that stores data on paths to nodes that are not adjacent to each other
+/**
+ * Class that stores data on paths to nodes that are not adjacent to each other
  *
  */
 public class ExtraPath {
@@ -10,7 +11,8 @@ public class ExtraPath {
     private int destX, destY;
     private ArrayList<Coord> pathCoords;
 
-    /** Creates an ExtraPath with the given parameters
+    /**
+     * Creates an ExtraPath with the given parameters
      *
      * @param destX x position of the other end of the path
      * @param destY y position of the other end of the path
@@ -24,7 +26,8 @@ public class ExtraPath {
         this.pathCoords = pathCoords;
     }
 
-    /** Returns x position of path destination
+    /**
+     * Returns x position of path destination
      *
      * @return x position of path destination
      */
@@ -32,7 +35,8 @@ public class ExtraPath {
         return destX;
     }
 
-    /** Returns y position of path destination
+    /**
+     * Returns y position of path destination
      *
      * @return y position of path destination
      */
@@ -40,7 +44,8 @@ public class ExtraPath {
         return destY;
     }
 
-    /** Returns total weight of the path
+    /**
+     * Returns total weight of the path
      *
      * @return total weight of the path
      */
@@ -48,7 +53,8 @@ public class ExtraPath {
         return pathWeight;
     }
 
-    /** Returns a list of the coordinates that make up the path
+    /**
+     * Returns a list of the coordinates that make up the path
      *
      * @return coordinates of path
      */

+ 42 - 20
src/pathgame/algorithm/Node2D.java

@@ -4,7 +4,8 @@ import pathgame.tilemap.TileType;
 
 import java.util.ArrayList;
 
-/** Class for storing node data for the Dijkstra algorithm
+/**
+ * Class for storing node data for the Dijkstra algorithm
  *
  */
 public class Node2D {
@@ -20,7 +21,8 @@ public class Node2D {
 
     private ArrayList<ExtraPath> extraPaths = new ArrayList<>();
 
-    /** Create new Node2D with given weight
+    /**
+     * Create new Node2D with given weight
      *
      * @param weight cost it takes to travel to this node
      */
@@ -28,7 +30,8 @@ public class Node2D {
         this.weight = weight;
     }
 
-    /** Returns the weight of the node
+    /**
+     * Returns the weight of the node
      *
      * @return the weight of the node
      */
@@ -36,7 +39,8 @@ public class Node2D {
         return weight;
     }
 
-    /** Returns the lowest total cost of travelling to this node from where the algorithm started
+    /**
+     * Returns the lowest total cost of travelling to this node from where the algorithm started
      *
      * @return lowest cost to get to this node
      */
@@ -44,7 +48,8 @@ public class Node2D {
         return costSoFar;
     }
 
-    /** Sets the currently lowest total cost of travelling to this node from where the algorithm started
+    /**
+     * Sets the currently lowest total cost of travelling to this node from where the algorithm started
      *
      * @param costSoFar currently lowest cost to get to this node
      */
@@ -52,7 +57,9 @@ public class Node2D {
         this.costSoFar = costSoFar;
     }
 
-    /** Returns a character indicating the previous node of the shortest path from the algorithm's starting point to this node
+    /**
+     * Returns a character indicating the previous node of the shortest path from the algorithm's starting point to this
+     * node
      *
      * @return direction of previous node
      */
@@ -60,7 +67,9 @@ public class Node2D {
         return prevOfPath;
     }
 
-    /** Sets the character indicating the previous node of the shortest path from the algorithm's starting point to this node
+    /**
+     * Sets the character indicating the previous node of the shortest path from the algorithm's starting point to this
+     * node
      *
      * @param prevOfPath direction of previous node
      */
@@ -68,7 +77,8 @@ public class Node2D {
         this.prevOfPath = prevOfPath;
     }
 
-    /** Returns the list of all ExtraPaths of this node
+    /**
+     * Returns the list of all ExtraPaths of this node
      *
      * @return list of ExtraPaths
      */
@@ -76,7 +86,8 @@ public class Node2D {
         return extraPaths;
     }
 
-    /** Creates an ExtraPath using the given parameters and adds it to the node
+    /**
+     * Creates an ExtraPath using the given parameters and adds it to the node
      *
      * @param dest coordinate of the destination of the path
      * @param pathWeight total weight to travel this path
@@ -87,7 +98,8 @@ public class Node2D {
         extraPaths.add(new ExtraPath(dest.getX(), dest.getY(), pathWeight, pathCoords));
     }
 
-    /** Returns hasExtraPaths, which is true, if this node has ExtraPaths
+    /**
+     * Returns hasExtraPaths, which is true, if this node has ExtraPaths
      *
      * @return whether node has ExtraPaths
      */
@@ -95,7 +107,8 @@ public class Node2D {
         return hasExtraPaths;
     }
 
-    /** Returns isQAdded, which is true, if the node has been added to the queue
+    /**
+     * Returns isQAdded, which is true, if the node has been added to the queue
      *
      * @return whether node has been added to the queue
      */
@@ -103,7 +116,8 @@ public class Node2D {
         return isQAdded;
     }
 
-    /** Sets isQAdded, which is true, if the node has been added to the queue
+    /**
+     * Sets isQAdded, which is true, if the node has been added to the queue
      *
      * @param QAdded whether node has been added to the queue
      */
@@ -111,7 +125,8 @@ public class Node2D {
         isQAdded = QAdded;
     }
 
-    /** Returns isBlocked, which is true, if this node can't be travelled to from adjacent nodes
+    /**
+     * Returns isBlocked, which is true, if this node can't be travelled to from adjacent nodes
      *
      * @return whether node is blocked from travel
      */
@@ -119,7 +134,8 @@ public class Node2D {
         return isBlocked;
     }
 
-    /** Sets isBlocked, which is true, if this node can't be travelled to from adjacent nodes
+    /**
+     * Sets isBlocked, which is true, if this node can't be travelled to from adjacent nodes
      *
      * @param blocked whether node is blocked from travel
      */
@@ -127,7 +143,8 @@ public class Node2D {
         isBlocked = blocked;
     }
 
-    /** Returns the type of the Tile that is represented by this node
+    /**
+     * Returns the type of the Tile that is represented by this node
      *
      * @return the type of the tile
      */
@@ -135,7 +152,8 @@ public class Node2D {
         return type;
     }
 
-    /** Sets the type of the Tile that is represented by this node
+    /**
+     * Sets the type of the Tile that is represented by this node
      *
      * @param type the type of the tile
      */
@@ -143,7 +161,8 @@ public class Node2D {
         this.type = type;
     }
 
-    /** Returns the index of the the previous ExtraPath
+    /**
+     * Returns the index of the the previous ExtraPath
      *
      * @return the index of the the previous ExtraPath
      */
@@ -151,7 +170,8 @@ public class Node2D {
         return prevBoatPath;
     }
 
-    /** Sets the index of the the previous ExtraPath
+    /**
+     * Sets the index of the the previous ExtraPath
      *
      * @param prevBoatPath the index of the the previous ExtraPath
      */
@@ -159,7 +179,8 @@ public class Node2D {
         this.prevBoatPath = prevBoatPath;
     }
 
-    /** Returns isTown, which is true if the node is a town
+    /**
+     * Returns isTown, which is true if the node is a town
      *
      * @return whether node is a town
      */
@@ -167,7 +188,8 @@ public class Node2D {
         return isTown;
     }
 
-    /** Sets isTown, which is true if the node is a town
+    /**
+     * Sets isTown, which is true if the node is a town
      *
      * @param town whether node is a town
      */

+ 17 - 10
src/pathgame/algorithm/OddDegreeList.java

@@ -2,14 +2,16 @@ package pathgame.algorithm;
 
 import java.util.ArrayList;
 
-/** Class for storing and managing a list of graph vertexes with odd degrees
+/**
+ * Class for storing and managing a list of graph vertexes with odd degrees
  *
  */
 public class OddDegreeList {
     private ArrayList<Integer> items = new ArrayList<>();
     private ArrayList<Boolean> itemUsed = new ArrayList<>();
 
-    /** Adds a vertex to the list
+    /**
+     * Adds a vertex to the list
      *
      * @param vertex index of the vertex in the list of all vertexes
      */
@@ -18,7 +20,8 @@ public class OddDegreeList {
         itemUsed.add(false);
     }
 
-    /** Returns the size of the list of vertexes
+    /**
+     * Returns the size of the list of vertexes
      *
      * @return the size of the list of vertexes
      */
@@ -26,7 +29,8 @@ public class OddDegreeList {
         return items.size();
     }
 
-    /** Resets which vertexes have already been used for the permutation
+    /**
+     * Resets which vertexes have already been used for the permutation
      *
      */
     public void resetUsed() {
@@ -35,7 +39,8 @@ public class OddDegreeList {
         }
     }
 
-    /** Returns the next unused vertex after the given offset
+    /**
+     * Returns the next unused vertex after the given offset
      *
      * @param offSet number of unused vertexes that are skipped before returning a vertex
      * @return the next unused vertex after the offset
@@ -44,7 +49,8 @@ public class OddDegreeList {
         return items.get(getOffsetPos(offSet));
     }
 
-    /** Makes an unused vertex used after the given offset
+    /**
+     * Makes an unused vertex used after the given offset
      *
      * @param offSet number of unused vertexes that are skipped before making the vertex used
      * @return the index of the vertex that was made used
@@ -55,7 +61,8 @@ public class OddDegreeList {
         return pos;
     }
 
-    /** makes the vertex at the given position unused
+    /**
+     * makes the vertex at the given position unused
      *
      * @param pos index of the vertex that is made unused
      */
@@ -66,9 +73,9 @@ public class OddDegreeList {
     private int getOffsetPos(int offSet) {
         int foundValid = 0;
 
-        for (int i = 0; i < items.size(); i++) {
-            if (!itemUsed.get(i)) {
-                if (offSet == foundValid) {
+        for(int i = 0; i < items.size(); i++) {
+            if(!itemUsed.get(i)) {
+                if(offSet == foundValid) {
                     return i;
                 }
                 foundValid++;

+ 30 - 18
src/pathgame/algorithm/Permutation.java

@@ -1,6 +1,7 @@
 package pathgame.algorithm;
 
-/** Class for generating all possible permutations of travelling salesman paths
+/**
+ * Class for generating all possible permutations of travelling salesman paths
  *
  */
 public class Permutation {
@@ -10,49 +11,54 @@ public class Permutation {
     private int minCost = Integer.MAX_VALUE;
     private int thingsPerPos;
 
-    /** Creates a new Permutation based on the given parameters
+    /**
+     * Creates a new Permutation based on the given parameters
      *
      * @param listSize size of the list the permutation is for
      * @param thingsPerPos number of list items per permutation position - for pairs: 2, for single items: 1
      */
     public Permutation(int listSize, int thingsPerPos) {
         this.thingsPerPos = thingsPerPos;
-        this.size = (listSize/thingsPerPos) - 1;
+        this.size = (listSize / thingsPerPos) - 1;
         vals = new int[size];
 
     }
 
-    /** Returns the offset stored at the given position
+    /**
+     * Returns the offset stored at the given position
      *
      * @param pos position of the permutation from which the value should be returned
      * @return an offset of the Permutation
      */
-    public int getValAtPos (int pos) {
+    public int getValAtPos(int pos) {
         return vals[pos];
     }
 
-    /** Returns true if the offset value at the given position can't be increased further
+    /**
+     * Returns true if the offset value at the given position can't be increased further
      *
      * @param pos position of the permutation that should be checked
      * @return whether offset at the given position is at its maximum
      */
-    public boolean isPosAtMax (int pos) {
+    public boolean isPosAtMax(int pos) {
         if(vals[pos] == getMaxOfPos(pos)) {
             return true;
         }
         return false;
     }
 
-    /** Returns the maximum value an offset can have at the given position
+    /**
+     * Returns the maximum value an offset can have at the given position
      *
      * @param pos position of the permutation that should be checked
      * @return the maximum value an offset can have at the given position
      */
-    public int getMaxOfPos (int pos) {
+    public int getMaxOfPos(int pos) {
         return thingsPerPos * (size - pos);
     }
 
-    /** Returns the size of the permutation
+    /**
+     * Returns the size of the permutation
      *
      * @return the size of the permutation
      */
@@ -60,18 +66,20 @@ public class Permutation {
         return size;
     }
 
-    /** Increases the offset at the given position by 1 and sets all offsets of higher positions back to 0
+    /**
+     * Increases the offset at the given position by 1 and sets all offsets of higher positions back to 0
      *
      * @param pos position of the permutation that should be increased
      */
-    public void increaseAtPos (int pos) {
+    public void increaseAtPos(int pos) {
         vals[pos]++;
-        for(int i = pos+1; i < size; i++) {
+        for(int i = pos + 1; i < size; i++) {
             vals[i] = 0;
         }
     }
 
-    /** Returns the minimum cost stored in this Permutation
+    /**
+     * Returns the minimum cost stored in this Permutation
      *
      * @return the minimum cost stored in this Permutation
      */
@@ -79,7 +87,8 @@ public class Permutation {
         return minCost;
     }
 
-    /** Sets the minimum cost stored in this Permutation
+    /**
+     * Sets the minimum cost stored in this Permutation
      *
      * @param minCost the new minimum cost to be set
      */
@@ -88,14 +97,16 @@ public class Permutation {
         minVals = vals.clone();
     }
 
-    /** Makes the current permutation the new minimum permutation to be stored
+    /**
+     * Makes the current permutation the new minimum permutation to be stored
      *
      */
     public void makePermutMinimal() {
         vals = minVals.clone();
     }
 
-    /** Prints the current permutation
+    /**
+     * Prints the current permutation
      *
      */
     public void printPermut() {
@@ -105,7 +116,8 @@ public class Permutation {
         System.out.println();
     }
 
-    /** Prints the stored minimum permutation
+    /**
+     * Prints the stored minimum permutation
      *
      */
     public void printMinPermut() {

+ 8 - 4
src/pathgame/algorithm/SaleRoute.java

@@ -2,14 +2,16 @@ package pathgame.algorithm;
 
 import java.util.ArrayList;
 
-/** Class for storing one value of the Dijkstra results table
+/**
+ * Class for storing one value of the Dijkstra results table
  *
  */
 public class SaleRoute {
     private ArrayList<Coord> path;
     private int totalCost;
 
-    /** Creates a new SaleRoute with the given parameters
+    /**
+     * Creates a new SaleRoute with the given parameters
      *
      * @param path the list of coordinates making up this path
      * @param totalCost the total cost of this path
@@ -19,7 +21,8 @@ public class SaleRoute {
         this.totalCost = totalCost;
     }
 
-    /** Returns a list of coordinates making up this path
+    /**
+     * Returns a list of coordinates making up this path
      *
      * @return a list of coordinates making up this path
      */
@@ -27,7 +30,8 @@ public class SaleRoute {
         return path;
     }
 
-    /** Returns the total cost of this path
+    /**
+     * Returns the total cost of this path
      *
      * @return the total cost of this path
      */

+ 31 - 44
src/pathgame/algorithm/TravellingSalesAlg.java

@@ -1,17 +1,17 @@
 package pathgame.algorithm;
 
 import pathgame.gameplay.Player;
-import pathgame.logging.Logger;
 import pathgame.tilemap.TileMap;
-
 import java.util.ArrayList;
 import java.util.Collections;
 
-/** Class for calculating an approximation of the travelling salesman problem, using the Christofides algorithm
+/**
+ * Class for calculating an approximation of the travelling salesman problem, using the Christofides algorithm
  *
  */
 public class TravellingSalesAlg {
-    /** Calculates an approximation of the travelling salesman problem, using the Christofides algorithm
+    /**
+     * Calculates an approximation of the travelling salesman problem, using the Christofides algorithm
      *
      * @param map the TileMap that the algorithm should be used on
      * @param player that is traversing the map
@@ -35,11 +35,8 @@ public class TravellingSalesAlg {
         //cut short
         cutShort(eulerTour);
 
-        Logger.onAlgoDone(salesPitch, eulerTour);
-
         //calculate the total weight of the tour using the edge table (salesPitch)
         int tourWeight = calcTourWeight(eulerTour, salesPitch);
-        System.out.println("min cost: " + tourWeight);
         return tourWeight;
 
         //brute force
@@ -49,15 +46,14 @@ public class TravellingSalesAlg {
     private static int calcTourWeight(ArrayList<Integer> tour, ArrayList<ArrayList<SaleRoute>> salesPitch) {
         int totalWeight = 0;
 
-        for(int i = 0; i < tour.size()-1; i++) {
+        for(int i = 0; i < tour.size() - 1; i++) {
             int startNode, endNode;
 
-            if(tour.get(i) < tour.get(i+1)) {
+            if(tour.get(i) < tour.get(i + 1)) {
                 startNode = tour.get(i);
-                endNode = tour.get(i+1) - startNode - 1;
-            }
-            else {
-                startNode = tour.get(i+1);
+                endNode = tour.get(i + 1) - startNode - 1;
+            } else {
+                startNode = tour.get(i + 1);
                 endNode = tour.get(i) - startNode - 1;
             }
             totalWeight += salesPitch.get(startNode).get(endNode).getTotalCost();
@@ -68,7 +64,7 @@ public class TravellingSalesAlg {
     private static void cutShort(ArrayList<Integer> eulerTour) {
         int counter = 2;
 
-        while(counter < eulerTour.size()-1) {
+        while(counter < eulerTour.size() - 1) {
             int current = eulerTour.get(counter);
 
             boolean found = false;
@@ -82,8 +78,7 @@ public class TravellingSalesAlg {
 
             if(found) {
                 eulerTour.remove(counter);
-            }
-            else {
+            } else {
                 counter++;
             }
         }
@@ -92,11 +87,10 @@ public class TravellingSalesAlg {
     private static ArrayList<Integer> getEulerTour(ArrayList<TreeEdge> graph) {
         ArrayList<Integer> tour = new ArrayList<>();
 
-        while (graph.size() > 0) {
+        while(graph.size() > 0) {
             if(tour.size() == 0) {
                 tour = getSubtour(graph, graph.get(0).getSrc());
-            }
-            else {
+            } else {
                 int start = -1;
 
                 for(int e = 0; e < graph.size(); e++) {
@@ -105,13 +99,12 @@ public class TravellingSalesAlg {
                         if(edge.getSrc() == tour.get(tp)) {
                             start = edge.getSrc();
                             break;
-                        }
-                        else if(edge.getDest() == tour.get(tp)) {
+                        } else if(edge.getDest() == tour.get(tp)) {
                             start = edge.getDest();
                             break;
                         }
                     }
-                    if(start!= -1) {
+                    if(start != -1) {
                         break;
                     }
                 }
@@ -134,7 +127,7 @@ public class TravellingSalesAlg {
         graph.remove(pos);
         tour.add(next);
 
-        while (next != start) {
+        while(next != start) {
             pos = nextTourEdgePos(graph, next);
             next = graph.get(pos).getOtherVertex(next);
             graph.remove(pos);
@@ -160,29 +153,29 @@ public class TravellingSalesAlg {
         int mergePos = -1;
 
         for(int i = 0; i < tour.size(); i++) {
-            if (tour.get(i) == mergeTo) {
+            if(tour.get(i) == mergeTo) {
                 mergePos = i;
             }
         }
 
-        for(int i = subTour.size()-1; i > 0; i--) {
-            tour.add(mergePos+1, subTour.get(i));
+        for(int i = subTour.size() - 1; i > 0; i--) {
+            tour.add(mergePos + 1, subTour.get(i));
         }
     }
 
     private static ArrayList<TreeEdge> makeOddDegEdges(ArrayList<TreeEdge> msTree, ArrayList<ArrayList<SaleRoute>> salesPitch) {
         int numOfEdges[] = new int[salesPitch.size()];
 
-        for (int i = 0; i < msTree.size(); i++) {
+        for(int i = 0; i < msTree.size(); i++) {
             numOfEdges[msTree.get(i).getSrc()]++;
             numOfEdges[msTree.get(i).getDest()]++;
         }
 
         OddDegreeList oddDegs = new OddDegreeList();
 
-        for (int i = 0; i < numOfEdges.length; i++) {
+        for(int i = 0; i < numOfEdges.length; i++) {
             //System.out.println(numOfEdges[i]);
-            if (numOfEdges[i] % 2 == 1) {
+            if(numOfEdges[i] % 2 == 1) {
                 oddDegs.add(i);
             }
         }
@@ -196,7 +189,6 @@ public class TravellingSalesAlg {
         //System.out.println(permut.tempCounter2);
         //System.out.println("min cost: " + permut.getMinCost());
         //permut.printPermut();
-
         ArrayList<TreeEdge> oddEdges = new ArrayList<>();
         oddDegs.resetUsed();
         for(int i = 0; i < permut.size(); i++) {
@@ -225,8 +217,7 @@ public class TravellingSalesAlg {
 
             if(permutPos == permut.size()) {
                 offSet = 0;
-            }
-            else {
+            } else {
                 offSet = permut.getValAtPos(permutPos);
             }
 
@@ -242,7 +233,6 @@ public class TravellingSalesAlg {
             System.out.println(orig + " : " + dest);
             System.out.println("newCost: " + newCost);
             permut.printPermut();*/
-
             if(newCost < permut.getMinCost()) {
                 if(permutPos == permut.size()) {
                     permut.setMinCost(newCost);
@@ -250,11 +240,10 @@ public class TravellingSalesAlg {
                     System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
                     System.out.println("New Min: " + newCost);
                     System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");*/
-                }
-                else {
+                } else {
                     int used1 = oddDegs.makeOffsetUsed(0);
                     int used2 = oddDegs.makeOffsetUsed(offSet);
-                    calcPairShortest(oddDegs, salesPitch, permut, permutPos+1, costSoFar+edgeWeight);
+                    calcPairShortest(oddDegs, salesPitch, permut, permutPos + 1, costSoFar + edgeWeight);
                     oddDegs.makeUnused(used1);
                     oddDegs.makeUnused(used2);
                 }
@@ -278,8 +267,8 @@ public class TravellingSalesAlg {
 
         int vertNum = salesPitch.size();
 
-        for (int orig = 0; orig < salesPitch.size(); orig++) {
-            for (int dest = 0; dest < salesPitch.get(orig).size(); dest++) {
+        for(int orig = 0; orig < salesPitch.size(); orig++) {
+            for(int dest = 0; dest < salesPitch.get(orig).size(); dest++) {
                 allEdges.add(new TreeEdge(orig, dest + 1 + orig, salesPitch.get(orig).get(dest).getTotalCost()));
                 //System.out.println(edge.getSrc() + " " + edge.getDest() + " " + edge.getWeight());
                 //System.out.println(salesPitch.get(orig).get(dest).getTotalCost());
@@ -287,12 +276,11 @@ public class TravellingSalesAlg {
         }
 
         //System.out.println(vertNum);
-
         Collections.sort(allEdges);
 
-        while (msTree.size() < vertNum - 1) {
+        while(msTree.size() < vertNum - 1) {
 
-            if (notCycle(msTree, allEdges.get(0))) {
+            if(notCycle(msTree, allEdges.get(0))) {
                 msTree.add(allEdges.get(0));
                 //System.out.println(allEdges.get(0).getSrc() + " " + allEdges.get(0).getDest() + " " + allEdges.get(0).getWeight());
             }
@@ -327,8 +315,7 @@ public class TravellingSalesAlg {
             edgeQ.remove(0);
             if(edge.getSrc() == dest || edge.getDest() == dest) {
                 return false;
-            }
-            else {
+            } else {
                 qEdges(tree, edgeQ, edge.getSrc());
                 qEdges(tree, edgeQ, edge.getDest());
             }
@@ -342,4 +329,4 @@ public class TravellingSalesAlg {
             tree.get(i).setChecked(false);
         }
     }
-}
+}

+ 20 - 12
src/pathgame/algorithm/TreeEdge.java

@@ -1,13 +1,15 @@
 package pathgame.algorithm;
 
-/** Class that stores data for a graph edge
+/**
+ * Class that stores data for a graph edge
  *
  */
-public class TreeEdge implements Comparable< TreeEdge > {
+public class TreeEdge implements Comparable< TreeEdge> {
     private int src, dest, weight;
     private boolean checked = false;
 
-    /** Creates a new TreeEdge with the given parameters
+    /**
+     * Creates a new TreeEdge with the given parameters
      *
      * @param src the index of the source vertex of the edge
      * @param dest the index of the destination vertex of the edge
@@ -19,7 +21,8 @@ public class TreeEdge implements Comparable< TreeEdge > {
         this.weight = weight;
     }
 
-    /** Returns the index of the source vertex of the edge
+    /**
+     * Returns the index of the source vertex of the edge
      *
      * @return the index of the source vertex of the edge
      */
@@ -27,7 +30,8 @@ public class TreeEdge implements Comparable< TreeEdge > {
         return src;
     }
 
-    /** Returns the index of the destination vertex of the edge
+    /**
+     * Returns the index of the destination vertex of the edge
      *
      * @return the index of the destination vertex of the edge
      */
@@ -35,7 +39,8 @@ public class TreeEdge implements Comparable< TreeEdge > {
         return dest;
     }
 
-    /** Returns the index of the other vertex, using the given vertex
+    /**
+     * Returns the index of the other vertex, using the given vertex
      *
      * @param other the vertex index that shouldn't be returned
      * @return the other vertex index
@@ -43,13 +48,13 @@ public class TreeEdge implements Comparable< TreeEdge > {
     public int getOtherVertex(int other) {
         if(other == src) {
             return dest;
-        }
-        else  {
+        } else {
             return src;
         }
     }
 
-    /** Returns the weight of the edge
+    /**
+     * Returns the weight of the edge
      *
      * @return the weight of the edge
      */
@@ -57,7 +62,8 @@ public class TreeEdge implements Comparable< TreeEdge > {
         return weight;
     }
 
-    /** Returns isChecked, which is true if the TreeEdge has been checked
+    /**
+     * Returns isChecked, which is true if the TreeEdge has been checked
      *
      * @return whether this TreeEdge has been checked
      */
@@ -65,7 +71,8 @@ public class TreeEdge implements Comparable< TreeEdge > {
         return checked;
     }
 
-    /** Sets isChecked, which is true if the TreeEdge has been checked
+    /**
+     * Sets isChecked, which is true if the TreeEdge has been checked
      *
      * @param checked new status of whether this TreeEdge has been checked
      */
@@ -73,7 +80,8 @@ public class TreeEdge implements Comparable< TreeEdge > {
         this.checked = checked;
     }
 
-    /** Used for sorting Collections of TreeEdges
+    /**
+     * Used for sorting Collections of TreeEdges
      *
      * @param o the TreeEdge that this one is being compared to
      * @return the result of compareTo()

+ 9 - 12
src/pathgame/gameplay/Facing.java

@@ -1,21 +1,18 @@
 package pathgame.gameplay;
 
-public enum Facing
-{
-    NORTH(3), 
-    EAST(2), 
-    SOUTH(0), 
+public enum Facing {
+    NORTH(3),
+    EAST(2),
+    SOUTH(0),
     WEST(1);
-    
+
     private final int index;
-    
-    private Facing(int index)
-    {
+
+    private Facing(int index) {
         this.index = index;
     }
-    
-    public int getIndex()
-    {
+
+    public int getIndex() {
         return index;
     }
 }

+ 5 - 10
src/pathgame/gameplay/Gamestate.java

@@ -5,8 +5,7 @@ package pathgame.gameplay;
  *
  * @author julia
  */
-public class Gamestate
-{
+public class Gamestate {
     private Gamestates state = Gamestates.MENU;
 
     /**
@@ -14,8 +13,7 @@ public class Gamestate
      *
      * @param state the desired gamestate
      */
-    public void setState(Gamestates state)
-    {
+    public void setState(Gamestates state) {
         this.state = state;
     }
 
@@ -24,20 +22,17 @@ public class Gamestate
      *
      * @return the current game state
      */
-    public Gamestates getState()
-    {
+    public Gamestates getState() {
         return state;
     }
 
     /**
      * Returns if current gamestate is same as gamestate from parameter
      *
-     * @param gamestate the gamestate that has to be checked if it is the
-     * current
+     * @param gamestate the gamestate that has to be checked if it is the current
      * @return if current gamestate is same as gamestate from parameter
      */
-    public boolean is(Gamestates gamestate)
-    {
+    public boolean is(Gamestates gamestate) {
         return state == gamestate;
     }
 }

+ 1 - 2
src/pathgame/gameplay/Gamestates.java

@@ -1,6 +1,5 @@
 package pathgame.gameplay;
 
-public enum Gamestates
-{
+public enum Gamestates {
     GAMEPLAY, MENU
 }

+ 13 - 21
src/pathgame/gameplay/Keys.java

@@ -13,8 +13,7 @@ import org.lwjgl.glfw.GLFW;
  *
  * @author julia
  */
-public class Keys
-{
+public class Keys {
     public static final KeyBinding UP_KEY = KeyHandler.register(GLFW.GLFW_KEY_W);
     public static final KeyBinding DOWN_KEY = KeyHandler.register(GLFW.GLFW_KEY_S);
     public static final KeyBinding LEFT_KEY = KeyHandler.register(GLFW.GLFW_KEY_A);
@@ -34,8 +33,7 @@ public class Keys
     /**
      * An array of all rebindable keys
      */
-    public static final KeyBinding[] KEYS = new KeyBinding[]
-    {
+    public static final KeyBinding[] KEYS = new KeyBinding[]{
         UP_KEY, DOWN_KEY, LEFT_KEY, RIGHT_KEY, ZOOM_IN_KEY, ZOOM_OUT_KEY,
         CAM_UP_KEY, CAM_DOWN_KEY, CAM_LEFT_KEY,
         CAM_RIGHT_KEY, OVERLAY_KEY, BOAT_KEY
@@ -44,27 +42,21 @@ public class Keys
     /**
      * An array of the names of all rebindable keys
      */
-    public static final String[] KEYNAMES =
-    {
-        "Up Key", "Down Key", "Left Key", "Right Key", "Zoom In Key",
-        "Zoom Out Key", "Cam Up Key", "Cam Down Key", "Cam Left Key",
-        "Cam Right Key", "Overlay Key", "Boat Key"
-    };
+    public static final String[] KEYNAMES
+            = {
+                "Up Key", "Down Key", "Left Key", "Right Key", "Zoom In Key",
+                "Zoom Out Key", "Cam Up Key", "Cam Down Key", "Cam Left Key",
+                "Cam Right Key", "Overlay Key", "Boat Key"
+            };
 
-    static
-    {
+    static {
         File f = new File("resources/config.bin");
-        if(f.exists())
-        {
-            try(DataInputStream reader = new DataInputStream(new FileInputStream(f)))
-            {
-                for(int i = 0; i < KEYS.length; ++i)
-                {
+        if(f.exists()) {
+            try(DataInputStream reader = new DataInputStream(new FileInputStream(f))) {
+                for(int i = 0; i < KEYS.length; ++i) {
                     KeyHandler.rebind(KEYS[i], reader.readInt());
                 }
-            }
-            catch(IOException ex)
-            {
+            } catch(IOException ex) {
             }
         }
     }

+ 19 - 40
src/pathgame/gameplay/Level.java

@@ -1,7 +1,6 @@
 package pathgame.gameplay;
 
 import pathgame.algorithm.TravellingSalesAlg;
-import pathgame.logging.Logger;
 import pathgame.tilemap.TileMap;
 import pathgame.tilemap.TileMapGenerator;
 
@@ -10,14 +9,12 @@ import pathgame.tilemap.TileMapGenerator;
  *
  * @author julia
  */
-public final class Level
-{
-
+public final class Level {
     public final static float ALGORITHM_1 = 1.0f;
     public final static float ALGORITHM_2 = 1.1f;
     public final static float ALGORITHM_3 = 1.2f;
     public final static float ALGORITHM_4 = 1.3f;
-    
+
     private final Player player = new Player();
     private int level = 1;
     private TileMap map = null;
@@ -28,30 +25,23 @@ public final class Level
     /**
      * Contructor generating and initializing new Level and Player
      */
-    public Level()
-    {
+    public Level() {
         reset();
     }
 
     /**
-     * Checks gamestate changes every gametick based on user input and game
-     * events
+     * Checks gamestate changes every gametick based on user input and game events
      *
      * @param gamestate the gamestate
      */
-    public void tick(Gamestate gamestate)
-    {
+    public void tick(Gamestate gamestate) {
         map.tick();
-        if(gamestate.is(Gamestates.GAMEPLAY) && !showScoreMenu)
-        {
+        if(gamestate.is(Gamestates.GAMEPLAY) && !showScoreMenu) {
             player.tick(map);
         }
-        if(gamestate.is(Gamestates.GAMEPLAY) && !showScoreMenu && (player.hasLost() || player.hasWon()))
-        {
+        if(gamestate.is(Gamestates.GAMEPLAY) && !showScoreMenu && (player.hasLost() || player.hasWon())) {
             showScoreMenu = true;
-        }
-        else if(showScoreMenu && Keys.CONFIRM_KEY.getTime() == 1)
-        {
+        } else if(showScoreMenu && Keys.CONFIRM_KEY.getTime() == 1) {
             showScoreMenu = false;
             showAfterScore = true;
         }
@@ -60,8 +50,7 @@ public final class Level
     /**
      * Loads the next level
      */
-    public void nextLevel()
-    {
+    public void nextLevel() {
         level++;
         reset();
     }
@@ -69,8 +58,7 @@ public final class Level
     /**
      * Resets the current level
      */
-    public void reset()
-    {
+    public void reset() {
         int levelW = Math.round(16.0f + (level * 16.0f / 9.0f));
         int levelH = Math.round(9.0f + (level * 16.0f / 16.0f));
         int towns = Math.round(2.0f + level * 0.5f);
@@ -81,8 +69,6 @@ public final class Level
 
         algorithm = TravellingSalesAlg.calcSalesPathLen(map, player);
         player.setEnergySupply(Math.round(algorithm * ALGORITHM_4));
-
-        Logger.onLevelReset(level, player, map);
     }
 
     /**
@@ -90,8 +76,7 @@ public final class Level
      *
      * @return the map of the current level
      */
-    public TileMap getMap()
-    {
+    public TileMap getMap() {
         return map;
     }
 
@@ -100,8 +85,7 @@ public final class Level
      *
      * @return the player of the current level
      */
-    public Player getPlayer()
-    {
+    public Player getPlayer() {
         return player;
     }
 
@@ -110,28 +94,25 @@ public final class Level
      *
      * @return the current level
      */
-    public int getLevel()
-    {
+    public int getLevel() {
         return level;
     }
-    
+
     /**
      * Returns the energy use of the algorithm
      *
      * @return the energy use of the algorithm
      */
-    public int getAlgorithmValue()
-    {
+    public int getAlgorithmValue() {
         return algorithm;
     }
-    
+
     /**
      * Returns if the AfterScoreMenu is showed
      *
      * @return if the AfterScoreMenu is showed
      */
-    public boolean isShowingAfterScore()
-    {
+    public boolean isShowingAfterScore() {
         return showAfterScore;
     }
 
@@ -140,8 +121,7 @@ public final class Level
      *
      * @param show sets if the AfterScore should be showed
      */
-    public void setShowAfterScore(boolean show)
-    {
+    public void setShowAfterScore(boolean show) {
         showAfterScore = show;
     }
 
@@ -150,8 +130,7 @@ public final class Level
      *
      * @return if the ScoreMenu is showed
      */
-    public boolean isShowingScoreMenu()
-    {
+    public boolean isShowingScoreMenu() {
         return showScoreMenu;
     }
 }

+ 7 - 14
src/pathgame/gameplay/MinusStepsValues.java

@@ -1,13 +1,11 @@
 package pathgame.gameplay;
 
 /**
- * A container for holding an energy cost from the step of the player with a
- * lifetime for showing in the HUD
+ * A container for holding an energy cost from the step of the player with a lifetime for showing in the HUD
  *
  * @author julia
  */
-public class MinusStepsValues
-{
+public class MinusStepsValues {
     private final int minusValue;
     private int lifeTime = 0;
 
@@ -16,8 +14,7 @@ public class MinusStepsValues
      *
      * @param minusValue energyCost of a step of the player
      */
-    public MinusStepsValues(int minusValue)
-    {
+    public MinusStepsValues(int minusValue) {
         this.minusValue = minusValue;
     }
 
@@ -26,8 +23,7 @@ public class MinusStepsValues
      *
      * @return energyCost value
      */
-    public int getValue()
-    {
+    public int getValue() {
         return minusValue;
     }
 
@@ -36,19 +32,16 @@ public class MinusStepsValues
      *
      * @return energyCost lifetime
      */
-    public int getLifeTime()
-    {
+    public int getLifeTime() {
         return lifeTime;
     }
 
     /**
-     * Recalculates the lifetime every gametick and returns if energyCost is
-     * still alive
+     * Recalculates the lifetime every gametick and returns if energyCost is still alive
      *
      * @return if energyCost is still alive
      */
-    public boolean tick()
-    {
+    public boolean tick() {
         lifeTime++;
         return lifeTime >= 10;
     }

+ 57 - 125
src/pathgame/gameplay/Player.java

@@ -2,7 +2,6 @@ package pathgame.gameplay;
 
 import java.util.Iterator;
 import java.util.LinkedList;
-import pathgame.logging.Logger;
 import pathgame.tilemap.Tile;
 import pathgame.tilemap.TileMap;
 import pathgame.tilemap.Tiles;
@@ -12,8 +11,7 @@ import pathgame.tilemap.Tiles;
  *
  * @author julia
  */
-public class Player
-{
+public class Player {
     private static final float SPEED = 0.25f;
 
     private int ticksLived = 0;
@@ -38,15 +36,14 @@ public class Player
     private int objectivesVisited = 0;
     private final LinkedList<MinusStepsValues> steps = new LinkedList<>();
     private Tile currentTile = Tiles.HOME_TOWN;
-    
+
     private Facing facing = Facing.SOUTH;
 
     /**
      * Constructor of the player
      *
      */
-    public Player()
-    {
+    public Player() {
     }
 
     /**
@@ -54,8 +51,7 @@ public class Player
      *
      * @return x-position of the player of the last frame
      */
-    public float getLastX()
-    {
+    public float getLastX() {
         return lastX;
     }
 
@@ -64,8 +60,7 @@ public class Player
      *
      * @return y-position of the player of the last frame
      */
-    public float getLastY()
-    {
+    public float getLastY() {
         return lastY;
     }
 
@@ -74,8 +69,7 @@ public class Player
      *
      * @return current x-position of the player
      */
-    public float getX()
-    {
+    public float getX() {
         return x;
     }
 
@@ -84,19 +78,15 @@ public class Player
      *
      * @return current y-position of the player
      */
-    public float getY()
-    {
+    public float getY() {
         return y;
     }
 
-    private void tickSteps()
-    {
+    private void tickSteps() {
         Iterator<MinusStepsValues> iter = steps.iterator();
-        while(iter.hasNext())
-        {
+        while(iter.hasNext()) {
             MinusStepsValues next = iter.next();
-            if(next.tick())
-            {
+            if(next.tick()) {
                 iter.remove();
             }
         }
@@ -107,8 +97,7 @@ public class Player
      *
      * @param map the current map
      */
-    public void tick(TileMap map)
-    {
+    public void tick(TileMap map) {
         ticksLived++;
         tickSteps();
 
@@ -120,13 +109,10 @@ public class Player
         lastX = x;
         lastY = y;
 
-        if(isOnTile())
-        {
+        if(isOnTile()) {
             velX = 0.0f;
             velY = 0.0f;
-            if(isMoving)
-            {
-                Logger.onTileEnter(this, map, currentTileX, currentTileY);
+            if(isMoving) {
                 currentTile.onEnter(this, map, currentTileX, currentTileY);
                 steps.addLast(new MinusStepsValues(currSpeedSlowdown));
                 energyUsed += currSpeedSlowdown;
@@ -135,73 +121,51 @@ public class Player
             currentTile.isStandingOn(this, map, currentTileX, currentTileY);
         }
 
-        if(Keys.LEFT_KEY.isDown() && !isMoving && currentTileX > 0 && !map.getTile(currentTileX - 1, currentTileY).isBlockingMovement(this))
-        {
+        if(Keys.LEFT_KEY.isDown() && !isMoving && currentTileX > 0 && !map.getTile(currentTileX - 1, currentTileY).isBlockingMovement(this)) {
             facing = Facing.WEST;
             velX = -SPEED;
             isMoving = true;
-            Logger.onTileLeave(this, map, currentTileX, currentTileY);
             currentTile.onLeave(this, map, currentTileX, currentTileY);
-        }
-        else if(Keys.RIGHT_KEY.isDown() && !isMoving && currentTileX < map.getWidth() - 1 && !map.getTile(currentTileX + 1, currentTileY).isBlockingMovement(this))
-        {
+        } else if(Keys.RIGHT_KEY.isDown() && !isMoving && currentTileX < map.getWidth() - 1 && !map.getTile(currentTileX + 1, currentTileY).isBlockingMovement(this)) {
             facing = Facing.EAST;
             velX = SPEED;
             isMoving = true;
-            Logger.onTileLeave(this, map, currentTileX, currentTileY);
             currentTile.onLeave(this, map, currentTileX, currentTileY);
-        }
-        else if(Keys.UP_KEY.isDown() && !isMoving && currentTileY > 0 && !map.getTile(currentTileX, currentTileY - 1).isBlockingMovement(this))
-        {
+        } else if(Keys.UP_KEY.isDown() && !isMoving && currentTileY > 0 && !map.getTile(currentTileX, currentTileY - 1).isBlockingMovement(this)) {
             facing = Facing.NORTH;
             velY = -SPEED;
             isMoving = true;
-            Logger.onTileLeave(this, map, currentTileX, currentTileY);
             currentTile.onLeave(this, map, currentTileX, currentTileY);
-        }
-        else if(Keys.DOWN_KEY.isDown() && !isMoving && currentTileY < map.getHeight() - 1 && !map.getTile(currentTileX, currentTileY + 1).isBlockingMovement(this))
-        {
+        } else if(Keys.DOWN_KEY.isDown() && !isMoving && currentTileY < map.getHeight() - 1 && !map.getTile(currentTileX, currentTileY + 1).isBlockingMovement(this)) {
             facing = Facing.SOUTH;
             velY = SPEED;
             isMoving = true;
-            Logger.onTileLeave(this, map, currentTileX, currentTileY);
             currentTile.onLeave(this, map, currentTileX, currentTileY);
         }
 
         float moveX = Math.abs(velX / currSpeedSlowdown);
         float moveY = Math.abs(velY / currSpeedSlowdown);
-        if(velX < 0.0f)
-        {
+        if(velX < 0.0f) {
             float d = x - (float) Math.floor(x);
-            if(d < 0.01f)
-            {
+            if(d < 0.01f) {
                 d = 1.0f;
             }
             moveX = -Math.min(moveX, d);
-        }
-        else if(velX > 0.0f)
-        {
+        } else if(velX > 0.0f) {
             float d = (float) Math.ceil(x) - x;
-            if(d < 0.01f)
-            {
+            if(d < 0.01f) {
                 d = 1.0f;
             }
             moveX = Math.min(moveX, d);
-        }
-        else if(velY < 0.0f)
-        {
+        } else if(velY < 0.0f) {
             float d = y - (float) Math.floor(y);
-            if(d < 0.01f)
-            {
+            if(d < 0.01f) {
                 d = 1.0f;
             }
             moveY = -Math.min(moveY, d);
-        }
-        else if(velY > 0.0f)
-        {
+        } else if(velY > 0.0f) {
             float d = (float) Math.ceil(y) - y;
-            if(d < 0.01f)
-            {
+            if(d < 0.01f) {
                 d = 1.0f;
             }
             moveY = Math.min(moveY, d);
@@ -210,8 +174,7 @@ public class Player
         y += moveY;
     }
 
-    private boolean isOnTile()
-    {
+    private boolean isOnTile() {
         return Math.abs(x - Math.round(x)) < 0.01f && Math.abs(y - Math.round(y)) < 0.01f;
     }
 
@@ -220,8 +183,7 @@ public class Player
      *
      * @return the current x-velocity of the player
      */
-    public float getVelX()
-    {
+    public float getVelX() {
         return velX;
     }
 
@@ -230,8 +192,7 @@ public class Player
      *
      * @return the current y-velocity of the player
      */
-    public float getVelY()
-    {
+    public float getVelY() {
         return velY;
     }
 
@@ -240,8 +201,7 @@ public class Player
      *
      * @return the overall energy supply of the player for the current map
      */
-    public int getEnergySupply()
-    {
+    public int getEnergySupply() {
         return energySupply;
     }
 
@@ -250,8 +210,7 @@ public class Player
      *
      * @return the current energy of the player that is left for the current map
      */
-    public int getEnergyLeft()
-    {
+    public int getEnergyLeft() {
         return energySupply - energyUsed;
     }
 
@@ -260,8 +219,7 @@ public class Player
      *
      * @return the energy of the player that is already used for the current map
      */
-    public int getEnergyUsed()
-    {
+    public int getEnergyUsed() {
         return energyUsed;
     }
 
@@ -270,19 +228,16 @@ public class Player
      *
      * @return the overall amount of objectives that the player has to visit
      */
-    public int getObjectivesAmount()
-    {
+    public int getObjectivesAmount() {
         return objectivesAmount;
     }
 
     /**
      * Sets the overall amount of objectives that the player has to visit
      *
-     * @param objectivesAmount sets the overall amount of objectives that the
-     * player has to visit
+     * @param objectivesAmount sets the overall amount of objectives that the player has to visit
      */
-    public void setObjectivesAmount(int objectivesAmount)
-    {
+    public void setObjectivesAmount(int objectivesAmount) {
         this.objectivesAmount = objectivesAmount;
     }
 
@@ -291,16 +246,14 @@ public class Player
      *
      * @return the amount of objectives that the player has already to visited
      */
-    public int getObjectivesVisited()
-    {
+    public int getObjectivesVisited() {
         return objectivesVisited;
     }
 
     /**
      * Player visits a town and updates the player statistics
      */
-    public void visitTown()
-    {
+    public void visitTown() {
         objectivesVisited++;
     }
 
@@ -309,8 +262,7 @@ public class Player
      *
      * @return a list of the last energy costs of the last steps of the player
      */
-    public LinkedList<MinusStepsValues> getLastSteps()
-    {
+    public LinkedList<MinusStepsValues> getLastSteps() {
         return steps;
     }
 
@@ -319,8 +271,7 @@ public class Player
      *
      * @param playerAbilities sets the abilities of the player
      */
-    public void setAbilities(PlayerAbilities playerAbilities)
-    {
+    public void setAbilities(PlayerAbilities playerAbilities) {
         abilities = playerAbilities;
     }
 
@@ -329,31 +280,25 @@ public class Player
      *
      * @return the abilities of the player
      */
-    public PlayerAbilities getAbilities()
-    {
+    public PlayerAbilities getAbilities() {
         return abilities;
     }
 
     /**
      * Sets the overall energy supply for the player for the current map
      *
-     * @param energySupply sets the overall energy supply for the player for the
-     * current map
+     * @param energySupply sets the overall energy supply for the player for the current map
      */
-    public void setEnergySupply(int energySupply)
-    {
+    public void setEnergySupply(int energySupply) {
         this.energySupply = energySupply;
     }
 
     /**
-     * Returns if player has already visited all towns and is allowed win when
-     * going to the start field
+     * Returns if player has already visited all towns and is allowed win when going to the start field
      *
-     * @return if player has already visited all towns and is allowed win when
-     * going to the start field
+     * @return if player has already visited all towns and is allowed win when going to the start field
      */
-    public boolean canWin()
-    {
+    public boolean canWin() {
         return objectivesVisited >= objectivesAmount;
     }
 
@@ -362,18 +307,15 @@ public class Player
      *
      * @return if player has already won the current map
      */
-    public boolean hasWon()
-    {
+    public boolean hasWon() {
         return hasWon;
     }
 
     /**
      * Player wins and updates the player statistics
      */
-    public void win(TileMap map)
-    {
+    public void win(TileMap map) {
         this.hasWon = true;
-        Logger.onWin(this, map);
     }
 
     /**
@@ -381,8 +323,7 @@ public class Player
      *
      * @return if player has lost the current map
      */
-    public boolean hasLost()
-    {
+    public boolean hasLost() {
         return energyUsed > energySupply || (currentTile != Tiles.HOME_TOWN && energyUsed == energySupply);
     }
 
@@ -394,8 +335,7 @@ public class Player
      * @param energySupply overall energy supply for current map
      * @param objectivesAmount objectives amount on current map
      */
-    public void reset(int sx, int sy, int energySupply, int objectivesAmount)
-    {
+    public void reset(int sx, int sy, int energySupply, int objectivesAmount) {
         ticksLived = 0;
 
         lastX = sx;
@@ -419,14 +359,12 @@ public class Player
     }
 
     /**
-     * Player is resetted, energy supply is set to standard of 1000, objectives
-     * amount is set to standard of 10
+     * Player is resetted, energy supply is set to standard of 1000, objectives amount is set to standard of 10
      *
      * @param sx start x-position
      * @param sy start y-position
      */
-    public void reset(int sx, int sy)
-    {
+    public void reset(int sx, int sy) {
         reset(sx, sy, 1000, 10);
     }
 
@@ -435,16 +373,14 @@ public class Player
      *
      * @return if player is currently moving
      */
-    public boolean isMoving()
-    {
+    public boolean isMoving() {
         return isMoving;
     }
 
     /**
      * Changes Player state to sailing
      */
-    public void switchSailing()
-    {
+    public void switchSailing() {
         isSailing = !isSailing;
     }
 
@@ -453,8 +389,7 @@ public class Player
      *
      * @return if player is currently sailing
      */
-    public boolean isSailing()
-    {
+    public boolean isSailing() {
         return isSailing;
     }
 
@@ -463,8 +398,7 @@ public class Player
      *
      * @return the tile the player is currently standing on
      */
-    public Tile getCurrTile()
-    {
+    public Tile getCurrTile() {
         return currentTile;
     }
 
@@ -473,18 +407,16 @@ public class Player
      *
      * @return how much ticks this player is alive
      */
-    public int getTicksLived()
-    {
+    public int getTicksLived() {
         return ticksLived;
     }
-    
+
     /**
      * Returns the direction the player is facing.
      *
      * @return the direction the player is facing
      */
-    public Facing getFacing()
-    {
+    public Facing getFacing() {
         return facing;
     }
 }

+ 18 - 36
src/pathgame/gameplay/PlayerAbilities.java

@@ -5,8 +5,7 @@ package pathgame.gameplay;
  *
  * @author julia
  */
-public class PlayerAbilities
-{
+public class PlayerAbilities {
     private final String name;
     private final int fasterGrass;
     private final int fasterForest;
@@ -20,24 +19,16 @@ public class PlayerAbilities
      * Contructor initializing new player abilities
      *
      * @param name name of the character type with this specific abilities
-     * @param fasterGrass the energyCostsPoints the player can move faster on
-     * grass tiles
-     * @param fasterForest the energyCostsPoints the player can move faster on
-     * forest tiles
-     * @param fasterShallowWater the energyCostsPoints the player can move
-     * faster on shallow water tiles
-     * @param fasterDeepWater the energyCostsPoints the player can move faster
-     * on deep water tiles
-     * @param fasterHill the energyCostsPoints the player can move faster on
-     * hill tiles
-     * @param fasterMountain the energyCostsPoints the player can move faster on
-     * mountain tiles
-     * @param fasterSwamp the energyCostsPoints the player can move faster on
-     * swamp tiles
+     * @param fasterGrass the energyCostsPoints the player can move faster on grass tiles
+     * @param fasterForest the energyCostsPoints the player can move faster on forest tiles
+     * @param fasterShallowWater the energyCostsPoints the player can move faster on shallow water tiles
+     * @param fasterDeepWater the energyCostsPoints the player can move faster on deep water tiles
+     * @param fasterHill the energyCostsPoints the player can move faster on hill tiles
+     * @param fasterMountain the energyCostsPoints the player can move faster on mountain tiles
+     * @param fasterSwamp the energyCostsPoints the player can move faster on swamp tiles
      */
     private PlayerAbilities(String name, int fasterGrass, int fasterForest, int fasterShallowWater,
-            int fasterDeepWater, int fasterHill, int fasterMountain, int fasterSwamp)
-    {
+            int fasterDeepWater, int fasterHill, int fasterMountain, int fasterSwamp) {
         this.name = name;
         this.fasterGrass = fasterGrass;
         this.fasterForest = fasterForest;
@@ -56,8 +47,7 @@ public class PlayerAbilities
     /**
      * Array of all character types
      */
-    public final static PlayerAbilities[] ABILITIES = new PlayerAbilities[]
-    {
+    public final static PlayerAbilities[] ABILITIES = new PlayerAbilities[]{
         NORMAL, HIKER, HUNTER, SWIMMER, SAILOR
     };
 
@@ -66,8 +56,7 @@ public class PlayerAbilities
      *
      * @return the energyCostPoints the player is faster on grass tiles
      */
-    public int getFasterGrass()
-    {
+    public int getFasterGrass() {
         return fasterGrass;
     }
 
@@ -76,8 +65,7 @@ public class PlayerAbilities
      *
      * @return the energyCostPoints the player is faster on forest tiles
      */
-    public int getFasterForest()
-    {
+    public int getFasterForest() {
         return fasterForest;
     }
 
@@ -86,8 +74,7 @@ public class PlayerAbilities
      *
      * @return the energyCostPoints the player is faster on shallow water tiles
      */
-    public int getFasterShallowWater()
-    {
+    public int getFasterShallowWater() {
         return fasterShallowWater;
     }
 
@@ -96,8 +83,7 @@ public class PlayerAbilities
      *
      * @return the energyCostPoints the player is faster on deep water tiles
      */
-    public int getFasterDeepWater()
-    {
+    public int getFasterDeepWater() {
         return fasterDeepWater;
     }
 
@@ -106,8 +92,7 @@ public class PlayerAbilities
      *
      * @return the energyCostPoints the player is faster on hill tiles
      */
-    public int getFasterHill()
-    {
+    public int getFasterHill() {
         return fasterHill;
     }
 
@@ -116,8 +101,7 @@ public class PlayerAbilities
      *
      * @return the energyCostPoints the player is faster on mountain tiles
      */
-    public int getFasterMountain()
-    {
+    public int getFasterMountain() {
         return fasterMountain;
     }
 
@@ -126,8 +110,7 @@ public class PlayerAbilities
      *
      * @return the energyCostPoints the player is faster on swamp tiles
      */
-    public int getFasterSwamp()
-    {
+    public int getFasterSwamp() {
         return fasterSwamp;
     }
 
@@ -136,8 +119,7 @@ public class PlayerAbilities
      *
      * @return the name of the current character type
      */
-    public String getName()
-    {
+    public String getName() {
         return name;
     }
 }

+ 12 - 17
src/pathgame/gameplay/menu/AfterScoreMenu.java

@@ -7,42 +7,38 @@ import pathgame.gameplay.Gamestates;
  *
  * @author julia
  */
-public class AfterScoreMenu extends BaseMenu
-{
+public class AfterScoreMenu extends BaseMenu {
     private final MenuButton[] options;
 
     /**
      * Contructor generating and initializing the AfterScoreMenu
-     * 
+     *
      * @param id the id of the AfterScoreMenu
      * @param mainId the id to the MainMenu
      */
-    public AfterScoreMenu(int id, int mainId)
-    {
+    public AfterScoreMenu(int id, int mainId) {
         super(id);
 
-        options = new MenuButton[]
-        {
-            new MenuButton("Next Level", (gamestate, level) ->
-            {
+        options = new MenuButton[]{
+            new MenuButton("Next Level", (gamestate, level)
+            -> {
                 level.nextLevel();
                 level.getPlayer().setAbilities(level.getPlayer().getAbilities());
                 gamestate.setState(Gamestates.GAMEPLAY);
                 level.setShowAfterScore(false);
             }),
-            new MenuButton("Retry", (gamestate, level) ->
-            {
+            new MenuButton("Retry", (gamestate, level)
+            -> {
                 level.reset();
                 level.getPlayer().setAbilities(level.getPlayer().getAbilities());
                 gamestate.setState(Gamestates.GAMEPLAY);
                 level.setShowAfterScore(false);
             }),
-            new MenuButton("Main Menu", (gamestate, level) ->
-            {
+            new MenuButton("Main Menu", (gamestate, level)
+            -> {
                 level.setShowAfterScore(false);
                 setReturnId(mainId);
-            }),
-        };
+            }),};
     }
 
     /**
@@ -51,8 +47,7 @@ public class AfterScoreMenu extends BaseMenu
      * @return the options of the AfterScoreMenu
      */
     @Override
-    public MenuButton[] getOptions()
-    {
+    public MenuButton[] getOptions() {
         return options;
     }
 

+ 13 - 28
src/pathgame/gameplay/menu/BaseMenu.java

@@ -10,8 +10,7 @@ import pathgame.gameplay.Level;
  *
  * @author julia
  */
-public abstract class BaseMenu
-{
+public abstract class BaseMenu {
     private final int id;
     private int index = 0;
 
@@ -23,8 +22,7 @@ public abstract class BaseMenu
      *
      * @param id the id of the desired menu
      */
-    public BaseMenu(int id)
-    {
+    public BaseMenu(int id) {
         this.id = id;
     }
 
@@ -33,8 +31,7 @@ public abstract class BaseMenu
      *
      * @return the index of the active menu button
      */
-    public int getActiveIndex()
-    {
+    public int getActiveIndex() {
         return index;
     }
 
@@ -43,38 +40,29 @@ public abstract class BaseMenu
      *
      * @return if this is the OptionMenu
      */
-    public boolean isOptionMenu()
-    {
+    public boolean isOptionMenu() {
         return false;
     }
 
     /**
-     * Updates the menu state every gametick based on user input and returns the
-     * id of the current menu
+     * Updates the menu state every gametick based on user input and returns the id of the current menu
      *
      * @param gamestate the gamestate
      * @param level a level containing the current map and the current player
      *
      * @return the id of the current menu
      */
-    public int tick(Gamestate gamestate, Level level)
-    {
+    public int tick(Gamestate gamestate, Level level) {
         returnId = id;
-        if(isKeyPressed(Keys.UP_KEY) || isKeyPressed(Keys.CAM_UP_KEY))
-        {
+        if(isKeyPressed(Keys.UP_KEY) || isKeyPressed(Keys.CAM_UP_KEY)) {
             int length = getOptions().length;
             index = ((index - 1) + length) % length;
-        }
-        else if(isKeyPressed(Keys.DOWN_KEY) || isKeyPressed(Keys.CAM_DOWN_KEY))
-        {
+        } else if(isKeyPressed(Keys.DOWN_KEY) || isKeyPressed(Keys.CAM_DOWN_KEY)) {
             index = (index + 1) % getOptions().length;
-        }
-        else if(isKeyPressed(Keys.CONFIRM_KEY))
-        {
+        } else if(isKeyPressed(Keys.CONFIRM_KEY)) {
             getOptions()[index].run(gamestate, level);
         }
-        if(returnId != id)
-        {
+        if(returnId != id) {
             index = 0;
         }
         return returnId;
@@ -86,8 +74,7 @@ public abstract class BaseMenu
      * @param id the id of the current menu
      *
      */
-    public void setReturnId(int id)
-    {
+    public void setReturnId(int id) {
         returnId = id;
     }
 
@@ -95,8 +82,7 @@ public abstract class BaseMenu
      * Resets the index of the current button to the first button
      *
      */
-    public void resetIndex()
-    {
+    public void resetIndex() {
         index = 0;
     }
 
@@ -106,8 +92,7 @@ public abstract class BaseMenu
      * @param key the key that is checked
      * @return if the key is pressed
      */
-    private boolean isKeyPressed(KeyBinding key)
-    {
+    private boolean isKeyPressed(KeyBinding key) {
         return key.getTime() == 1 || (key.getTime() >= 20 && key.getTime() % 5 == 1);
     }
 

+ 10 - 15
src/pathgame/gameplay/menu/CharacterMenu.java

@@ -8,34 +8,30 @@ import pathgame.gameplay.PlayerAbilities;
  *
  * @author julia
  */
-public class CharacterMenu extends BaseMenu
-{
+public class CharacterMenu extends BaseMenu {
     private final MenuButton[] options;
 
     /**
      * Contructor generating and initializing the CharacterMenu
-     * 
+     *
      * @param id the id of the CharacterMenu
      * @param mainId the id to the MainMenu
      */
-    public CharacterMenu(int id, int mainId)
-    {
+    public CharacterMenu(int id, int mainId) {
         super(id);
         options = new MenuButton[PlayerAbilities.ABILITIES.length + 1];
-        for(int i = 0; i < options.length - 1; ++i)
-        {
+        for(int i = 0; i < options.length - 1; ++i) {
             options[i] = getAbilityOption(PlayerAbilities.ABILITIES[i]);
         }
-        options[options.length - 1] = new MenuButton("Back", (gamestate) ->
-        {
+        options[options.length - 1] = new MenuButton("Back", (gamestate)
+                -> {
             setReturnId(mainId);
         });
     }
 
-    private static MenuButton getAbilityOption(PlayerAbilities pa)
-    {
-        return new MenuButton(pa.getName(), (gamestate, level) ->
-        {
+    private static MenuButton getAbilityOption(PlayerAbilities pa) {
+        return new MenuButton(pa.getName(), (gamestate, level)
+                -> {
             level.reset();
             level.getPlayer().setAbilities(pa);
             gamestate.setState(Gamestates.GAMEPLAY);
@@ -48,8 +44,7 @@ public class CharacterMenu extends BaseMenu
      * @return the options of the CharacterMenu
      */
     @Override
-    public MenuButton[] getOptions()
-    {
+    public MenuButton[] getOptions() {
         return options;
     }
 }

+ 14 - 19
src/pathgame/gameplay/menu/EscMenu.java

@@ -8,8 +8,7 @@ import pathgame.gameplay.Gamestates;
  *
  * @author julia
  */
-public class EscMenu extends BaseMenu
-{
+public class EscMenu extends BaseMenu {
     private final MenuButton[] options;
 
     /**
@@ -18,30 +17,27 @@ public class EscMenu extends BaseMenu
      * @param id the id of the EscapeMenu
      * @param mainId the id to the MainMenu
      */
-    public EscMenu(int id, int mainId)
-    {
+    public EscMenu(int id, int mainId) {
         super(id);
 
-        options = new MenuButton[]
-        {
-            new MenuButton("Continue", (gamestate) ->
-            {
+        options = new MenuButton[]{
+            new MenuButton("Continue", (gamestate)
+            -> {
                 gamestate.setState(Gamestates.GAMEPLAY);
             }),
-            new MenuButton("Retry", (gamestate, level) ->
-            {
+            new MenuButton("Retry", (gamestate, level)
+            -> {
                 level.reset();
-                gamestate.setState(Gamestates.GAMEPLAY);                
+                gamestate.setState(Gamestates.GAMEPLAY);
             }),
-            new MenuButton("Main Menu", (gamestate) ->
-            {
+            new MenuButton("Main Menu", (gamestate)
+            -> {
                 setReturnId(mainId);
             }),
-            new MenuButton("Exit", (gamestate) ->
-            {
+            new MenuButton("Exit", (gamestate)
+            -> {
                 Engine.stop();
-            }),
-        };
+            }),};
     }
 
     /**
@@ -50,8 +46,7 @@ public class EscMenu extends BaseMenu
      * @return the options of the EscapeMenu
      */
     @Override
-    public MenuButton[] getOptions()
-    {
+    public MenuButton[] getOptions() {
         return options;
     }
 }

+ 10 - 14
src/pathgame/gameplay/menu/MainMenu.java

@@ -7,8 +7,7 @@ import me.hammerle.snuviengine.api.Engine;
  *
  * @author julia
  */
-public class MainMenu extends BaseMenu
-{
+public class MainMenu extends BaseMenu {
     private final MenuButton[] options;
 
     /**
@@ -18,22 +17,20 @@ public class MainMenu extends BaseMenu
      * @param optionsId the id to the OptionMenu
      * @param characterId the id to the CharacterMenu
      */
-    public MainMenu(int id, int optionsId, int characterId)
-    {
+    public MainMenu(int id, int optionsId, int characterId) {
         super(id);
 
-        options = new MenuButton[]
-        {
-            new MenuButton("Start", (gamestate) ->
-            {
+        options = new MenuButton[]{
+            new MenuButton("Start", (gamestate)
+            -> {
                 setReturnId(characterId);
             }),
-            new MenuButton("Options", (gamestate) ->
-            {
+            new MenuButton("Options", (gamestate)
+            -> {
                 setReturnId(optionsId);
             }),
-            new MenuButton("Exit", (gamestate) ->
-            {
+            new MenuButton("Exit", (gamestate)
+            -> {
                 Engine.stop();
             })
         };
@@ -45,8 +42,7 @@ public class MainMenu extends BaseMenu
      * @return the options of the MainMenu
      */
     @Override
-    public MenuButton[] getOptions()
-    {
+    public MenuButton[] getOptions() {
         return options;
     }
 }

+ 14 - 30
src/pathgame/gameplay/menu/Menu.java

@@ -10,16 +10,14 @@ import pathgame.gameplay.Level;
  *
  * @author julia
  */
-public class Menu
-{
+public class Menu {
     private final static int MAIN_ID;
     private final static int ESCAPE_ID;
     private final static int OPTION_ID;
     private final static int CHARACTER_ID;
     private final static int AFTER_SCORE_ID;
 
-    static
-    {
+    static {
         int id = 0;
         MAIN_ID = id++;
         ESCAPE_ID = id++;
@@ -28,8 +26,7 @@ public class Menu
         AFTER_SCORE_ID = id++;
     }
 
-    private final BaseMenu[] menus = new BaseMenu[]
-    {
+    private final BaseMenu[] menus = new BaseMenu[]{
         new MainMenu(MAIN_ID, OPTION_ID, CHARACTER_ID),
         new EscMenu(ESCAPE_ID, MAIN_ID),
         new OptionMenu(OPTION_ID, MAIN_ID),
@@ -45,29 +42,20 @@ public class Menu
      * @param gamestate the gamestate
      * @param level a level containing the current map and the current player
      */
-    public void tick(Gamestate gamestate, Level level)
-    {
-        if(gamestate.getState() == Gamestates.MENU)
-        {
+    public void tick(Gamestate gamestate, Level level) {
+        if(gamestate.getState() == Gamestates.MENU) {
             currentIndex = menus[currentIndex].tick(gamestate, level);
-            if(currentIndex == ESCAPE_ID && Keys.ESCAPE_KEY.getTime() == 1)
-            {
+            if(currentIndex == ESCAPE_ID && Keys.ESCAPE_KEY.getTime() == 1) {
                 gamestate.setState(Gamestates.GAMEPLAY);
-            }
-            else if((currentIndex == OPTION_ID || currentIndex == CHARACTER_ID)
-                    && Keys.ESCAPE_KEY.getTime() == 1)
-            {
+            } else if((currentIndex == OPTION_ID || currentIndex == CHARACTER_ID)
+                    && Keys.ESCAPE_KEY.getTime() == 1) {
                 currentIndex = MAIN_ID;
             }
-        }
-        else if(gamestate.getState() == Gamestates.GAMEPLAY && Keys.ESCAPE_KEY.getTime() == 1)
-        {
+        } else if(gamestate.getState() == Gamestates.GAMEPLAY && Keys.ESCAPE_KEY.getTime() == 1) {
             currentIndex = ESCAPE_ID;
             gamestate.setState(Gamestates.MENU);
             menus[currentIndex].resetIndex();
-        }
-        else if(level.isShowingAfterScore())
-        {
+        } else if(level.isShowingAfterScore()) {
             currentIndex = AFTER_SCORE_ID;
             gamestate.setState(Gamestates.MENU);
             menus[currentIndex].resetIndex();
@@ -79,8 +67,7 @@ public class Menu
      *
      * @return the array of menu buttons of the menu
      */
-    public MenuButton[] getOptions()
-    {
+    public MenuButton[] getOptions() {
         return menus[currentIndex].getOptions();
     }
 
@@ -89,8 +76,7 @@ public class Menu
      *
      * @return the index of the active menu button
      */
-    public int getActiveIndex()
-    {
+    public int getActiveIndex() {
         return menus[currentIndex].getActiveIndex();
     }
 
@@ -99,8 +85,7 @@ public class Menu
      *
      * @return if this is the OptionMenu
      */
-    public boolean isOptionMenu()
-    {
+    public boolean isOptionMenu() {
         return menus[currentIndex].isOptionMenu();
     }
 
@@ -108,8 +93,7 @@ public class Menu
      * Opens the escape menu
      *
      */
-    public void showEscapeMenu()
-    {
+    public void showEscapeMenu() {
         currentIndex = ESCAPE_ID;
     }
 }

+ 5 - 10
src/pathgame/gameplay/menu/MenuButton.java

@@ -10,8 +10,7 @@ import pathgame.gameplay.Level;
  *
  * @author julia
  */
-public class MenuButton
-{
+public class MenuButton {
     private final String name;
     private final BiConsumer<Gamestate, Level> r;
 
@@ -21,8 +20,7 @@ public class MenuButton
      * @param name the name of the button to be shown to the player
      * @param r function that is executed when pressed on the button
      */
-    public MenuButton(String name, BiConsumer<Gamestate, Level> r)
-    {
+    public MenuButton(String name, BiConsumer<Gamestate, Level> r) {
         this.name = name;
         this.r = r;
     }
@@ -33,8 +31,7 @@ public class MenuButton
      * @param name the name of the button to be shown to the player
      * @param r function that is executed when pressed on the button
      */
-    public MenuButton(String name, Consumer<Gamestate> r)
-    {
+    public MenuButton(String name, Consumer<Gamestate> r) {
         this(name, (gamestate, level) -> r.accept(gamestate));
     }
 
@@ -43,8 +40,7 @@ public class MenuButton
      *
      * @return the name of the button
      */
-    public String getName()
-    {
+    public String getName() {
         return name;
     }
 
@@ -54,8 +50,7 @@ public class MenuButton
      * @param gamestate the gamestate
      * @param level the current level
      */
-    public void run(Gamestate gamestate, Level level)
-    {
+    public void run(Gamestate gamestate, Level level) {
         r.accept(gamestate, level);
     }
 }

+ 11 - 23
src/pathgame/gameplay/menu/OptionMenu.java

@@ -13,8 +13,7 @@ import pathgame.gameplay.Keys;
  *
  * @author julia
  */
-public class OptionMenu extends BaseMenu
-{
+public class OptionMenu extends BaseMenu {
     private final MenuButton[] options;
 
     /**
@@ -23,36 +22,27 @@ public class OptionMenu extends BaseMenu
      * @param id the id of the OptionMenu
      * @param mainId the id to the MainMenu
      */
-    public OptionMenu(int id, int mainId)
-    {
+    public OptionMenu(int id, int mainId) {
         super(id);
         int menuLength = Keys.KEYS.length;
         options = new MenuButton[menuLength + 1];
-        for(int i = 0; i < menuLength; ++i)
-        {
+        for(int i = 0; i < menuLength; ++i) {
             options[i] = getButton(Keys.KEYNAMES[i], Keys.KEYS[i]);
         }
-        options[menuLength] = new MenuButton("Back to Main Menu", (gamestate) ->
-        {
+        options[menuLength] = new MenuButton("Back to Main Menu", (gamestate) -> {
             File f = new File("resources/config.bin");
-            try(DataOutputStream writer = new DataOutputStream(new FileOutputStream(f)))
-            {
-                for(int i = 0; i < Keys.KEYS.length; ++i)
-                {
+            try(DataOutputStream writer = new DataOutputStream(new FileOutputStream(f))) {
+                for(int i = 0; i < Keys.KEYS.length; ++i) {
                     writer.writeInt(Keys.KEYS[i].getKey());
                 }
-            }
-            catch(IOException ex)
-            {
+            } catch(IOException ex) {
             }
             setReturnId(mainId);
         });
     }
 
-    private MenuButton getButton(String name, KeyBinding key)
-    {
-        return new MenuButton(name, (gamestate) ->
-        {
+    private MenuButton getButton(String name, KeyBinding key) {
+        return new MenuButton(name, (gamestate) -> {
             KeyHandler.rebind(key);
         });
     }
@@ -63,8 +53,7 @@ public class OptionMenu extends BaseMenu
      * @return the options of the OptionMenu
      */
     @Override
-    public MenuButton[] getOptions()
-    {
+    public MenuButton[] getOptions() {
         return options;
     }
 
@@ -74,8 +63,7 @@ public class OptionMenu extends BaseMenu
      * @return if this is the OptionMenu
      */
     @Override
-    public boolean isOptionMenu()
-    {
+    public boolean isOptionMenu() {
         return true;
     }
 }

+ 0 - 118
src/pathgame/logging/Logger.java

@@ -1,118 +0,0 @@
-package pathgame.logging;
-
-import pathgame.algorithm.SaleRoute;
-import pathgame.gameplay.Player;
-import pathgame.tilemap.TileMap;
-
-import java.io.IOException;
-import java.nio.charset.StandardCharsets;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-import java.util.ArrayList;
-import java.util.List;
-
-public class Logger
-{
-    private static int leaveX = 0;
-    private static int leaveY = 0;
-    private static int currentLevel = 0;
-
-    private static List<String> path = new ArrayList<String>();
-    private static List<String> pathCoords = new ArrayList<String>();
-
-
-    public static void logFile(){
-
-        try {
-            Files.write(Paths.get("logfiles/level"+ currentLevel +".txt"), path, StandardCharsets.UTF_8);
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
-
-        try {
-            Files.write(Paths.get("logfiles/level"+ currentLevel +"Coords.txt"), pathCoords, StandardCharsets.UTF_8);
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
-        path.clear();
-        pathCoords.clear();
-    }
-
-
-    public static void onLevelReset(int level, Player p, TileMap map)
-    {
-        currentLevel = level;
-        System.out.println("Level Reset " + level);
-    }
-    
-    public static void onTileEnter(Player p, TileMap map, int x, int y)
-    {
-        //System.out.println("Tile Enter " + x + " " + y);
-
-        if(leaveX < x){
-            System.out.println("Right");
-            path.add("Right");
-        } else if(leaveX > x) {
-            System.out.println("Left");
-            path.add("Left");
-        } else if(leaveY > y) {
-            System.out.println("Up");
-            path.add("Up");
-        } else if(leaveY < y) {
-            System.out.println("Down");
-            path.add("Down");
-        }
-    }
-    
-    public static void onTileLeave(Player p, TileMap map, int x, int y)
-    {
-        leaveX = x;
-        leaveY = y;
-
-        pathCoords.add("x:" + x + " y:" + y);
-        //System.out.println("Tile Leave " + x + " " + y);
-    }
-    
-    public static void onWin(Player p, TileMap map)
-    {
-        System.out.println("Win");
-        int playerValue = p.getEnergyUsed();
-        int algoValue = p.getEnergySupply()/130*100;
-        
-        if(playerValue < algoValue){
-            logFile();
-            System.out.println("saving...");
-        }
-    }
-
-    public static void onAlgoDone(ArrayList<ArrayList<SaleRoute>> salesPitch, ArrayList<Integer> eulerTour) {
-        System.out.println("algorithm done");
-        /*TODO: follow the eulerTour, getting salesPitch.get(x).get(y).get(path)
-          TODO: and getting the x and y value of each coord in that list and logging them*/
-        /*x and y correspond indirectly to values of the eulerTour
-        * salesPitch is structured like so:
-        *          [town0]  [town1]  [town2]  [town3] ...
-        * [town0]     -     x:0/y:0  x:0/y:1  x:0/y:2
-        * [town1]     -        -     x:1/y:0  x:1/y:1
-        * [town2]     -        -        -     x:2/y:0
-        * [town3]     -        -        -        -
-        * ...*/
-        /*so to get the path between node 0 and 1 use salesPitch.get(0).get(0).get(path);
-        * (x is equal to [townRowIndex], y is equal to [townColIndex] - x - 1 (!!!))
-        * note that paths between x and y are equal to paths between y and x, but only one can be found in salesPitch
-        * so the path between 0 - 1 and 1 - 0 are the same, but only 0 - 1 can be accessed
-        * make sure that x <= y to not go out of bounds*/
-
-        /*Example eulerTour: 3, 0, 1, 2, 3
-        * Therefore, the paths logged need to be:
-        * salesPitch.get(0).get(2).get(path)
-        * salesPitch.get(0).get(0).get(path)
-        * salesPitch.get(1).get(0).get(path)
-        * salesPitch.get(2).get(0).get(path)
-        * */
-
-        /*NOTE: for visual representation, algorithm coordinates don't have to be logged in order
-        * for the final representation to be correct. If the end-output is a list of coordinates, though,
-        * it may be necessary to order the coordinates to form a continuous path*/
-    }
-}

+ 27 - 55
src/pathgame/rendering/Camera.java

@@ -10,8 +10,7 @@ import pathgame.gameplay.Level;
  *
  * @author julia
  */
-public class Camera
-{
+public class Camera {
     private final static int CAM_SPEED = 64;
 
     private float lastScale = 1.0f;
@@ -28,37 +27,28 @@ public class Camera
      * @param level a level containing the current map and the current player
      * @param gamestate the gamestate
      */
-    public void tick(Level level, Gamestate gamestate)
-    {
+    public void tick(Level level, Gamestate gamestate) {
         lastCamOffsetX = camOffsetX;
         lastCamOffsetY = camOffsetY;
         lastScale = scale;
 
-        if(!level.getPlayer().isMoving() && gamestate.is(Gamestates.GAMEPLAY))
-        {
-            if(Keys.ZOOM_IN_KEY.isDown())
-            {
+        if(!level.getPlayer().isMoving() && gamestate.is(Gamestates.GAMEPLAY)) {
+            if(Keys.ZOOM_IN_KEY.isDown()) {
                 scale *= 1.1f;
-            }
-            else if(Keys.ZOOM_OUT_KEY.isDown())
-            {
+            } else if(Keys.ZOOM_OUT_KEY.isDown()) {
                 scale /= 1.1f;
             }
 
-            if(Keys.CAM_UP_KEY.isDown())
-            {
+            if(Keys.CAM_UP_KEY.isDown()) {
                 camOffsetY += CAM_SPEED;
             }
-            if(Keys.CAM_DOWN_KEY.isDown())
-            {
+            if(Keys.CAM_DOWN_KEY.isDown()) {
                 camOffsetY -= CAM_SPEED;
             }
-            if(Keys.CAM_LEFT_KEY.isDown())
-            {
+            if(Keys.CAM_LEFT_KEY.isDown()) {
                 camOffsetX += CAM_SPEED;
             }
-            if(Keys.CAM_RIGHT_KEY.isDown())
-            {
+            if(Keys.CAM_RIGHT_KEY.isDown()) {
                 camOffsetX -= CAM_SPEED;
             }
         }
@@ -67,17 +57,13 @@ public class Camera
     /**
      * Limits scale of camera
      *
-     * @param zoomRestriction the lower zoom factor restriction (zooming out
-     * restriction)
+     * @param zoomRestriction the lower zoom factor restriction (zooming out restriction)
      */
-    public void limitScale(float zoomRestriction)
-    {
-        if(scale <= zoomRestriction)
-        {
+    public void limitScale(float zoomRestriction) {
+        if(scale <= zoomRestriction) {
             scale = zoomRestriction;
         }
-        if(lastScale <= zoomRestriction)
-        {
+        if(lastScale <= zoomRestriction) {
             lastScale = zoomRestriction;
         }
 
@@ -87,8 +73,7 @@ public class Camera
      * Resetting the camera to focus the player
      *
      */
-    public void reset()
-    {
+    public void reset() {
         camOffsetX = 0.0f;
         camOffsetY = 0.0f;
         lastCamOffsetX = 0.0f;
@@ -101,8 +86,7 @@ public class Camera
      * @param lag the render lag
      * @return the interpolated scale
      */
-    public float getInterpolatedScale(float lag)
-    {
+    public float getInterpolatedScale(float lag) {
         return lastScale + (scale - lastScale) * lag;
     }
 
@@ -110,29 +94,23 @@ public class Camera
      * Returns the x-offset of the camera to the player
      *
      * @param offX the x-offset of the map
-     * @param minOffX the minimum x-offset restriction of the camera to prevent
-     * going outside the screen
+     * @param minOffX the minimum x-offset restriction of the camera to prevent going outside the screen
      * @param lag the render lag
      * @param interScale the interpolated scale
      * @return the x-offset of the camera to the player
      */
-    public float getCamOffsetX(float offX, float minOffX, float lag, float interScale)
-    {
+    public float getCamOffsetX(float offX, float minOffX, float lag, float interScale) {
         float interCamX = lastCamOffsetX + (camOffsetX - lastCamOffsetX) * lag;
-        if(offX + interCamX > 0.0f)
-        {
+        if(offX + interCamX > 0.0f) {
             camOffsetX = -offX;
-            if(lastCamOffsetX > camOffsetX)
-            {
+            if(lastCamOffsetX > camOffsetX) {
                 lastCamOffsetX = camOffsetX;
             }
             interCamX = lastCamOffsetX + (camOffsetX - lastCamOffsetX) * lag;
         }
-        if(offX + interCamX < minOffX)
-        {
+        if(offX + interCamX < minOffX) {
             camOffsetX = minOffX - offX;
-            if(lastCamOffsetX < camOffsetX)
-            {
+            if(lastCamOffsetX < camOffsetX) {
                 lastCamOffsetX = camOffsetX;
             }
             interCamX = lastCamOffsetX + (camOffsetX - lastCamOffsetX) * lag;
@@ -144,29 +122,23 @@ public class Camera
      * Returns the y-offset of the camera to the player
      *
      * @param offY the y-offset of the map
-     * @param minOffY the minimum y-offset restriction of the camera to prevent
-     * going outside the screen
+     * @param minOffY the minimum y-offset restriction of the camera to prevent going outside the screen
      * @param lag the render lag
      * @param interScale the interpolated scale
      * @return the y-offset of the camera to the player
      */
-    public float getCamOffsetY(float offY, float minOffY, float lag, float interScale)
-    {
+    public float getCamOffsetY(float offY, float minOffY, float lag, float interScale) {
         float interCamY = lastCamOffsetY + (camOffsetY - lastCamOffsetY) * lag;
-        if(offY + interCamY > 0.0f)
-        {
+        if(offY + interCamY > 0.0f) {
             camOffsetY = -offY;
-            if(lastCamOffsetY > camOffsetY)
-            {
+            if(lastCamOffsetY > camOffsetY) {
                 lastCamOffsetY = camOffsetY;
             }
             interCamY = lastCamOffsetY + (camOffsetY - lastCamOffsetY) * lag;
         }
-        if(offY + interCamY < minOffY)
-        {
+        if(offY + interCamY < minOffY) {
             camOffsetY = minOffY - offY;
-            if(lastCamOffsetY < camOffsetY)
-            {
+            if(lastCamOffsetY < camOffsetY) {
                 lastCamOffsetY = camOffsetY;
             }
             interCamY = lastCamOffsetY + (camOffsetY - lastCamOffsetY) * lag;

+ 10 - 19
src/pathgame/rendering/HUDRenderer.java

@@ -11,15 +11,13 @@ import pathgame.gameplay.Player;
  *
  * @author julia
  */
-public class HUDRenderer
-{
-
+public class HUDRenderer {
     public static final float OFFSET_Y = 40;
     private static final Texture ENERGYBAR = new Texture("resources/energyBars.png");
 
     /**
-     * Recalculates the rendering positions and settings of the HUD-elements on
-     * the screen every rendertick based on the gamelogic in the gametick
+     * Recalculates the rendering positions and settings of the HUD-elements on the screen every rendertick based on the
+     * gamelogic in the gametick
      *
      * @param r the renderer
      * @param p the current player
@@ -38,8 +36,7 @@ public class HUDRenderer
         renderMinusEnergy(r, p, lag);
     }
 
-    private void renderHUDBackgound(Renderer r)
-    {
+    private void renderHUDBackgound(Renderer r) {
         r.setMixColorEnabled(true);
         r.setColorEnabled(true);
         r.setTextureEnabled(false);
@@ -48,8 +45,7 @@ public class HUDRenderer
         r.getColorRenderer().drawRectangle(0, 0, r.getViewWidth(), 20, 0xFF_00_00_00);//ABGR
     }
 
-    private void renderObjectiveTracker(Renderer r, Player p)
-    {
+    private void renderObjectiveTracker(Renderer r, Player p) {
         r.setMixColorEnabled(false);
         r.setColorEnabled(true);
         r.setTextureEnabled(true);
@@ -58,8 +54,7 @@ public class HUDRenderer
         r.getFontRenderer().drawString(2, 6, objectiveTracker);
     }
 
-    private void renderEnergyText(Renderer r, Player p)
-    {
+    private void renderEnergyText(Renderer r, Player p) {
         r.setMixColorEnabled(false);
         r.setColorEnabled(true);
         r.setTextureEnabled(true);
@@ -72,16 +67,14 @@ public class HUDRenderer
                 6, energy);
     }
 
-    private void renderEnergyBar(Renderer r, Player p)
-    {
+    private void renderEnergyBar(Renderer r, Player p) {
         r.setMixColorEnabled(true);
         r.setColorEnabled(false);
         r.setTextureEnabled(true);
         r.setBlendingEnabled(true);
 
         float energyPercent = 100 / (float) p.getEnergySupply() * (float) p.getEnergyLeft() / 100;
-        if(energyPercent < 0)
-        {
+        if(energyPercent < 0) {
             energyPercent = 0;
         }
         ENERGYBAR.bind();
@@ -90,15 +83,13 @@ public class HUDRenderer
 
     }
 
-    private void renderMinusEnergy(Renderer r, Player p, float lag)
-    {
+    private void renderMinusEnergy(Renderer r, Player p, float lag) {
         r.setMixColorEnabled(false);
         r.setColorEnabled(true);
         r.setTextureEnabled(true);
 
         LinkedList<MinusStepsValues> steps = p.getLastSteps();
-        for(MinusStepsValues step : steps)
-        {
+        for(MinusStepsValues step : steps) {
             String minusEnergy = String.format("&4-%d", step.getValue());
             r.getFontRenderer().drawString(r.getViewWidth() * 0.5f - 63, 9 + step.getLifeTime() + lag, minusEnergy);
         }

+ 17 - 35
src/pathgame/rendering/LevelRenderer.java

@@ -12,8 +12,7 @@ import pathgame.tilemap.TileMap;
  *
  * @author julia
  */
-public class LevelRenderer
-{
+public class LevelRenderer {
     private final PlayerRenderer playerRenderer = new PlayerRenderer();
     private final TileMapRenderer mapRenderer = new TileMapRenderer();
     private final HUDRenderer hudRenderer = new HUDRenderer();
@@ -21,35 +20,30 @@ public class LevelRenderer
     private final ScoreMenuRenderer scoreRenderer = new ScoreMenuRenderer();
 
     /**
-     * Calls the camera tick and the mapRenderer tick and resets the camera if
-     * the player is moving
+     * Calls the camera tick and the mapRenderer tick and resets the camera if the player is moving
      *
      * @param level a level containing the current map and the current player
      * @param gamestate the gamestate
      */
-    public void tick(Level level, Gamestate gamestate)
-    {
+    public void tick(Level level, Gamestate gamestate) {
         cam.tick(level, gamestate);
         mapRenderer.tick();
-        if(level.getPlayer().isMoving())
-        {
+        if(level.getPlayer().isMoving()) {
             cam.reset();
         }
     }
 
     /**
-     * Recalculates the rendering position and settings of everything in the
-     * level every rendertick based on the gamelogic in the gametick
+     * Recalculates the rendering position and settings of everything in the level every rendertick based on the
+     * gamelogic in the gametick
      *
      * @param r the renderer
      * @param lag the current lag
      * @param level the current level containing the map and the player
      * @param gamestate the gamestate
      */
-    public void renderTick(Renderer r, float lag, Level level, Gamestate gamestate)
-    {
-        if(level.isShowingAfterScore() || level.isShowingScoreMenu())
-        {
+    public void renderTick(Renderer r, float lag, Level level, Gamestate gamestate) {
+        if(level.isShowingAfterScore() || level.isShowingScoreMenu()) {
             lag = 0.0f;
         }
         TileMap map = level.getMap();
@@ -68,51 +62,39 @@ public class LevelRenderer
 
         mapRenderer.renderTick(map, r, player, false, offX, offY);
 
-        if(gamestate.is(Gamestates.GAMEPLAY))
-        {
+        if(gamestate.is(Gamestates.GAMEPLAY)) {
             playerRenderer.renderTick(map, mapRenderer, r, player, lag, offX, offY);
-            if(!level.isShowingScoreMenu())
-            {
+            if(!level.isShowingScoreMenu()) {
                 hudRenderer.renderTick(r, player, lag);
-            }
-            else if(level.isShowingScoreMenu())
-            {
+            } else if(level.isShowingScoreMenu()) {
                 scoreRenderer.renderTick(r, lag, level);
             }
         }
 
     }
 
-    private float getMapOffsetX(TileMap map, Player player, Renderer r, float lag, float interScale)
-    {
+    private float getMapOffsetX(TileMap map, Player player, Renderer r, float lag, float interScale) {
         float ix = (player.getLastX() + (player.getX() - player.getLastX()) * lag) * interScale * TileRenderer.TILE_SIZE;
         float offX = (-ix + r.getViewWidth() * 0.5f) - TileRenderer.TILE_SIZE * 0.5f * interScale;
 
         float minOffX = -mapRenderer.getWidth(map) + r.getViewWidth();
-        if(offX < minOffX)
-        {
+        if(offX < minOffX) {
             return cam.getCamOffsetX(minOffX, minOffX, lag, interScale);
-        }
-        else if(offX > 0.0f)
-        {
+        } else if(offX > 0.0f) {
             return cam.getCamOffsetX(0.0f, minOffX, lag, interScale);
         }
         return cam.getCamOffsetX(offX, minOffX, lag, interScale);
     }
 
-    private float getMapOffsetY(TileMap map, Player player, Renderer r, float lag, float interScale)
-    {
+    private float getMapOffsetY(TileMap map, Player player, Renderer r, float lag, float interScale) {
         float viewHeight = r.getViewHeight() - HUDRenderer.OFFSET_Y;
         float iy = (player.getLastY() + (player.getY() - player.getLastY()) * lag) * interScale * TileRenderer.TILE_SIZE;
         float offY = (-iy + viewHeight * 0.5f) - TileRenderer.TILE_SIZE * 0.5f * interScale;
 
         float minOffY = -mapRenderer.getHeight(map) + viewHeight;
-        if(offY < minOffY)
-        {
+        if(offY < minOffY) {
             return cam.getCamOffsetY(minOffY, minOffY, lag, interScale);
-        }
-        else if(offY > 0.0f)
-        {
+        } else if(offY > 0.0f) {
             return cam.getCamOffsetY(0.0f, minOffY, lag, interScale);
         }
         return cam.getCamOffsetY(offY, minOffY, lag, interScale);

+ 21 - 39
src/pathgame/rendering/MenuRenderer.java

@@ -11,20 +11,18 @@ import pathgame.gameplay.menu.MenuButton;
  *
  * @author julia
  */
-public class MenuRenderer
-{
+public class MenuRenderer {
     private final float keyWidths[] = new float[Keys.KEYS.length];
 
-        /**
-     * Recalculates the rendering positions and settings of the menu-elements on
-     * the screen every rendertick based on the gamelogic in the gametick
+    /**
+     * Recalculates the rendering positions and settings of the menu-elements on the screen every rendertick based on
+     * the gamelogic in the gametick
      *
      * @param r the renderer
      * @param lag the current lag
      * @param menu the current menu
      */
-    public void renderTick(Renderer r, float lag, Menu menu)
-    {
+    public void renderTick(Renderer r, float lag, Menu menu) {
         r.translateTo(0.0f, 0.0f);
         float scale = 2.0f;
         r.scale(scale, scale);
@@ -52,30 +50,23 @@ public class MenuRenderer
 
         r.setTextureEnabled(true);
 
-        if(!menu.isOptionMenu())
-        {
-            for(int i = 0; i < options.length - 1; i++)
-            {
+        if(!menu.isOptionMenu()) {
+            for(int i = 0; i < options.length - 1; i++) {
                 renderText(options[i].getName(), menu.getActiveIndex() == i, r, windowWidth, y, false);
                 y += step;
             }
             y += lastGap;
             renderText(options[options.length - 1].getName(), menu.getActiveIndex() == options.length - 1, r, windowWidth, y, false);
-        }
-        else
-        {
+        } else {
             float max = Float.MIN_VALUE;
-            for(int i = 0; i < Keys.KEYS.length; i++)
-            {
+            for(int i = 0; i < Keys.KEYS.length; i++) {
                 keyWidths[i] = r.getFontRenderer().getSize(getKeyName(Keys.KEYS[i])).getWidth();
-                if(keyWidths[i] > max)
-                {
+                if(keyWidths[i] > max) {
                     max = keyWidths[i];
                 }
             }
 
-            for(int i = 0; i < options.length - 1; i++)
-            {
+            for(int i = 0; i < options.length - 1; i++) {
                 boolean active = menu.getActiveIndex() == i;
                 renderText(options[i].getName(), active, r, windowWidth, y, true);
                 r.getFontRenderer().drawString(windowWidth * 0.85f - max * 0.5f - keyWidths[i] * 0.5f, y, addColor(getKeyName(Keys.KEYS[i]), active));
@@ -86,32 +77,23 @@ public class MenuRenderer
         }
     }
 
-    private void renderText(String s, boolean active, Renderer r, float wWidth, float y, boolean left)
-    {
-        if(left)
-        {
+    private void renderText(String s, boolean active, Renderer r, float wWidth, float y, boolean left) {
+        if(left) {
             r.getFontRenderer().drawString(wWidth * 0.15f, y, addColor(s, active));
-        }
-        else
-        {
+        } else {
             r.getFontRenderer().drawString(wWidth * 0.5f - (r.getFontRenderer().getSize(s).getWidth() * 0.5f), y, addColor(s, active));
         }
     }
-    
-    private String addColor(String s, boolean active)
-    {
+
+    private String addColor(String s, boolean active) {
         return (active ? "&f" : "&7") + s;
     }
-    
-    private String getKeyName(KeyBinding key)
-    {
-        if(key.isRebinding())
-        {
+
+    private String getKeyName(KeyBinding key) {
+        if(key.isRebinding()) {
             return "[...]";
-        }
-        else
-        {
+        } else {
             return key.getName();
         }
     }
-}
+}

+ 22 - 51
src/pathgame/rendering/PlayerRenderer.java

@@ -2,7 +2,6 @@ package pathgame.rendering;
 
 import me.hammerle.snuviengine.api.Renderer;
 import me.hammerle.snuviengine.api.Texture;
-import pathgame.gameplay.Facing;
 import pathgame.gameplay.Player;
 import pathgame.gameplay.PlayerAbilities;
 import pathgame.tilemap.TileMap;
@@ -13,8 +12,7 @@ import pathgame.tilemap.TileRenderType;
  *
  * @author julia
  */
-public class PlayerRenderer
-{
+public class PlayerRenderer {
     private static final Texture CHARACTER = new Texture("resources/character.png");
     private static final Texture CHARACTER_HIKER = new Texture("resources/hiker.png");
     private static final Texture CHARACTER_HUNTER = new Texture("resources/hunter.png");
@@ -22,8 +20,8 @@ public class PlayerRenderer
     private static final Texture CHARACTER_SWIMMER = new Texture("resources/swimmer.png");
 
     /**
-     * Recalculates the rendering positions and settings of the menu-elements on
-     * the screen every rendertick based on the gamelogic in the gametick
+     * Recalculates the rendering positions and settings of the menu-elements on the screen every rendertick based on
+     * the gamelogic in the gametick
      *
      * @param map the current map
      * @param mapR the map renderer
@@ -33,8 +31,7 @@ public class PlayerRenderer
      * @param offX the current x-offset of the map
      * @param offY the current y-offset of the map
      */
-    public void renderTick(TileMap map, TileMapRenderer mapR, Renderer r, Player p, float lag, float offX, float offY)
-    {
+    public void renderTick(TileMap map, TileMapRenderer mapR, Renderer r, Player p, float lag, float offX, float offY) {
         boolean inWater = p.getCurrTile().getRenderType() == TileRenderType.WATER;
         float playerSize = mapR.getScale() * TileRenderer.TILE_SIZE;
 
@@ -60,48 +57,35 @@ public class PlayerRenderer
         float yTexOff = 0;
 
         bindTexture(p, inWater);
-        
-        if(p.getVelX() > 0)
-        {
+
+        if(p.getVelX() > 0) {
             //go right
             yIndex = 2;
             tIndex = checkForAnimationIndex(baseX);
-        }
-        else if(p.getVelX() < 0)
-        {
+        } else if(p.getVelX() < 0) {
             //go left
             yIndex = 1;
             tIndex = checkForAnimationIndex(baseX);
-        }
-        else if(p.getVelY() > 0)
-        {
+        } else if(p.getVelY() > 0) {
             //go down
             yIndex = 0;
             tIndex = checkForAnimationIndex(baseY);
-        }
-        else if(p.getVelY() < 0)
-        {
+        } else if(p.getVelY() < 0) {
             //go up
             yIndex = 3;
             tIndex = checkForAnimationIndex(baseY);
-        }
-        else
-        {
+        } else {
             //stand still
             yIndex = p.getFacing().getIndex();
             // idle animation on water
-            if(inWater && (p.getTicksLived() % 20) < 10)
-            {
+            if(inWater && (p.getTicksLived() % 20) < 10) {
                 tIndex = 1;
             }
         }
 
-        if(p.isSailing())
-        {
+        if(p.isSailing()) {
             yTexOff = 0.5f;
-        }
-        else if(inWater)
-        {
+        } else if(inWater) {
             xTexOff = 0.5f;
         }
 
@@ -114,35 +98,22 @@ public class PlayerRenderer
                 (tIndex + 1) * 0.125f + xTexOff, yIndex * 0.125f + 0.125f + yTexOff);
     }
 
-    private int checkForAnimationIndex(float base)
-    {
+    private int checkForAnimationIndex(float base) {
         return ((int) (base * 4 * 2)) % 4;
     }
-    
-    private void bindTexture(Player p, boolean inWater)
-    {
-        if(p.isSailing() || inWater || p.getAbilities() == PlayerAbilities.NORMAL)
-        {
+
+    private void bindTexture(Player p, boolean inWater) {
+        if(p.isSailing() || inWater || p.getAbilities() == PlayerAbilities.NORMAL) {
             CHARACTER.bind();
-        }
-        else if(p.getAbilities() == PlayerAbilities.HIKER)
-        {
+        } else if(p.getAbilities() == PlayerAbilities.HIKER) {
             CHARACTER_HIKER.bind();
-        }
-        else if(p.getAbilities() == PlayerAbilities.HUNTER)
-        {
+        } else if(p.getAbilities() == PlayerAbilities.HUNTER) {
             CHARACTER_HUNTER.bind();
-        }
-        else if(p.getAbilities() == PlayerAbilities.SAILOR)
-        {
+        } else if(p.getAbilities() == PlayerAbilities.SAILOR) {
             CHARACTER_SAILOR.bind();
-        }
-        else if(p.getAbilities() == PlayerAbilities.SWIMMER)
-        {
+        } else if(p.getAbilities() == PlayerAbilities.SWIMMER) {
             CHARACTER_SWIMMER.bind();
-        }
-        else
-        {
+        } else {
             CHARACTER.bind();
         }
     }

+ 18 - 37
src/pathgame/rendering/ScoreMenuRenderer.java

@@ -9,18 +9,16 @@ import pathgame.gameplay.Player;
  *
  * @author julia
  */
-public class ScoreMenuRenderer
-{
+public class ScoreMenuRenderer {
     /**
-     * Recalculates the rendering positions and settings of the menu-elements on
-     * the screen every rendertick based on the gamelogic in the gametick
+     * Recalculates the rendering positions and settings of the menu-elements on the screen every rendertick based on
+     * the gamelogic in the gametick
      *
      * @param r the renderer
      * @param lag the current lag
      * @param level the current level containing the player and the map
      */
-    public void renderTick(Renderer r, float lag, Level level)
-    {
+    public void renderTick(Renderer r, float lag, Level level) {
         float windowWidth = r.getViewWidth();
         float windowHeight = r.getViewHeight();
         float paddingX = 30;
@@ -37,7 +35,7 @@ public class ScoreMenuRenderer
 
         Player p = level.getPlayer();
         String message = String.format("&2%d&f of &2%d&f Energy used",
-        p.getEnergyUsed(), p.getEnergySupply());
+                p.getEnergyUsed(), p.getEnergySupply());
 
         r.getFontRenderer().drawString((windowWidth * scale - getWidth(r, message)) / 2, (windowHeight * scale - getHeight(r, message)) / 2 - windowHeight * scale * 0.5f * 0.15f, message);
 
@@ -46,12 +44,9 @@ public class ScoreMenuRenderer
         r.getFontRenderer().drawString((windowWidth * scale - getWidth(r, message)) / 2, (windowHeight * scale - getHeight(r, message)) / 2 - windowHeight * scale * 0.5f * (-0.15f), message);
 
         scale = scale(r, 2);
-        if(p.hasLost())
-        {
+        if(p.hasLost()) {
             message = "What a pity! Out of energy!";
-        }
-        else
-        {
+        } else {
             message = "Congratulations!";
         }
         r.getFontRenderer().drawString((windowWidth * scale - getWidth(r, message)) / 2, (windowHeight * scale - getHeight(r, message)) / 2, message);
@@ -61,48 +56,34 @@ public class ScoreMenuRenderer
 
     }
 
-    private float getWidth(Renderer r, String s)
-    {
+    private float getWidth(Renderer r, String s) {
         return r.getFontRenderer().getSize(s).getWidth();
     }
 
-    private float getHeight(Renderer r, String s)
-    {
+    private float getHeight(Renderer r, String s) {
         return r.getFontRenderer().getSize(s).getHeight();
     }
 
-    private float scale(Renderer r, int scale)
-    {
+    private float scale(Renderer r, int scale) {
         r.scale(scale, scale);
         r.updateMatrix();
         return 1.0f / scale;
     }
-    
-    private String getMessage(int playerEnergy, int algorithmEnergy, int maxEnergy)
-    {
-        if(playerEnergy == algorithmEnergy)
-        {
+
+    private String getMessage(int playerEnergy, int algorithmEnergy, int maxEnergy) {
+        if(playerEnergy == algorithmEnergy) {
             return "As good as the algorithm!";
         }
         float energyPercent = ((float) playerEnergy / maxEnergy) * Level.ALGORITHM_4;
-        if(energyPercent < Level.ALGORITHM_1)
-        {
+        if(energyPercent < Level.ALGORITHM_1) {
             return "Better than the algorithm!";
-        }
-        else if(energyPercent < Level.ALGORITHM_2)
-        {
+        } else if(energyPercent < Level.ALGORITHM_2) {
             return "0-10% over the algorithm!";
-        }
-        else if(energyPercent < Level.ALGORITHM_3)
-        {
+        } else if(energyPercent < Level.ALGORITHM_3) {
             return "10-20% over the algorithm!";
-        }
-        else if(energyPercent < Level.ALGORITHM_4)
-        {
+        } else if(energyPercent < Level.ALGORITHM_4) {
             return "20-30% over the algorithm!";
-        }
-        else
-        {
+        } else {
             return "30% over the algorithm!";
         }
     }

+ 10 - 11
src/pathgame/rendering/StaticTextureProvider.java

@@ -3,27 +3,26 @@ package pathgame.rendering;
 import pathgame.tilemap.Tile;
 import pathgame.tilemap.TileMap;
 
-/** A static {@link  pathgame.rendering.TileTextureProvider TileTextureProvider},
- * which always returns the same {@link  pathgame.rendering.TileTexture TileTexture}.
+/**
+ * A static {@link  pathgame.rendering.TileTextureProvider TileTextureProvider}, which always returns the same
+ * {@link  pathgame.rendering.TileTexture TileTexture}.
  *
  * @author kajetan
  */
-public class StaticTextureProvider implements TileTextureProvider
-{
+public class StaticTextureProvider implements TileTextureProvider {
     private final TileTexture tt;
-    
-    /** Creates a new static texture provider.
+
+    /**
+     * Creates a new static texture provider.
      *
      * @param tt a tile texture
      */
-    public StaticTextureProvider(TileTexture tt)
-    {
+    public StaticTextureProvider(TileTexture tt) {
         this.tt = tt;
     }
-    
+
     @Override
-    public TileTexture getTexture(TileMap map, Tile t, int x, int y)
-    {
+    public TileTexture getTexture(TileMap map, Tile t, int x, int y) {
         return tt;
     }
 }

+ 47 - 89
src/pathgame/rendering/TileMapRenderer.java

@@ -16,9 +16,7 @@ import pathgame.tilemap.TileType;
  *
  * @author kajetan
  */
-public class TileMapRenderer
-{
-
+public class TileMapRenderer {
     // prevents rendering artifacts especially on different zoom levels
     private final static float ERROR = 1.0f / 512.0F;
     private final static float T_ERROR = 1.0f / 4096.0F;
@@ -30,31 +28,27 @@ public class TileMapRenderer
     private final TextureRenderer swampWaterOverlayRenderer = new TextureRenderer(20 * 20 * 2); // default to 20x20 map
     private final TextureRenderer grassOverlayRenderer = new TextureRenderer(20 * 20 * 2); // default to 20x20 map
     private float scale = 1.0f;
-    
-    private final static String[] OVERLAY = new String[]
-    {
+
+    private final static String[] OVERLAY = new String[]{
         "&a1", "&a2", "&a3", "&e4", "&e5", "&66", "&67", "&68", "&c9"
     };
-    
-    private static String[] getWavePath()
-    {
+
+    private static String[] getWavePath() {
         String[] path = new String[60];
-        for(int i = 0; i < path.length; i++)
-        {
+        for(int i = 0; i < path.length; i++) {
             path[i] = "resources/waves/wave" + (i + 1) + ".png";
         }
         return path;
     }
-    
+
     private final Texture.Animation waves = tileTexture.addAnimation((int) (8 * TileRenderer.TILE_SIZE), (int) (2 * TileRenderer.TILE_SIZE), getWavePath());
     private int counter = 0;
-    
+
     /**
      * Creates a new tile map renderer.
      *
      */
-    public TileMapRenderer()
-    {
+    public TileMapRenderer() {
     }
 
     /**
@@ -62,8 +56,7 @@ public class TileMapRenderer
      *
      * @param scale the scale of the map
      */
-    public void setScale(float scale)
-    {
+    public void setScale(float scale) {
         this.scale = scale;
     }
 
@@ -72,8 +65,7 @@ public class TileMapRenderer
      *
      * @return the scale of the map
      */
-    public float getScale()
-    {
+    public float getScale() {
         return scale;
     }
 
@@ -83,8 +75,7 @@ public class TileMapRenderer
      * @param map a map
      * @return the scaled render width of a map
      */
-    public float getWidth(TileMap map)
-    {
+    public float getWidth(TileMap map) {
         return map.getWidth() * TileRenderer.TILE_SIZE * scale;
     }
 
@@ -94,18 +85,15 @@ public class TileMapRenderer
      * @param map a map
      * @return the scaled render height of a map
      */
-    public float getHeight(TileMap map)
-    {
+    public float getHeight(TileMap map) {
         return map.getHeight() * TileRenderer.TILE_SIZE * scale;
     }
 
-    private float toTexture(int x)
-    {
+    private float toTexture(int x) {
         return x * TileRenderer.TILE_SIZE / TileTexture.TEXTURE_SIZE;
     }
 
-    private void addTile(TextureRenderer tr, int x, int y, float tMinX, float tMinY, float tMaxX, float tMaxY)
-    {
+    private void addTile(TextureRenderer tr, int x, int y, float tMinX, float tMinY, float tMaxX, float tMaxY) {
         tr.addRectangle(
                 x * TileRenderer.TILE_SIZE - ERROR, y * TileRenderer.TILE_SIZE - ERROR,
                 (x + 1) * TileRenderer.TILE_SIZE + ERROR, (y + 1) * TileRenderer.TILE_SIZE + ERROR,
@@ -113,38 +101,31 @@ public class TileMapRenderer
                 tMaxX - T_ERROR, tMaxY - T_ERROR);
     }
 
-    private void addTileOverlay(TextureRenderer tr, int x, int y, int ox, int oy)
-    {
+    private void addTileOverlay(TextureRenderer tr, int x, int y, int ox, int oy) {
         addTile(tr, x, y, toTexture(ox), toTexture(oy), toTexture(ox + 1), toTexture(oy + 1));
     }
 
-    private boolean isInRange(TileMap map, int x, int y)
-    {
+    private boolean isInRange(TileMap map, int x, int y) {
         return x >= 0 && y >= 0 && x < map.getWidth() && y < map.getHeight();
     }
-    
-    private boolean isShallowWater(TileMap map, int x, int y)
-    {
+
+    private boolean isShallowWater(TileMap map, int x, int y) {
         return isInRange(map, x, y) && map.getTile(x, y).getType() == TileType.SHALLOW_WATER;
     }
 
-    private boolean isSwamp(TileMap map, int x, int y)
-    {
+    private boolean isSwamp(TileMap map, int x, int y) {
         return isInRange(map, x, y) && map.getTile(x, y).getRenderType() == TileRenderType.SWAMP;
     }
 
-    private boolean isSwampOrWaterOrBorder(TileMap map, int x, int y)
-    {
-        if(!isInRange(map, x, y))
-        {
+    private boolean isSwampOrWaterOrBorder(TileMap map, int x, int y) {
+        if(!isInRange(map, x, y)) {
             return true;
         }
         TileRenderType type = map.getTile(x, y).getRenderType();
         return type == TileRenderType.SWAMP || type == TileRenderType.WATER;
     }
 
-    private void addWaterSwampOverlay(TileMap map, int x, int y)
-    {
+    private void addWaterSwampOverlay(TileMap map, int x, int y) {
         boolean n = isSwamp(map, x, y - 1);
         boolean e = isSwamp(map, x + 1, y);
         boolean s = isSwamp(map, x, y + 1);
@@ -172,15 +153,13 @@ public class TileMapRenderer
         index += e ? 0 : 4;
         index += s ? 0 : 2;
         index += w ? 0 : 1;
-        if(index == 15)
-        {
+        if(index == 15) {
             return;
         }
         addTileOverlay(swampWaterOverlayRenderer, x, y, index, 15);
     }
-    
-    private void addDeepWaterOverlay(TileMap map, int x, int y)
-    {
+
+    private void addDeepWaterOverlay(TileMap map, int x, int y) {
         boolean n = isShallowWater(map, x, y - 1);
         boolean e = isShallowWater(map, x + 1, y);
         boolean s = isShallowWater(map, x, y + 1);
@@ -208,15 +187,13 @@ public class TileMapRenderer
         index += e ? 0 : 4;
         index += s ? 0 : 2;
         index += w ? 0 : 1;
-        if(index == 15)
-        {
+        if(index == 15) {
             return;
         }
         addTileOverlay(waterOverlayRenderer, x, y, index, 12);
     }
 
-    private void addGrassOverlay(TileMap map, int x, int y)
-    {
+    private void addGrassOverlay(TileMap map, int x, int y) {
         boolean n = isSwampOrWaterOrBorder(map, x, y - 1);
         boolean e = isSwampOrWaterOrBorder(map, x + 1, y);
         boolean s = isSwampOrWaterOrBorder(map, x, y + 1);
@@ -244,43 +221,34 @@ public class TileMapRenderer
         index += !e ? 0 : 4;
         index += !s ? 0 : 2;
         index += !w ? 0 : 1;
-        if(index == 15)
-        {
+        if(index == 15) {
             return;
         }
 
         addTileOverlay(grassOverlayRenderer, x, y, index, 14);
     }
 
-    private void updateData(TileMap map)
-    {
+    private void updateData(TileMap map) {
         textureRenderer.clear();
         waterOverlayRenderer.clear();
         waveRenderer.clear();
-        swampWaterOverlayRenderer.clear();    
+        swampWaterOverlayRenderer.clear();
         grassOverlayRenderer.clear();
-        for(int x = 0; x < map.getWidth(); x++)
-        {
-            for(int y = 0; y < map.getHeight(); y++)
-            {
+        for(int x = 0; x < map.getWidth(); x++) {
+            for(int y = 0; y < map.getHeight(); y++) {
                 Tile t = map.getTile(x, y);
                 TileTexture tt = TileRenderer.getTileTexture(map, t, x, y);
-                if(tt == null)
-                {
+                if(tt == null) {
                     continue;
                 }
-                if(t.getRenderType() == TileRenderType.WATER)
-                {
-                    if(t.getType() == TileType.DEEP_WATER)
-                    {
+                if(t.getRenderType() == TileRenderType.WATER) {
+                    if(t.getType() == TileType.DEEP_WATER) {
                         addDeepWaterOverlay(map, x, y);
                     }
                     addWaterSwampOverlay(map, x, y);
                     addGrassOverlay(map, x, y);
                     addTileOverlay(waveRenderer, x, y, 8, 2);
-                }
-                else if(t.getRenderType() == TileRenderType.SWAMP)
-                {
+                } else if(t.getRenderType() == TileRenderType.SWAMP) {
                     addGrassOverlay(map, x, y);
                 }
                 addTile(textureRenderer, x, y, tt.getMinX(), tt.getMinY(), tt.getMaxX(), tt.getMaxY());
@@ -297,12 +265,10 @@ public class TileMapRenderer
      * Ticks the renderer. Used for animated tiles.
      *
      */
-    public void tick()
-    {
+    public void tick() {
         // tick tile animations here
         counter++;
-        if(counter >= 1)
-        {
+        if(counter >= 1) {
             tileTexture.bind();
             waves.nextFrame();
             counter = 0;
@@ -318,16 +284,14 @@ public class TileMapRenderer
      * @param offX the x coordinate of the offset
      * @param offY the y coordinate of the offset
      */
-    public void renderTick(TileMap map, Renderer r, Player p, boolean forceUpdate, float offX, float offY)
-    {
+    public void renderTick(TileMap map, Renderer r, Player p, boolean forceUpdate, float offX, float offY) {
         r.setTextureEnabled(true);
         r.setColorEnabled(false);
         r.setMixColorEnabled(false);
 
         tileTexture.bind();
 
-        if(forceUpdate || map.isDirty())
-        {
+        if(forceUpdate || map.isDirty()) {
             updateData(map);
             map.clean();
         }
@@ -345,8 +309,7 @@ public class TileMapRenderer
         swampWaterOverlayRenderer.draw();
         grassOverlayRenderer.draw();
 
-        if(Keys.OVERLAY_KEY.isDown())
-        {
+        if(Keys.OVERLAY_KEY.isDown()) {
             r.translateTo(0.0f, 0.0f);
             r.updateMatrix();
             r.setTextureEnabled(false);
@@ -362,19 +325,14 @@ public class TileMapRenderer
 
             float midX = (TileRenderer.TILE_SIZE - fr.getWidth() * 2) * 0.5f * 0.5f;
             float midY = (TileRenderer.TILE_SIZE - (fr.getHeight() - 1) * 2) * 0.5f * 0.5f;
-            for(int x = 0; x < map.getWidth(); x++)
-            {
-                for(int y = 0; y < map.getHeight(); y++)
-                {
+            for(int x = 0; x < map.getWidth(); x++) {
+                for(int y = 0; y < map.getHeight(); y++) {
                     Tile t = map.getTile(x, y);
                     float tx = midX + TileRenderer.TILE_SIZE * x * 0.5f;
-                    float ty =  midY + TileRenderer.TILE_SIZE * y * 0.5f;
-                    if(t.isBlockingMovement(p))
-                    {
+                    float ty = midY + TileRenderer.TILE_SIZE * y * 0.5f;
+                    if(t.isBlockingMovement(p)) {
                         fr.drawString(tx, ty, true, "&4-");
-                    }
-                    else
-                    {
+                    } else {
                         fr.drawString(tx, ty, true, OVERLAY[map.getTile(x, y).getEnergyCost(p) - 1]);
                     }
                 }

+ 19 - 22
src/pathgame/rendering/TileRenderer.java

@@ -4,30 +4,29 @@ import pathgame.tilemap.Tile;
 import pathgame.tilemap.TileMap;
 import pathgame.tilemap.Tiles;
 
-/** Registry for rendering all possible tiles.
+/**
+ * Registry for rendering all possible tiles.
  *
  * @author kajetan
  */
-public class TileRenderer
-{
-    /** The unscaled render size of a map tile. */
+public class TileRenderer {
+    /**
+     * The unscaled render size of a map tile.
+     */
     public final static float TILE_SIZE = 32;
-    
+
     private static TileTextureProvider[] tProviders = new TileTextureProvider[8];
-    
-    private static void register(Tile t, TileTextureProvider provider)
-    {
-        if(t.getId() >= tProviders.length)
-        {
+
+    private static void register(Tile t, TileTextureProvider provider) {
+        if(t.getId() >= tProviders.length) {
             TileTextureProvider[] newTProviders = new TileTextureProvider[tProviders.length * 2];
             System.arraycopy(tProviders, 0, newTProviders, 0, tProviders.length);
             tProviders = newTProviders;
         }
         tProviders[t.getId()] = provider;
     }
-    
-    static
-    {
+
+    static {
         register(Tiles.GRASS, new StaticTextureProvider(TileTexture.fromTextureId(0)));
         register(Tiles.GRASS_WITH_STONE, new StaticTextureProvider(TileTexture.fromTextureId(1)));
         register(Tiles.GRASS_WITH_6_BUSHES, new StaticTextureProvider(TileTexture.fromTextureId(2)));
@@ -54,7 +53,7 @@ public class TileRenderer
         register(Tiles.TOWN_BLOCKED_4, new StaticTextureProvider(TileTexture.fromTextureId(20)));
         register(Tiles.PORT, new StaticTextureProvider(TileTexture.fromTextureId(15)));
         register(Tiles.HOME_TOWN, new StaticTextureProvider(TileTexture.fromTextureId(39)));
-        
+
         register(Tiles.PATH_N, new StaticTextureProvider(TileTexture.fromTextureId(24)));
         register(Tiles.PATH_E, new StaticTextureProvider(TileTexture.fromTextureId(25)));
         register(Tiles.PATH_S, new StaticTextureProvider(TileTexture.fromTextureId(26)));
@@ -71,8 +70,9 @@ public class TileRenderer
         register(Tiles.PATH_E_S_W, new StaticTextureProvider(TileTexture.fromTextureId(37)));
         register(Tiles.PATH_N_E_S_W, new StaticTextureProvider(TileTexture.fromTextureId(38)));
     }
-    
-    /** Returns a tile texture of a given map tile.
+
+    /**
+     * Returns a tile texture of a given map tile.
      *
      * @param map a map
      * @param t a tile
@@ -80,15 +80,12 @@ public class TileRenderer
      * @param y the y coordinate of the given tile
      * @return a tile texture of a given map tile
      */
-    public static TileTexture getTileTexture(TileMap map, Tile t, int x, int y)
-    {
-        if(t == null)
-        {
+    public static TileTexture getTileTexture(TileMap map, Tile t, int x, int y) {
+        if(t == null) {
             return null;
         }
         int id = t.getId();
-        if(id < 0 || id >= tProviders.length || tProviders[id] == null)
-        {
+        if(id < 0 || id >= tProviders.length || tProviders[id] == null) {
             return null;
         }
         return tProviders[id].getTexture(map, t, x, y);

+ 27 - 27
src/pathgame/rendering/TileTexture.java

@@ -1,82 +1,82 @@
 package pathgame.rendering;
 
-/** A container for tile texture coordinates.
+/**
+ * A container for tile texture coordinates.
  *
  * @author kajetan
  */
-public class TileTexture
-{
+public class TileTexture {
     public final static float TEXTURE_SIZE = 512;
     private final static float TILE_TEXTURE_PERCENT = TileRenderer.TILE_SIZE / TEXTURE_SIZE;
     private final static int TILES_PER_LINE = (int) (TEXTURE_SIZE / TileRenderer.TILE_SIZE);
-    
-    /** Returns a tile texture constructed from a given texture id.
+
+    /**
+     * Returns a tile texture constructed from a given texture id.
      *
      * @param textureId a texture id
      * @return a tile texture constructed from a given texture id
      */
-    public static TileTexture fromTextureId(int textureId)
-    {
+    public static TileTexture fromTextureId(int textureId) {
         float tMinX = (textureId % TILES_PER_LINE) * TILE_TEXTURE_PERCENT;
-        float tMinY = (textureId/ TILES_PER_LINE) * TILE_TEXTURE_PERCENT;
+        float tMinY = (textureId / TILES_PER_LINE) * TILE_TEXTURE_PERCENT;
         float tMaxX = tMinX + TILE_TEXTURE_PERCENT;
         float tMaxY = tMinY + TILE_TEXTURE_PERCENT;
         return new TileTexture(tMinX, tMinY, tMaxX, tMaxY);
     }
-    
+
     private final float tMinX;
     private final float tMinY;
     private final float tMaxX;
     private final float tMaxY;
-    
-    /** Creates a new tile texture.
+
+    /**
+     * Creates a new tile texture.
      *
      * @param tMinX the left x coordinate in the texture atlas
      * @param tMinY the upper y coordinate in the texture atlas
      * @param tMaxX the right x coordinate in the texture atlas
      * @param tMaxY the lower y coordinate in the texture atlas
      */
-    public TileTexture(float tMinX, float tMinY, float tMaxX, float tMaxY)
-    {     
+    public TileTexture(float tMinX, float tMinY, float tMaxX, float tMaxY) {
         this.tMinX = tMinX;
         this.tMinY = tMinY;
         this.tMaxX = tMaxX;
         this.tMaxY = tMaxY;
     }
 
-    /** Returns the the left x coordinate in the texture atlas.
+    /**
+     * Returns the the left x coordinate in the texture atlas.
      *
      * @return the left x coordinate in the texture atlas
      */
-    public float getMinX()
-    {
+    public float getMinX() {
         return tMinX;
     }
 
-    /** Returns the upper y coordinate in the texture atlas.
+    /**
+     * Returns the upper y coordinate in the texture atlas.
      *
      * @return the upper y coordinate in the texture atlas
      */
-    public float getMinY()
-    {
+    public float getMinY() {
         return tMinY;
     }
-             
-    /** Returns the right x coordinate in the texture atlas.
+
+    /**
+     * Returns the right x coordinate in the texture atlas.
      *
      * @return the right x coordinate in the texture atlas
      */
-    public float getMaxX()
-    {
+    public float getMaxX() {
         return tMaxX;
     }
 
-    /** Returns the lower y coordinate in the texture atlas.
+    /**
+     * Returns the lower y coordinate in the texture atlas.
      *
      * @return the lower y coordinate in the texture atlas
      */
-    public float getMaxY()
-    {
+    public float getMaxY() {
         return tMaxY;
     }
-}
+}

+ 5 - 4
src/pathgame/rendering/TileTextureProvider.java

@@ -3,14 +3,15 @@ package pathgame.rendering;
 import pathgame.tilemap.Tile;
 import pathgame.tilemap.TileMap;
 
-/** Represents an operation that accepts tile map data and returns a tile texture.
+/**
+ * Represents an operation that accepts tile map data and returns a tile texture.
  *
  * @author kajetan
  */
 @FunctionalInterface
-public interface TileTextureProvider
-{
-    /** Returns a tile texture corresponding to the given tile at the given position.
+public interface TileTextureProvider {
+    /**
+     * Returns a tile texture corresponding to the given tile at the given position.
      *
      * @param map a map
      * @param t a tile

+ 36 - 49
src/pathgame/tilemap/HighMap.java

@@ -2,71 +2,66 @@ package pathgame.tilemap;
 
 import java.util.Random;
 
-/** Class for generating two dimensional highmaps of arbitrary size.
+/**
+ * Class for generating two dimensional highmaps of arbitrary size.
  *
  * @author kajetan
  */
-public class HighMap
-{
+public class HighMap {
     private static final float LOW_FREQUENCY = 8.0f;
     private static final float HIGH_FREQUENCY = 7.0f;
-    
-    /** Returns a generated highmap.
+
+    /**
+     * Returns a generated highmap.
      *
      * @param seed the seed for the highmap
      * @param width the width of the highmap
      * @param height the height of the highmap
      * @return a generated highmap
      */
-    public static HighMap generate(long seed, int width, int height)
-    {
+    public static HighMap generate(long seed, int width, int height) {
         HighMap map = new HighMap(seed, width, height);
         map.zoom();
         return map;
     }
-    
+
     private final int width;
     private final int height;
     private final float data[][];
     private final Random r;
-    
-    private HighMap(long seed, int width, int height)
-    {
+
+    private HighMap(long seed, int width, int height) {
         r = new Random(seed);
         this.width = width;
         this.height = height;
         this.data = new float[width][height];
     }
-    
-    /** Returns the value at the given position.
+
+    /**
+     * Returns the value at the given position.
      *
      * @param x the x coordinate of a position
      * @param y the y coordinate of a position
      * @return the value at the given position
      */
-    public float get(int x, int y)
-    {
+    public float get(int x, int y) {
         return data[x][y];
     }
-    
-    private float[][] randomizeBase()
-    {
+
+    private float[][] randomizeBase() {
         // +1 for neighbours
-        int w = (int) Math.ceil(width / HIGH_FREQUENCY) + 1; 
+        int w = (int) Math.ceil(width / HIGH_FREQUENCY) + 1;
         int h = (int) Math.ceil(height / HIGH_FREQUENCY) + 1;
         float[][] base = new float[w][h];
-        for(int x = 0; x < w; x++)
-        {
-            for(int y = 0; y < h; y++)
-            {
+        for(int x = 0; x < w; x++) {
+            for(int y = 0; y < h; y++) {
                 base[x][y] = r.nextFloat();
             }
         }
         return base;
     }
-    
-    private float smooth(float[][] base, float x1, float y1)
-    {
+
+    private float smooth(float[][] base, float x1, float y1) {
         // distance to next exact pixel
         float fractX = x1 - (int) x1;
         float fractY = y1 - (int) y1;
@@ -74,7 +69,7 @@ public class HighMap
         // neighbour pixel coords
         int x2 = ((int) x1 + 1) % width;
         int y2 = ((int) y1 + 1) % height;
-        
+
         // interpolate over all 4 pixels, strength varies with distance
         float value = 0.0f;
         value += (1 - fractX) * (1 - fractY) * base[(int) x1][(int) y1];
@@ -83,45 +78,37 @@ public class HighMap
         value += fractX * fractY * base[(int) x2][(int) y2];
         return value;
     }
-    
-    private float turbulence(float[][] base, float x1, float y1)
-    {
+
+    private float turbulence(float[][] base, float x1, float y1) {
         float sum = 0.0f;
         sum += smooth(base, x1 / LOW_FREQUENCY, y1 / LOW_FREQUENCY) * LOW_FREQUENCY;
         sum += smooth(base, x1 / HIGH_FREQUENCY, y1 / HIGH_FREQUENCY) * HIGH_FREQUENCY;
         return sum;
     }
-    
-    private void zoom()
-    {
+
+    private void zoom() {
         float[][] base = randomizeBase();
-        
+
         float min = Float.MAX_VALUE;
         float max = Float.MIN_VALUE;
-        
-        for(int x = 0; x < width; x++)
-        {
-            for(int y = 0; y < height; y++)
-            {
+
+        for(int x = 0; x < width; x++) {
+            for(int y = 0; y < height; y++) {
                 float f = turbulence(base, x, y);
                 data[x][y] = f;
-                if(f < min)
-                {
+                if(f < min) {
                     min = f;
                 }
-                if(f > max)
-                {
+                if(f > max) {
                     max = f;
                 }
             }
         }
-        
+
         float f = 1.0f / (max - min);
-        for(int x = 0; x < width; x++)
-        {
-            for(int y = 0; y < height; y++)
-            {
-                data[x][y] = (data[x][y] - min) * f; 
+        for(int x = 0; x < width; x++) {
+            for(int y = 0; y < height; y++) {
+                data[x][y] = (data[x][y] - min) * f;
             }
         }
     }

+ 108 - 113
src/pathgame/tilemap/Tile.java

@@ -3,18 +3,18 @@ package pathgame.tilemap;
 import java.util.function.Function;
 import pathgame.gameplay.Player;
 
-/** Base class for tiles. Tiles are registered on construction.
+/**
+ * Base class for tiles. Tiles are registered on construction.
  *
  * @author kajetan
  */
-public class Tile
-{
+public class Tile {
 
-    /** A builder for tiles.
+    /**
+     * A builder for tiles.
      *
      */
-    public static class TileBuilder
-    {
+    public static class TileBuilder {
         private int energyCost = 2;
         private float forestReplaceChance = 1.0f;
         private Function<Player, Integer> speedUp = (p) -> 0;
@@ -24,132 +24,129 @@ public class Tile
         private boolean canHostPath = false;
         private boolean path = false;
         private TileRenderType renderType = TileRenderType.NORMAL;
-        
-        private TileBuilder()
-        {
+
+        private TileBuilder() {
         }
-        
-        /** Returns a new tile builder;
+
+        /**
+         * Returns a new tile builder;
          *
          * @return a new tile builder
          */
-        public static TileBuilder create()
-        {
+        public static TileBuilder create() {
             return new TileBuilder();
         }
 
-        /** Sets the base energy cost of the tile.
+        /**
+         * Sets the base energy cost of the tile.
          *
          * @param energyCost the base energy cost of the tile.
          * @return the tile builder
          */
-        public TileBuilder setEnergyCost(int energyCost)
-        {
+        public TileBuilder setEnergyCost(int energyCost) {
             this.energyCost = energyCost;
             return this;
         }
 
-        /** Sets the chance that the tile can be replaced by forest.
+        /**
+         * Sets the chance that the tile can be replaced by forest.
          *
          * @param forestReplaceChance the chance that the tile can be replaced by forest.
          * @return the tile builder
          */
-        public TileBuilder setForestReplaceChance(float forestReplaceChance)
-        {
+        public TileBuilder setForestReplaceChance(float forestReplaceChance) {
             this.forestReplaceChance = forestReplaceChance;
             return this;
         }
 
-        /** Sets the function for handling speed ups.
+        /**
+         * Sets the function for handling speed ups.
          *
          * @param speedUp a function.
          * @return the tile builder
          */
-        public TileBuilder setSpeedUp(Function<Player, Integer> speedUp)
-        {
+        public TileBuilder setSpeedUp(Function<Player, Integer> speedUp) {
             this.speedUp = speedUp;
             return this;
         }
 
-        /** Marks the tile as non host for towns.
+        /**
+         * Marks the tile as non host for towns.
          *
          * @return the tile builder
          */
-        public TileBuilder noTown()
-        {
+        public TileBuilder noTown() {
             this.canHostTown = false;
             return this;
         }
-        
-        /** Marks the tile as blocked for every movement.
+
+        /**
+         * Marks the tile as blocked for every movement.
          *
          * @return the tile builder
          */
-        public TileBuilder noMovement()
-        {
+        public TileBuilder noMovement() {
             this.blocksMovement = true;
             return this;
         }
-        
-        /** Sets the type of the tile.
+
+        /**
+         * Sets the type of the tile.
          *
          * @param type a tile type
          * @return the tile builder
          */
-        public TileBuilder setType(TileType type)
-        {
+        public TileBuilder setType(TileType type) {
             this.type = type;
             return this;
         }
-        
-        /** Marks the tile as host for paths.
+
+        /**
+         * Marks the tile as host for paths.
          *
          * @return the tile builder
          */
-        public TileBuilder pathHost()
-        {
+        public TileBuilder pathHost() {
             this.canHostPath = true;
             return this;
         }
-        
-        /** Marks the tile as path.
+
+        /**
+         * Marks the tile as path.
          *
          * @return the tile builder
          */
-        public TileBuilder path()
-        {
+        public TileBuilder path() {
             this.path = true;
             return this;
         }
-        
-        /** Sets the render type of the tile.
+
+        /**
+         * Sets the render type of the tile.
          *
          * @param type a render type
          * @return the tile builder
          */
-        public TileBuilder setRenderType(TileRenderType type)
-        {
+        public TileBuilder setRenderType(TileRenderType type) {
             this.renderType = type;
             return this;
         }
-        
-        /** Returns the built tile.
+
+        /**
+         * Returns the built tile.
          *
          * @return the built tile.
          */
-        public Tile build()
-        {
+        public Tile build() {
             return new Tile(energyCost, forestReplaceChance, speedUp, canHostTown, blocksMovement, type, canHostPath, path, renderType);
         }
     }
-    
+
     private static int idCounter = 0;
     private static Tile[] tiles = new Tile[8];
-    
-    private static int addTile(Tile t)
-    {
-        if(idCounter >= tiles.length)
-        {
+
+    private static int addTile(Tile t) {
+        if(idCounter >= tiles.length) {
             Tile[] newTiles = new Tile[tiles.length * 2];
             System.arraycopy(tiles, 0, newTiles, 0, tiles.length);
             tiles = newTiles;
@@ -157,21 +154,20 @@ public class Tile
         tiles[idCounter] = t;
         return idCounter++;
     }
-    
-    /** Returns a tile from the given id or null if the id is invalid.
+
+    /**
+     * Returns a tile from the given id or null if the id is invalid.
      *
      * @param id the id of the tile
      * @return a tile from the given id or null if the id is invalid
      */
-    public static Tile fromId(int id)
-    {
-        if(id < 0 || id >= idCounter)
-        {
+    public static Tile fromId(int id) {
+        if(id < 0 || id >= idCounter) {
             return null;
         }
         return tiles[id];
     }
-    
+
     private final int id;
     private final int energyCost;
     private final float forestReplaceChance;
@@ -182,11 +178,10 @@ public class Tile
     private final boolean canHostPath;
     private final boolean path;
     private final TileRenderType renderType;
-    
-    protected Tile(int energyCost, float forestReplaceChance, Function<Player, Integer> speedUp, 
+
+    protected Tile(int energyCost, float forestReplaceChance, Function<Player, Integer> speedUp,
             boolean canHostTown, boolean blocksMovement, TileType type, boolean canHostPath, boolean path,
-            TileRenderType renderType)
-    {
+            TileRenderType renderType) {
         id = addTile(this);
         this.energyCost = energyCost;
         this.forestReplaceChance = forestReplaceChance;
@@ -199,120 +194,120 @@ public class Tile
         this.renderType = renderType;
     }
 
-    /** Returns the id of the tile.
+    /**
+     * Returns the id of the tile.
      *
      * @return the id of the tile
      */
-    public final int getId()
-    {
+    public final int getId() {
         return id;
     }
-    
-    /** Returns the energy cost of a player on this tile.
+
+    /**
+     * Returns the energy cost of a player on this tile.
      *
      * @param p a player
      * @return the energy cost of a player on this tile
      */
-    public int getEnergyCost(Player p)
-    {
+    public int getEnergyCost(Player p) {
         return energyCost - speedUp.apply(p);
     }
 
-    /** Returns the chance that this tile is replaced by forest.
+    /**
+     * Returns the chance that this tile is replaced by forest.
      *
      * @return the chance that this tile is replaced by forest
      */
-    public float getForestReplaceChance()
-    {
+    public float getForestReplaceChance() {
         return forestReplaceChance;
-    } 
-    
-    /** Returns true if this tile can be replaced by a town.
+    }
+
+    /**
+     * Returns true if this tile can be replaced by a town.
      *
      * @return true if this tile can be replaced by a town
      */
-    public boolean canHostTown()
-    {
+    public boolean canHostTown() {
         return canHostTown;
-    } 
-    
-    /** Called when the player fully enters a tile.
+    }
+
+    /**
+     * Called when the player fully enters a tile.
      *
      * @param p the player
      * @param map the current tilemap
      * @param x the x coordinate of the tile
      * @param y the y coordinate of the tile
      */
-    public void onEnter(Player p, TileMap map, int x, int y)
-    {
+    public void onEnter(Player p, TileMap map, int x, int y) {
     }
-    
-    /** Called when the player leaves a tile.
+
+    /**
+     * Called when the player leaves a tile.
      *
      * @param p the player
      * @param map the current tilemap
      * @param x the x coordinate of the tile
      * @param y the y coordinate of the tile
      */
-    public void onLeave(Player p, TileMap map, int x, int y)
-    {
+    public void onLeave(Player p, TileMap map, int x, int y) {
     }
 
-    /** Returns true if this tile blocks movement.
+    /**
+     * Returns true if this tile blocks movement.
      *
      * @param p the player
      * @return true if this tile blocks movement
      */
-    public boolean isBlockingMovement(Player p)
-    {
-        return blocksMovement || (p.isSailing() && type == TileType.LAND) || 
-                (!p.isSailing() && type == TileType.DEEP_WATER);
+    public boolean isBlockingMovement(Player p) {
+        return blocksMovement || (p.isSailing() && type == TileType.LAND)
+                || (!p.isSailing() && type == TileType.DEEP_WATER);
     }
-    
-    /** Returns the type of the tile.
+
+    /**
+     * Returns the type of the tile.
      *
      * @return the type of the tile
      */
-    public TileType getType()
-    {
+    public TileType getType() {
         return type;
     }
 
-    /** Returns true if this tile can be replaced by a path.
+    /**
+     * Returns true if this tile can be replaced by a path.
      *
      * @return true if this tile can be replaced by a path
      */
-    public boolean canHostPath()
-    {
+    public boolean canHostPath() {
         return canHostPath;
     }
-    
-    /** Returns true if this tile is a path.
+
+    /**
+     * Returns true if this tile is a path.
      *
      * @return true if this tile is a path
      */
-    public boolean isPath()
-    {
+    public boolean isPath() {
         return path;
     }
 
-    /** Returns the rendering type for overlays.
+    /**
+     * Returns the rendering type for overlays.
      *
      * @return the rendering type for overlays
      */
-    public TileRenderType getRenderType()
-    {
+    public TileRenderType getRenderType() {
         return renderType;
     }
-    
-    /** Called when the player stands on that tile.
+
+    /**
+     * Called when the player stands on that tile.
      *
      * @param p the player
      * @param map the current tilemap
      * @param x the x coordinate of the tile
      * @param y the y coordinate of the tile
      */
-    public void isStandingOn(Player p, TileMap map, int x, int y)
-    {
+    public void isStandingOn(Player p, TileMap map, int x, int y) {
     }
 }

+ 6 - 9
src/pathgame/tilemap/TileHomeTown.java

@@ -2,22 +2,19 @@ package pathgame.tilemap;
 
 import pathgame.gameplay.Player;
 
-/** Class for home towns to have special behaviour.
+/**
+ * Class for home towns to have special behaviour.
  *
  * @author kajetan
  */
-public class TileHomeTown extends Tile
-{
-    public TileHomeTown()
-    {
+public class TileHomeTown extends Tile {
+    public TileHomeTown() {
         super(1, 0.0f, (pa) -> 0, false, false, TileType.LAND, false, false, TileRenderType.NORMAL);
     }
 
     @Override
-    public void onEnter(Player p, TileMap map, int x, int y)
-    {
-        if(p.canWin())
-        {
+    public void onEnter(Player p, TileMap map, int x, int y) {
+        if(p.canWin()) {
             p.win(map);
         }
     }

+ 60 - 68
src/pathgame/tilemap/TileMap.java

@@ -3,124 +3,117 @@ package pathgame.tilemap;
 import java.util.Iterator;
 import java.util.LinkedList;
 
-/** Fixed size container for tile maps. Changes are stored in a dirty flag,
- * which can be used for rendering.
+/**
+ * Fixed size container for tile maps. Changes are stored in a dirty flag, which can be used for rendering.
  *
  * @author kajetan
  */
-public class TileMap
-{
-    private static class TownConverter
-    {
+public class TileMap {
+    private static class TownConverter {
         private int x;
         private int y;
         private int ticks = 0;
         private int index = -1;
     }
-    
+
     private int towns = 0;
     private final int width;
     private final int height;
     private final int[][] tiles;
     private boolean dirty = true;
     private final LinkedList<TownConverter> townConverters = new LinkedList<>();
-    
+
     private int homeX;
     private int homeY;
-    
-    /** Creates a new tile map of the given size.
+
+    /**
+     * Creates a new tile map of the given size.
      *
      * @param width the width of the map
      * @param height the height of the map
      */
-    public TileMap(int width, int height)
-    {
+    public TileMap(int width, int height) {
         this.width = width;
         this.height = height;
         tiles = new int[width][height];
     }
-    
-    /** Returns the width of the map.
+
+    /**
+     * Returns the width of the map.
      *
      * @return the width of the map
      */
-    public int getWidth()
-    {
+    public int getWidth() {
         return width;
     }
 
-    /** Returns the height of the map.
+    /**
+     * Returns the height of the map.
      *
      * @return the height of the map
      */
-    public int getHeight()
-    {
+    public int getHeight() {
         return height;
     }
-    
-    /** Sets the tile at the given map position. The dirty flag is set.
+
+    /**
+     * Sets the tile at the given map position. The dirty flag is set.
      *
      * @param x the x coordinate of the tile
      * @param y the y coordinate of the tile
      * @param tile a tile
      */
-    public void setTile(int x, int y, Tile tile)
-    {
+    public void setTile(int x, int y, Tile tile) {
         dirty = true;
-        if(tiles[x][y] == Tiles.TOWN.getId())
-        {
+        if(tiles[x][y] == Tiles.TOWN.getId()) {
             towns--;
         }
-        if(tile == Tiles.TOWN)
-        {
+        if(tile == Tiles.TOWN) {
             towns++;
         }
         tiles[x][y] = tile.getId();
     }
-    
-    /** Returns the tile at the given map position or null if the tile is invalid.
+
+    /**
+     * Returns the tile at the given map position or null if the tile is invalid.
      *
      * @param x the x coordinate of the tile
      * @param y the y coordinate of the tile
      * @return the tile at the given map position or null if the tile is invalid
      */
-    public Tile getTile(int x, int y)
-    {
+    public Tile getTile(int x, int y) {
         return Tile.fromId(tiles[x][y]);
     }
 
-    /** Returns true if the map was modified. This is used for rendering.
+    /**
+     * Returns true if the map was modified. This is used for rendering.
      *
      * @return true if the map was modified
      */
-    public boolean isDirty()
-    {
+    public boolean isDirty() {
         return dirty;
     }
-    
-    /** Clears the dirty flag of the map.
+
+    /**
+     * Clears the dirty flag of the map.
      *
      */
-    public void clean()
-    {
+    public void clean() {
         dirty = false;
     }
-    
-    /** Ticks the tilemap.
+
+    /**
+     * Ticks the tilemap.
      *
      */
-    public void tick()
-    {
+    public void tick() {
         Iterator<TownConverter> iter = townConverters.iterator();
-        while(iter.hasNext())
-        {
+        while(iter.hasNext()) {
             TownConverter tc = iter.next();
             tc.ticks++;
-            if(tc.ticks % 10 == 0)
-            {
+            if(tc.ticks % 10 == 0) {
                 tc.index++;
-                if(tc.index >= Tiles.TOWN_BLOCKED.length)
-                {
+                if(tc.index >= Tiles.TOWN_BLOCKED.length) {
                     iter.remove();
                     continue;
                 }
@@ -128,56 +121,55 @@ public class TileMap
             }
         }
     }
-    
-    /** Slowly converts a tile into blocked town.
+
+    /**
+     * Slowly converts a tile into blocked town.
      *
      * @param x the x coordinate of the tile
      * @param y the y coordinate of the tile
      */
-    public void convertTown(int x, int y)
-    {
+    public void convertTown(int x, int y) {
         TownConverter tc = new TownConverter();
         tc.x = x;
         tc.y = y;
         townConverters.add(tc);
     }
-    
-    /** Returns the number of active towns.
+
+    /**
+     * Returns the number of active towns.
      *
      * @return the number of active towns
      */
-    public int getNumberOfTowns()
-    {
+    public int getNumberOfTowns() {
         return towns;
     }
-    
-    /** Sets the position of the home town.
+
+    /**
+     * Sets the position of the home town.
      *
-     * @param x the x coordinate of the home town 
+     * @param x the x coordinate of the home town
      * @param y the y coordinate of the home town
      */
-    public void setHomeTown(int x, int y)
-    {
+    public void setHomeTown(int x, int y) {
         homeX = x;
         homeY = y;
     }
 
-    /** Returns the x coordinate of the home town.
+    /**
+     * Returns the x coordinate of the home town.
      *
      * @return the x coordinate of the home town
      */
-    public int getHomeX()
-    {
+    public int getHomeX() {
         return homeX;
     }
 
-    /** Returns the y coordinate of the home town.
+    /**
+     * Returns the y coordinate of the home town.
      *
      * @return the y coordinate of the home town
      */
-    public int getHomeY()
-    {
+    public int getHomeY() {
         return homeY;
     }
 }
-

+ 136 - 224
src/pathgame/tilemap/TileMapGenerator.java

@@ -3,27 +3,28 @@ package pathgame.tilemap;
 import java.util.ArrayList;
 import java.util.Random;
 
-/** Static class to generate tile maps.
+/**
+ * Static class to generate tile maps.
  *
  * @author kajetan
  */
-public class TileMapGenerator
-{
+public class TileMapGenerator {
     private static long seed = 1;
-    
-    /** Returns a random generated map
+
+    /**
+     * Returns a random generated map
      *
      * @param width the width of the map
      * @param height the height of the map
      * @param towns the amount of towns
      * @return a random generated map
      */
-    public static TileMap getMap(int width, int height, int towns)
-    {
+    public static TileMap getMap(int width, int height, int towns) {
         return getMap(width, height, seed++, towns);
     }
-    
-    /** Returns a random generated map
+
+    /**
+     * Returns a random generated map
      *
      * @param width the width of the map
      * @param height the height of the map
@@ -31,78 +32,60 @@ public class TileMapGenerator
      * @param towns the amount of towns
      * @return a random generated map
      */
-    public static TileMap getMap(int width, int height, long seed, int towns)
-    {
+    public static TileMap getMap(int width, int height, long seed, int towns) {
         Random r = new Random(seed);
-        
+
         HighMap highMap = HighMap.generate(seed, width, height);
-        
+
         TileMap map = new TileMap(width, height);
-        for(int x = 0; x < width; x++)
-        {
-            for(int y = 0; y < height; y++)
-            {
-                if(highMap.get(x, y) < 0.15f)
-                {
+        for(int x = 0; x < width; x++) {
+            for(int y = 0; y < height; y++) {
+                if(highMap.get(x, y) < 0.15f) {
                     map.setTile(x, y, Tiles.DEEP_WATER);
-                }
-                else if(highMap.get(x, y) < 0.3f)
-                {
+                } else if(highMap.get(x, y) < 0.3f) {
                     map.setTile(x, y, Tiles.SHALLOW_WATER);
-                }
-                else if(highMap.get(x, y) < 0.7f)
-                {
+                } else if(highMap.get(x, y) < 0.7f) {
                     map.setTile(x, y, randomGrass(r));
-                }
-                else if(highMap.get(x, y) < 0.85f)
-                {
+                } else if(highMap.get(x, y) < 0.85f) {
                     map.setTile(x, y, Tiles.HILL);
-                }
-                else
-                {
+                } else {
                     map.setTile(x, y, Tiles.MOUNTAIN);
                 }
             }
         }
-        
+
         generateHomeTown(map, r);
-        
+
         int forestSize = ((width + height) / 2) / 10;
         forestSize *= forestSize;
         generateForest(map, r, forestSize, 10, 2, Tiles.FOREST);
         generateForest(map, r, forestSize, 5, 2, Tiles.SWAMP, Tiles.SWAMP, Tiles.SWAMP_DECO, Tiles.SWAMP_TREE, Tiles.SWAMP_BONES);
-        
+
         generateTowns(map, r, towns);
         generatePorts(map, r);
         generatePaths(map, r);
-        
+
         removeBadSwampTree(map);
         return map;
     }
-    
-    private static Tile randomGrass(Random r)
-    {
-        if(r.nextFloat() < 0.3f)
-        {
+
+    private static Tile randomGrass(Random r) {
+        if(r.nextFloat() < 0.3f) {
             return randomTile(Tiles.GRASS_VARIANTS, r);
         }
         return Tiles.GRASS;
     }
-    
-    private static void generateForest(TileMap map, Random r, int depth, int placements, int jumpRadius, Tile... t)
-    {
-        for(int i = 0; i < placements; i++)
-        {
+
+    private static void generateForest(TileMap map, Random r, int depth, int placements, int jumpRadius, Tile... t) {
+        for(int i = 0; i < placements; i++) {
             int x = r.nextInt(map.getWidth());
             int y = r.nextInt(map.getHeight());
-            while(map.getTile(x, y).getForestReplaceChance() < 1.0f)
-            {
+            while(map.getTile(x, y).getForestReplaceChance() < 1.0f) {
                 x = r.nextInt(map.getWidth());
                 y = r.nextInt(map.getHeight());
             }
-            
-            for(int j = 0; j < depth; j++)
-            {
+
+            for(int j = 0; j < depth; j++) {
                 int oldX = x;
                 int oldY = y;
 
@@ -110,169 +93,135 @@ public class TileMapGenerator
                 y += r.nextInt(jumpRadius * 2 + 1) - jumpRadius;
                 x = Math.min(Math.max(x, 0), map.getWidth() - 1);
                 y = Math.min(Math.max(y, 0), map.getHeight() - 1);
-                
-                if(r.nextFloat() < map.getTile(x, y).getForestReplaceChance())
-                {
+
+                if(r.nextFloat() < map.getTile(x, y).getForestReplaceChance()) {
                     map.setTile(x, y, randomTile(t, r));
                     placeForest(map, r, x - 1, y, t);
                     placeForest(map, r, x + 1, y, t);
                     placeForest(map, r, x, y - 1, t);
                     placeForest(map, r, x, y + 1, t);
-                }
-                else
-                {
+                } else {
                     x = oldX;
                     y = oldY;
                 }
             }
         }
     }
-    
-    private static void removeBadSwampTree(TileMap map)
-    {
-        for(int x = 0; x < map.getWidth(); x++)
-        {
-            for(int y = 0; y < map.getHeight(); y++)
-            {
+
+    private static void removeBadSwampTree(TileMap map) {
+        for(int x = 0; x < map.getWidth(); x++) {
+            for(int y = 0; y < map.getHeight(); y++) {
                 Tile t = map.getTile(x, y);
-                if((t == Tiles.SWAMP_TREE || t == Tiles.SWAMP_BONES) && 
-                        ((x > 0 && map.getTile(x - 1, y).getRenderType() != TileRenderType.SWAMP) || 
-                        (y > 0 && map.getTile(x, y - 1).getRenderType() != TileRenderType.SWAMP)))
-                {
+                if((t == Tiles.SWAMP_TREE || t == Tiles.SWAMP_BONES)
+                        && ((x > 0 && map.getTile(x - 1, y).getRenderType() != TileRenderType.SWAMP)
+                        || (y > 0 && map.getTile(x, y - 1).getRenderType() != TileRenderType.SWAMP))) {
                     map.setTile(x, y, Tiles.SWAMP);
                 }
             }
         }
     }
-    
-    private static Tile randomTile(Tile[] tiles, Random r)
-    {
-        if(tiles.length == 1)
-        {
+
+    private static Tile randomTile(Tile[] tiles, Random r) {
+        if(tiles.length == 1) {
             return tiles[0];
         }
         return tiles[r.nextInt(tiles.length)];
     }
-    
-    private static void placeForest(TileMap map, Random r, int x, int y, Tile... t)
-    {
-        if(x >= 0 && x < map.getWidth() && y >= 0 && y < map.getHeight())
-        {
-            if(r.nextFloat() * 2 < map.getTile(x, y).getForestReplaceChance())
-            {
+
+    private static void placeForest(TileMap map, Random r, int x, int y, Tile... t) {
+        if(x >= 0 && x < map.getWidth() && y >= 0 && y < map.getHeight()) {
+            if(r.nextFloat() * 2 < map.getTile(x, y).getForestReplaceChance()) {
                 map.setTile(x, y, randomTile(t, r));
             }
         }
     }
-    
-    private static void generateTowns(TileMap map, Random r, int towns)
-    {
+
+    private static void generateTowns(TileMap map, Random r, int towns) {
         int failCounter = 0;
-        while(towns > 0 && failCounter < 100)
-        {
+        while(towns > 0 && failCounter < 100) {
             int x = r.nextInt(map.getWidth());
             int y = r.nextInt(map.getHeight());
-            if(map.getTile(x, y).canHostTown() && checkNearbyTowns(map, x, y, 2))
-            {
+            if(map.getTile(x, y).canHostTown() && checkNearbyTowns(map, x, y, 2)) {
                 map.setTile(x, y, Tiles.TOWN);
                 towns--;
                 failCounter = 0;
-            }
-            else
-            {
+            } else {
                 failCounter++;
             }
         }
     }
-    
-    private static boolean checkNearbyTowns(TileMap map, int x, int y, int radius)
-    {
+
+    private static boolean checkNearbyTowns(TileMap map, int x, int y, int radius) {
         int startX = Math.max(x - radius, 0);
         int startY = Math.max(y - radius, 0);
         int endX = Math.min(x + radius, map.getWidth() - 1);
         int endY = Math.min(y + radius, map.getHeight() - 1);
-        for(int mx = startX; mx <= endX; mx++)
-        {
-            for(int my = startY; my <= endY; my++)
-            {
-                if(map.getTile(mx, my) == Tiles.TOWN)
-                {
+        for(int mx = startX; mx <= endX; mx++) {
+            for(int my = startY; my <= endY; my++) {
+                if(map.getTile(mx, my) == Tiles.TOWN) {
                     return false;
                 }
             }
         }
         return true;
     }
-    
-    private static boolean isWater(TileMap map, int x, int y)
-    {
+
+    private static boolean isWater(TileMap map, int x, int y) {
         TileType type = map.getTile(x, y).getType();
         return type == TileType.DEEP_WATER || type == TileType.SHALLOW_WATER;
     }
-    
-    private static boolean isNeighbourWater(TileMap map, int x, int y)
-    {
-        return (x - 1 >= 0 && isWater(map, x - 1, y)) ||
-                (x + 1 < map.getWidth() && isWater(map, x + 1, y)) ||
-                (y - 1 >= 0 && isWater(map, x, y - 1)) ||
-                (y + 1 < map.getHeight() && isWater(map, x, y + 1));
+
+    private static boolean isNeighbourWater(TileMap map, int x, int y) {
+        return (x - 1 >= 0 && isWater(map, x - 1, y))
+                || (x + 1 < map.getWidth() && isWater(map, x + 1, y))
+                || (y - 1 >= 0 && isWater(map, x, y - 1))
+                || (y + 1 < map.getHeight() && isWater(map, x, y + 1));
     }
-    
-    private static void generatePorts(TileMap map, Random r)
-    {
+
+    private static void generatePorts(TileMap map, Random r) {
         boolean[][] visited = new boolean[map.getWidth()][map.getHeight()];
-        for(int x = 0; x < map.getWidth(); x++)
-        {
-            for(int y = 0; y < map.getHeight(); y++)
-            {
-                if(!visited[x][y] && isWater(map, x, y))
-                {
+        for(int x = 0; x < map.getWidth(); x++) {
+            for(int y = 0; y < map.getHeight(); y++) {
+                if(!visited[x][y] && isWater(map, x, y)) {
                     getLake(map, r, x, y, visited);
                 }
                 visited[x][y] = true;
             }
         }
     }
-    
+
     private static int waterSize;
     private static int waterMinX;
     private static int waterMinY;
     private static int waterMaxX;
     private static int waterMaxY;
-    
-    private static class Location
-    {
+
+    private static class Location {
         private final int x;
         private final int y;
-        
-        public Location(int x, int y)
-        {
+
+        public Location(int x, int y) {
             this.x = x;
             this.y = y;
         }
-        
-        public double getQuaredDistance(int ox, int oy)
-        {
+
+        public double getQuaredDistance(int ox, int oy) {
             return (ox - x) * (ox - x) + (oy - y) * (oy - y);
         }
     }
-    
-    private static double minSquaredDistance(ArrayList<Location> locs, int x, int y)
-    {
+
+    private static double minSquaredDistance(ArrayList<Location> locs, int x, int y) {
         double min = Double.MAX_VALUE;
-        for(Location loc : locs)
-        {
+        for(Location loc : locs) {
             double d = loc.getQuaredDistance(x, y);
-            if(d < min)
-            {
+            if(d < min) {
                 min = d;
             }
         }
         return min;
     }
-    
-    private static void getLake(TileMap map, Random r, int x, int y, boolean[][] visited)
-    {
+
+    private static void getLake(TileMap map, Random r, int x, int y, boolean[][] visited) {
         waterSize = 0;
         waterMinX = x;
         waterMinY = y;
@@ -284,101 +233,82 @@ public class TileMapGenerator
         waterMinY = Math.max(0, waterMinY - 1);
         waterMaxX = Math.min(map.getWidth() - 1, waterMaxX + 1);
         waterMaxY = Math.min(map.getHeight() - 1, waterMaxY + 1);
-        
+
         ArrayList<Location> locs = new ArrayList<>();
-        
+
         //System.out.println(String.format("Lake Size: %d, (%d, %d) -> (%d, %d)", 
         //        waterSize, waterMinX, waterMinY, waterMaxX, waterMaxY));
         int ports = waterSize / 30;
         int diffX = waterMaxX - waterMinX + 1;
         int diffY = waterMaxY - waterMinY + 1;
         int failCounter = 0;
-        while(ports > 0 && failCounter < 100)
-        {
+        while(ports > 0 && failCounter < 100) {
             int rx = waterMinX + r.nextInt(diffX);
             int ry = waterMinY + r.nextInt(diffY);
-            if(map.getTile(rx, ry).canHostTown() && isNeighbourWater(map, rx, ry) && minSquaredDistance(locs, rx, ry) > 25)
-            {
+            if(map.getTile(rx, ry).canHostTown() && isNeighbourWater(map, rx, ry) && minSquaredDistance(locs, rx, ry) > 25) {
                 locs.add(new Location(rx, ry));
                 map.setTile(rx, ry, Tiles.PORT);
                 ports--;
                 failCounter = 0;
-            }
-            else
-            {
+            } else {
                 failCounter++;
             }
         }
     }
-    
-    private static void scanWaterTiles(TileMap map, int x, int y, boolean[][] visited)
-    {
-        if(!visited[x][y] && isWater(map, x, y))
-        {
+
+    private static void scanWaterTiles(TileMap map, int x, int y, boolean[][] visited) {
+        if(!visited[x][y] && isWater(map, x, y)) {
             visited[x][y] = true;
             waterSize++;
             waterMinX = Math.min(x, waterMinX);
             waterMinY = Math.min(y, waterMinY);
             waterMaxX = Math.max(x, waterMaxX);
             waterMaxY = Math.max(y, waterMaxY);
-            
-            if(x - 1 >= 0)
-            {
+
+            if(x - 1 >= 0) {
                 scanWaterTiles(map, x - 1, y, visited);
             }
-            if(x + 1 < map.getWidth())
-            {
+            if(x + 1 < map.getWidth()) {
                 scanWaterTiles(map, x + 1, y, visited);
             }
-            if(y - 1 >= 0)
-            {
+            if(y - 1 >= 0) {
                 scanWaterTiles(map, x, y - 1, visited);
             }
-            if(y + 1 < map.getHeight())
-            {
+            if(y + 1 < map.getHeight()) {
                 scanWaterTiles(map, x, y + 1, visited);
             }
         }
     }
-    
-    private static void generateHomeTown(TileMap map, Random r)
-    {
+
+    private static void generateHomeTown(TileMap map, Random r) {
         int failCounter = 0;
-        while(failCounter < 100)
-        {
+        while(failCounter < 100) {
             int x = r.nextInt(map.getWidth());
             int y = r.nextInt(map.getHeight());
-            if(map.getTile(x, y).canHostTown())
-            {
+            if(map.getTile(x, y).canHostTown()) {
                 map.setTile(x, y, Tiles.HOME_TOWN);
                 map.setHomeTown(x, y);
                 return;
-            }
-            else
-            {
+            } else {
                 failCounter++;
             }
         }
         map.setTile(0, 0, Tiles.HOME_TOWN);
         map.setHomeTown(0, 0);
     }
-    
-    private static boolean isPath(TileMap map, int x, int y)
-    {
+
+    private static boolean isPath(TileMap map, int x, int y) {
         return x >= 0 && y >= 0 && x < map.getWidth() && y < map.getHeight() && map.getTile(x, y).isPath();
     }
-    
-    private static void generatePaths(TileMap map, Random r)
-    {
+
+    private static void generatePaths(TileMap map, Random r) {
         int paths = (map.getHeight() + map.getWidth()) / 6 + 2;
-        
+
         // generate paths with random direction
-        for(int i = 0; i < paths; i++)
-        {
+        for(int i = 0; i < paths; i++) {
             int x = r.nextInt(map.getWidth());
             int y = r.nextInt(map.getHeight());
-            while(!map.getTile(x, y).canHostPath())
-            {
+            while(!map.getTile(x, y).canHostPath()) {
                 x = r.nextInt(map.getWidth());
                 y = r.nextInt(map.getHeight());
             }
@@ -390,77 +320,59 @@ public class TileMapGenerator
         // destroy path 2x2 blocks
         destroyPathBlocks(map);
         destroyPathBlocks(map);
-        
+
         // swap paths depending on neighbours
-        for(int x = 0; x < map.getWidth(); x++)
-        {
-            for(int y = 0; y < map.getHeight(); y++)
-            {
-                if(map.getTile(x, y).isPath())
-                {
+        for(int x = 0; x < map.getWidth(); x++) {
+            for(int y = 0; y < map.getHeight(); y++) {
+                if(map.getTile(x, y).isPath()) {
                     map.setTile(x, y, Tiles.getPath(
-                            isPath(map, x, y - 1), isPath(map, x + 1, y), 
+                            isPath(map, x, y - 1), isPath(map, x + 1, y),
                             isPath(map, x, y + 1), isPath(map, x - 1, y)));
                 }
             }
         }
     }
-    
-    private static void destroyPathBlocks(TileMap map)
-    {
-        for(int x = 0; x < map.getWidth() - 1; x++)
-        {
-            for(int y = 0; y < map.getHeight() - 1; y++)
-            {
-                if(map.getTile(x, y).isPath() && map.getTile(x + 1, y).isPath() && 
-                        map.getTile(x, y + 1).isPath() && map.getTile(x + 1, y + 1).isPath())
-                {
-                    if(!isPath(map, x - 1, y) && !isPath(map, x, y - 1))
-                    {
+
+    private static void destroyPathBlocks(TileMap map) {
+        for(int x = 0; x < map.getWidth() - 1; x++) {
+            for(int y = 0; y < map.getHeight() - 1; y++) {
+                if(map.getTile(x, y).isPath() && map.getTile(x + 1, y).isPath()
+                        && map.getTile(x, y + 1).isPath() && map.getTile(x + 1, y + 1).isPath()) {
+                    if(!isPath(map, x - 1, y) && !isPath(map, x, y - 1)) {
                         map.setTile(x, y, Tiles.GRASS);
                         continue;
                     }
-                    if(!isPath(map, x + 1, y - 1) && !isPath(map, x + 2, y))
-                    {
+                    if(!isPath(map, x + 1, y - 1) && !isPath(map, x + 2, y)) {
                         map.setTile(x + 1, y, Tiles.GRASS);
                         continue;
                     }
-                    if(!isPath(map, x - 1, y + 1) && !isPath(map, x, y + 2))
-                    {
+                    if(!isPath(map, x - 1, y + 1) && !isPath(map, x, y + 2)) {
                         map.setTile(x, y + 1, Tiles.GRASS);
                         continue;
                     }
-                    if(!isPath(map, x + 2, y + 1) && !isPath(map, x + 1, y + 2))
-                    {
+                    if(!isPath(map, x + 2, y + 1) && !isPath(map, x + 1, y + 2)) {
                         map.setTile(x + 1, y + 1, Tiles.GRASS);
                     }
                 }
             }
         }
     }
-    
-    private static void generatePathDiretion(TileMap map, Random r, float x, float y, float dx, float dy)
-    {
-        while(true)
-        {
+
+    private static void generatePathDiretion(TileMap map, Random r, float x, float y, float dx, float dy) {
+        while(true) {
             int tileX = (int) x;
             int tileY = (int) y;
-            
-            if(tileX < 0 || tileY < 0 || tileX >= map.getWidth() || tileY >= map.getHeight() || !map.getTile(tileX, tileY).canHostPath())
-            {
+
+            if(tileX < 0 || tileY < 0 || tileX >= map.getWidth() || tileY >= map.getHeight() || !map.getTile(tileX, tileY).canHostPath()) {
                 break;
             }
-            
+
             map.setTile(tileX, tileY, Tiles.PATH_N_E_S_W);
-            
-            while(tileX == (int) x && tileY == (int) y)
-            {
-                if(r.nextBoolean())
-                {
+
+            while(tileX == (int) x && tileY == (int) y) {
+                if(r.nextBoolean()) {
                     x += dx;
-                }
-                else
-                {
+                } else {
                     y += dy;
                 }
             }

+ 6 - 9
src/pathgame/tilemap/TilePort.java

@@ -3,22 +3,19 @@ package pathgame.tilemap;
 import pathgame.gameplay.Keys;
 import pathgame.gameplay.Player;
 
-/** Class for ports to have special behaviour.
+/**
+ * Class for ports to have special behaviour.
  *
  * @author kajetan
  */
-public class TilePort extends Tile
-{
-    public TilePort()
-    {
+public class TilePort extends Tile {
+    public TilePort() {
         super(2, 0.0f, (pa) -> 0, false, false, TileType.PORT, false, false, TileRenderType.NORMAL);
     }
 
     @Override
-    public void isStandingOn(Player p, TileMap map, int x, int y)
-    {
-        if(Keys.BOAT_KEY.getTime() == 1)
-        {
+    public void isStandingOn(Player p, TileMap map, int x, int y) {
+        if(Keys.BOAT_KEY.getTime() == 1) {
             p.switchSailing();
         }
     }

+ 3 - 3
src/pathgame/tilemap/TileRenderType.java

@@ -1,10 +1,10 @@
 package pathgame.tilemap;
 
-/** Rendering types of tiles used for deciding which overlay should be used.
+/**
+ * Rendering types of tiles used for deciding which overlay should be used.
  *
  * @author kajetan
  */
-public enum TileRenderType
-{
+public enum TileRenderType {
     WATER, SWAMP, NORMAL
 }

+ 6 - 9
src/pathgame/tilemap/TileTown.java

@@ -2,26 +2,23 @@ package pathgame.tilemap;
 
 import pathgame.gameplay.Player;
 
-/** Class for towns to have special behaviour.
+/**
+ * Class for towns to have special behaviour.
  *
  * @author kajetan
  */
-public class TileTown extends Tile
-{
-    public TileTown()
-    {
+public class TileTown extends Tile {
+    public TileTown() {
         super(2, 0.0f, (pa) -> 0, false, false, TileType.LAND, false, false, TileRenderType.NORMAL);
     }
 
     @Override
-    public void onEnter(Player p, TileMap map, int x, int y)
-    {
+    public void onEnter(Player p, TileMap map, int x, int y) {
         p.visitTown();
     }
 
     @Override
-    public void onLeave(Player p, TileMap map, int x, int y)
-    {
+    public void onLeave(Player p, TileMap map, int x, int y) {
         map.convertTown(x, y);
     }
 }

+ 3 - 4
src/pathgame/tilemap/TileType.java

@@ -1,11 +1,10 @@
 package pathgame.tilemap;
 
-/** Types of tiles used for deciding if a player can enter this tile in their
- * current state.
+/**
+ * Types of tiles used for deciding if a player can enter this tile in their current state.
  *
  * @author kajetan
  */
-public enum TileType
-{
+public enum TileType {
     PORT, LAND, SHALLOW_WATER, DEEP_WATER
 }

+ 17 - 26
src/pathgame/tilemap/Tiles.java

@@ -2,12 +2,12 @@ package pathgame.tilemap;
 
 import pathgame.gameplay.PlayerAbilities;
 
-/** Static class for all existing tiles.
+/**
+ * Static class for all existing tiles.
  *
  * @author kajetan
  */
-public class Tiles
-{
+public class Tiles {
 
     public final static Tile GRASS = buildGrass();
     public final static Tile GRASS_WITH_STONE = buildGrass();
@@ -20,8 +20,7 @@ public class Tiles
     public final static Tile GRASS_WITH_HILL = buildGrass();
     public final static Tile GRASS_WITH_EARTH = buildGrass();
 
-    public final static Tile[] GRASS_VARIANTS = new Tile[]
-    {
+    public final static Tile[] GRASS_VARIANTS = new Tile[]{
         GRASS, GRASS_WITH_STONE, GRASS_WITH_6_BUSHES, GRASS_WITH_3_BUSHES,
         GRASS_WITH_FLOWERS_1, GRASS_WITH_FLOWERS_2, GRASS_WITH_FLOWERS_3,
         GRASS_WITH_FLOWERS_4, GRASS_WITH_HILL, GRASS_WITH_EARTH
@@ -40,12 +39,10 @@ public class Tiles
     public final static Tile SHALLOW_WATER = Tile.TileBuilder.create()
             .setEnergyCost(6)
             .setForestReplaceChance(0.0f)
-            .setSpeedUp((p) ->
-            {
-                if(p.isSailing())
-                {
-                    if(p.getAbilities() == PlayerAbilities.SAILOR)
-                    {
+            .setSpeedUp((p)
+                    -> {
+                if(p.isSailing()) {
+                    if(p.getAbilities() == PlayerAbilities.SAILOR) {
                         return 5;
                     }
                     return 4;
@@ -82,15 +79,13 @@ public class Tiles
     public final static Tile TOWN_BLOCKED_3 = buildBlockedTown();
     public final static Tile TOWN_BLOCKED_4 = buildBlockedTown();
 
-    public final static Tile[] TOWN_BLOCKED = new Tile[]
-    {
+    public final static Tile[] TOWN_BLOCKED = new Tile[]{
         TOWN_BLOCKED_1, TOWN_BLOCKED_2, TOWN_BLOCKED_3, TOWN_BLOCKED_4
     };
 
     public final static Tile PORT = new TilePort();
 
-    private final static Tile buildGrass()
-    {
+    private final static Tile buildGrass() {
         return Tile.TileBuilder.create()
                 .setSpeedUp((p) -> p.getAbilities().getFasterGrass())
                 .pathHost()
@@ -98,8 +93,7 @@ public class Tiles
                 .build();
     }
 
-    private final static Tile buildSwamp()
-    {
+    private final static Tile buildSwamp() {
         return Tile.TileBuilder.create()
                 .setEnergyCost(5)
                 .setForestReplaceChance(0.0f)
@@ -108,8 +102,7 @@ public class Tiles
                 .build();
     }
 
-    private final static Tile buildBlockedTown()
-    {
+    private final static Tile buildBlockedTown() {
         return Tile.TileBuilder.create()
                 .setForestReplaceChance(0.0f)
                 .noTown()
@@ -118,8 +111,7 @@ public class Tiles
 
     public final static Tile HOME_TOWN = new TileHomeTown();
 
-    private final static Tile buildPath()
-    {
+    private final static Tile buildPath() {
         return Tile.TileBuilder.create()
                 .setForestReplaceChance(0.0f)
                 .path()
@@ -142,15 +134,15 @@ public class Tiles
     public final static Tile PATH_S = buildPath();
     public final static Tile PATH_W = buildPath();
 
-    public final static Tile[] PATH = new Tile[]
-    {
+    public final static Tile[] PATH = new Tile[]{
         PATH_N_E_S_W, PATH_N_E_S, PATH_N_E_W, PATH_N_E,
         PATH_N_S_W, PATH_N_S, PATH_N_W, PATH_N,
         PATH_E_S_W, PATH_E_S, PATH_E_W, PATH_E,
         PATH_S_W, PATH_S, PATH_W, GRASS
     };
 
-    /** Returns a path with the given blocked directions.
+    /**
+     * Returns a path with the given blocked directions.
      *
      * @param north true if there is a connection to the north tile
      * @param east true if there is a connection to the east tile
@@ -158,8 +150,7 @@ public class Tiles
      * @param west true if there is a connection to the west tile
      * @return a path with the given blocked directions
      */
-    public static Tile getPath(boolean north, boolean east, boolean south, boolean west)
-    {
+    public static Tile getPath(boolean north, boolean east, boolean south, boolean west) {
         return PATH[(north ? 0 : 8) + (east ? 0 : 4) + (south ? 0 : 2) + (west ? 0 : 1)];
     }
 }