Browse Source

update to new engine, clean up (javadoc, ...)

Kajetan Johannes Hammerle 4 years ago
parent
commit
38dca021f2
47 changed files with 254 additions and 1884 deletions
  1. BIN
      lib/SnuviEngine.jar
  2. 5 4
      src/pathgame/Main.java
  3. 25 12
      src/pathgame/PathGame.java
  4. 2 55
      src/pathgame/algorithm/Coord.java
  5. 9 153
      src/pathgame/algorithm/DijkstraMagic.java
  6. 4 35
      src/pathgame/algorithm/ExtraPath.java
  7. 2 106
      src/pathgame/algorithm/Node2D.java
  8. 2 38
      src/pathgame/algorithm/OddDegreeList.java
  9. 2 62
      src/pathgame/algorithm/Permutation.java
  10. 3 23
      src/pathgame/algorithm/SaleRoute.java
  11. 1 90
      src/pathgame/algorithm/TravellingSalesAlg.java
  12. 3 49
      src/pathgame/algorithm/TreeEdge.java
  13. 9 21
      src/pathgame/gameplay/Gamestate.java
  14. 64 48
      src/pathgame/gameplay/Keys.java
  15. 3 57
      src/pathgame/gameplay/Level.java
  16. 0 25
      src/pathgame/gameplay/MinusStepsValues.java
  17. 6 166
      src/pathgame/gameplay/Player.java
  18. 1 60
      src/pathgame/gameplay/PlayerAbilities.java
  19. 3 23
      src/pathgame/gameplay/menu/AfterScoreMenu.java
  20. 6 51
      src/pathgame/gameplay/menu/BaseMenu.java
  21. 2 22
      src/pathgame/gameplay/menu/CharacterMenu.java
  22. 6 22
      src/pathgame/gameplay/menu/EscMenu.java
  23. 3 31
      src/pathgame/gameplay/menu/MainMenu.java
  24. 17 43
      src/pathgame/gameplay/menu/Menu.java
  25. 0 28
      src/pathgame/gameplay/menu/MenuButton.java
  26. 8 20
      src/pathgame/gameplay/menu/OptionMenu.java
  27. 7 51
      src/pathgame/rendering/Camera.java
  28. 6 20
      src/pathgame/rendering/HUDRenderer.java
  29. 5 25
      src/pathgame/rendering/LevelRenderer.java
  30. 15 24
      src/pathgame/rendering/MenuRenderer.java
  31. 0 23
      src/pathgame/rendering/PlayerRenderer.java
  32. 5 19
      src/pathgame/rendering/ScoreMenuRenderer.java
  33. 4 15
      src/pathgame/rendering/StaticTextureProvider.java
  34. 18 79
      src/pathgame/rendering/TileMapRenderer.java
  35. 0 17
      src/pathgame/rendering/TileRenderer.java
  36. 0 39
      src/pathgame/rendering/TileTexture.java
  37. 0 14
      src/pathgame/rendering/TileTextureProvider.java
  38. 0 21
      src/pathgame/tilemap/HighMap.java
  39. 2 148
      src/pathgame/tilemap/Tile.java
  40. 0 5
      src/pathgame/tilemap/TileHomeTown.java
  41. 0 75
      src/pathgame/tilemap/TileMap.java
  42. 0 24
      src/pathgame/tilemap/TileMapGenerator.java
  43. 2 7
      src/pathgame/tilemap/TilePort.java
  44. 0 5
      src/pathgame/tilemap/TileRenderType.java
  45. 0 5
      src/pathgame/tilemap/TileTown.java
  46. 0 5
      src/pathgame/tilemap/TileType.java
  47. 4 19
      src/pathgame/tilemap/Tiles.java

BIN
lib/SnuviEngine.jar


+ 5 - 4
src/pathgame/Main.java

@@ -1,12 +1,13 @@
 package pathgame;
 
-import me.hammerle.snuviengine.api.Engine;
+import me.hammerle.snuviengine.api.ResizingWindowView;
+import me.hammerle.snuviengine.api.Window;
 
 public class Main {
     public static void main(String[] args) {
-        Engine.init("Path Game", 1024, 768);
-        Engine.setNanosPerTick(50_000_000);
+        Window window = new Window(50_000_000, new ResizingWindowView(400, 300));
+        window.initialize("Path Game", 1024, 768);
         PathGame game = new PathGame();
-        Engine.start(game);
+        window.open(game);
     }
 }

+ 25 - 12
src/pathgame/PathGame.java

@@ -1,7 +1,9 @@
 package pathgame;
 
-import me.hammerle.snuviengine.api.IGame;
+import me.hammerle.snuviengine.api.Game;
+import me.hammerle.snuviengine.api.Gamepad;
 import me.hammerle.snuviengine.api.Renderer;
+import me.hammerle.snuviengine.api.Stats;
 import pathgame.gameplay.Gamestate;
 import pathgame.gameplay.Gamestates;
 import pathgame.gameplay.Keys;
@@ -10,26 +12,32 @@ import pathgame.gameplay.menu.Menu;
 import pathgame.rendering.LevelRenderer;
 import pathgame.rendering.MenuRenderer;
 
-public class PathGame implements IGame {
+public class PathGame implements Game {
     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();
+    private Menu menu;
+    private MenuRenderer menuRenderer;
 
-    public PathGame() {
+    private Keys keys;
+
+    @Override
+    public void onCompleteInitialization(Stats stats, me.hammerle.snuviengine.api.Keys keys, Gamepad gamepad) {
+        this.keys = new Keys(keys);
+        menu = new Menu(this.keys);
+        menuRenderer = new MenuRenderer(this.keys);
     }
 
     @Override
     public void tick() {
-        level.tick(gamestate);
-        levelRenderer.tick(level, gamestate);
+        level.tick(gamestate, keys);
+        levelRenderer.tick(level, gamestate, keys);
 
-        menu.tick(gamestate, level);
+        menu.tick(gamestate, level, keys);
 
-        if(Keys.TEST_KEY.getTime() == 1) {
+        if(keys.test.getTime() == 1) {
             //level.nextLevel();
             level.getPlayer().win(level.getMap());
         }
@@ -38,14 +46,19 @@ public class PathGame implements IGame {
     @Override
     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);
+            levelRenderer.renderTick(r, 0.0f, level, gamestate, keys);
+            menuRenderer.renderTick(r, 0.0f, menu, keys);
         } else {
-            levelRenderer.renderTick(r, lag, level, gamestate);
+            levelRenderer.renderTick(r, lag, level, gamestate, keys);
         }
     }
 
     @Override
     public void onStop() {
     }
+
+    @Override
+    public boolean isRunning() {
+        return gamestate.isRunning();
+    }
 }

+ 2 - 55
src/pathgame/algorithm/Coord.java

@@ -1,98 +1,45 @@
 package pathgame.algorithm;
 
-/**
- * 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
-     *
-     * @param x position of Coord
-     * @param y position of Coord
-     */
-    Coord(int x, int y) {
+    public Coord(int x, int y) {
         this.x = x;
         this.y = y;
     }
 
-    /**
-     * 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
-     * @param isBoatTile set to true if part of a boat path; used for debug purposes
-     */
-    Coord(int x, int y, boolean isBoatTile) {
+    public Coord(int x, int y, boolean isBoatTile) {
         this.x = x;
         this.y = y;
         this.isBoatTile = isBoatTile;
     }
 
-    /**
-     * Returns x position of Coord
-     *
-     * @return x position
-     */
     public int getX() {
         return x;
     }
 
-    /**
-     * Returns y position of Coord
-     *
-     * @return y position
-     */
     public int getY() {
         return y;
     }
 
-    /**
-     * Adds given value to x position of Coord
-     *
-     * @param x value to be added to x position
-     */
     public void changeX(int x) {
         this.x += x;
     }
 
-    /**
-     * Adds given value to y position of Coord
-     *
-     * @param y value to be added to y position
-     */
     public void changeY(int y) {
         this.y += y;
     }
 
-    /**
-     * Sets x and y position of Coord to given values
-     *
-     * @param x new x position of Coord
-     * @param y new y position of Coord
-     */
     public void setCoord(int x, int y) {
         this.x = x;
         this.y = y;
     }
 
-    /**
-     * Returns isBoatTile, which is true if Coord is part of a boat path
-     *
-     * @return isBoatTile of Coord
-     */
     public boolean isBoatTile() {
         return isBoatTile;
     }
 
-    /**
-     * Sets isBoatTile to given value
-     *
-     * @param isBoatTile value isBoatTile gets set to
-     */
     public void setBoatTile(boolean isBoatTile) {
         this.isBoatTile = isBoatTile;
     }

+ 9 - 153
src/pathgame/algorithm/DijkstraMagic.java

@@ -7,28 +7,17 @@ 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
- *
- */
 public class DijkstraMagic {
-    private int TOWN_ID = Tiles.TOWN.getId();
-    private int START_ID = Tiles.HOME_TOWN.getId();
-    private int PORT_ID = Tiles.PORT.getId();
+    private final int TOWN_ID = Tiles.TOWN.getId();
+    private final int START_ID = Tiles.HOME_TOWN.getId();
+    private final int PORT_ID = Tiles.PORT.getId();
     private int WATER_WEIGHT;
-    private ArrayList<Coord> towns = new ArrayList<>();
-    private ArrayList<Coord> ports = new ArrayList<>();
-    private TileMap map;
-    private Node2D[][] weightMap;
-    private ArrayList<ArrayList<SaleRoute>> salesPitch = new ArrayList<>();
-
-    /**
-     * 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
-     */
+    private final ArrayList<Coord> towns = new ArrayList<>();
+    private final ArrayList<Coord> ports = new ArrayList<>();
+    private final TileMap map;
+    private final Node2D[][] weightMap;
+    private final ArrayList<ArrayList<SaleRoute>> salesPitch = new ArrayList<>();
+
     public DijkstraMagic(TileMap map, Player player) {
         this.map = map;
 
@@ -36,7 +25,6 @@ public class DijkstraMagic {
 
         setup(player);
 
-        //printWeightMap();
         for(int i = 0; i < ports.size(); i++) {
             doMagic(i, false);
         }
@@ -44,15 +32,8 @@ public class DijkstraMagic {
         for(int i = 0; i < towns.size(); i++) {
             doMagic(i, true);
         }
-
-        //printDijkstraResult();
     }
 
-    /**
-     * Returns the generated table of Dijkstra results
-     *
-     * @return generated table of Dijkstra results
-     */
     public ArrayList<ArrayList<SaleRoute>> getSalesPitch() {
         return salesPitch;
     }
@@ -98,14 +79,10 @@ public class DijkstraMagic {
             }
         }
         if(forTown) {
-            //printPathMap();
-            //printPorts();
             makeListForPitch(fromIndex);
         } else {
             addPortsPaths(fromIndex);
         }
-
-        //printDijkstraMap();
     }
 
     private void dijkstraForTownOrPort(int posX, int posY, ArrayList<Coord> tileQ, int qIndex, boolean forTown) {
@@ -199,8 +176,6 @@ public class DijkstraMagic {
             Coord nextPort = ports.get(i);
 
             if(weightMap[nextPort.getX()][nextPort.getY()].getCostSoFar() < Integer.MAX_VALUE) {
-                //System.out.println("connecting ports " + fromIndex + " and " + i);
-
                 int pathWeight = weightMap[nextPort.getX()][nextPort.getY()].getCostSoFar();
                 ArrayList<Coord> pathCoords = new ArrayList<>();
 
@@ -274,8 +249,6 @@ public class DijkstraMagic {
     }
 
     private void setup(Player player) {
-        //find towns
-
         for(int x = 0; x < map.getWidth(); x++) {
             for(int y = 0; y < map.getHeight(); y++) {
                 weightMap[x][y] = new Node2D(map.getTile(x, y).getEnergyCost(player));
@@ -300,121 +273,4 @@ public class DijkstraMagic {
 
         player.switchSailing();
     }
-
-    private void printDijkstraMap() {
-        String ANSI_RESET = "\u001B[0m";
-        String ANSI_BLUE = "\u001B[34m";
-        String ANSI_PURPLE = "\u001B[35m";
-        String ANSI_RED = "\u001B[31m";
-
-        for(int y = 0; y < weightMap[0].length; y++) {
-            for(int x = 0; x < weightMap.length; x++) {
-                int cost = weightMap[x][y].getCostSoFar();
-                if(cost == Integer.MAX_VALUE) {
-                    System.out.print("- ");
-                } 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) {
-                        System.out.print(ANSI_BLUE + cost + " " + ANSI_RESET);
-                    } else if(weightMap[x][y].isTown()) {
-                        System.out.print(ANSI_PURPLE + cost + " " + ANSI_RESET);
-                    } else {
-                        System.out.print(cost + " ");
-                    }
-
-                }
-
-            }
-            System.out.println();
-        }
-
-        System.out.println();
-    }
-
-    private void printDijkstraResult() {
-        System.out.println();
-
-        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++) {
-                System.out.print("Total Cost: " + salesPitch.get(origNum).get(lNum).getTotalCost() + "   ");
-
-                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 {
-                        System.out.print(c.getX() + "/" + c.getY() + " ");
-                    }
-                }
-                System.out.println();
-            }
-
-            System.out.println();
-        }
-
-        System.out.println();
-    }
-
-    private void printPorts() {
-        for(int y = 0; y < weightMap[0].length; y++) {
-            for(int x = 0; x < weightMap.length; x++) {
-                if(weightMap[x][y].hasExtraPaths()) {
-                    ArrayList<ExtraPath> extraPaths = weightMap[x][y].getExtraPaths();
-
-                    System.out.println(x + "/" + y);
-                    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();
-                }
-            }
-        }
-    }
-
-    private void printPathMap() {
-        for(int y = 0; y < weightMap[0].length; y++) {
-            for(int x = 0; x < weightMap.length; x++) {
-                if(weightMap[x][y].hasExtraPaths()) {
-                    System.out.print(weightMap[x][y].getPrevBoatPath() + " ");
-                } else {
-                    System.out.print(weightMap[x][y].getPrevOfPath() + " ");
-                }
-            }
-            System.out.println();
-        }
-
-        System.out.println();
-    }
-
-    private void printWeightMap() {
-        String ANSI_RESET = "\u001B[0m";
-        String ANSI_BLUE = "\u001B[34m";
-        String ANSI_CYAN = "\u001B[36m";
-        String ANSI_RED = "\u001B[31m";
-
-        for(int y = 0; y < weightMap[0].length; y++) {
-            for(int x = 0; x < weightMap.length; x++) {
-                int cost = weightMap[x][y].getWeight();
-                TileType type = weightMap[x][y].getType();
-                if(weightMap[x][y].isTown()) {
-                    System.out.print(ANSI_RED + "T " + ANSI_RESET);
-                } else if(type == TileType.PORT) {
-                    System.out.print(ANSI_CYAN + "P " + ANSI_RESET);
-                } else if(type == TileType.SHALLOW_WATER) {
-                    System.out.print(ANSI_BLUE + "s " + ANSI_RESET);
-                } else if(type == TileType.DEEP_WATER) {
-                    System.out.print(ANSI_BLUE + "d " + ANSI_RESET);
-                } else {
-                    System.out.print(cost + " ");
-                }
-            }
-            System.out.println();
-        }
-
-        System.out.println();
-    }
 }

+ 4 - 35
src/pathgame/algorithm/ExtraPath.java

@@ -2,23 +2,12 @@ package pathgame.algorithm;
 
 import java.util.ArrayList;
 
-/**
- * Class that stores data on paths to nodes that are not adjacent to each other
- *
- */
 public class ExtraPath {
-    private int pathWeight;
-    private int destX, destY;
-    private ArrayList<Coord> pathCoords;
+    private final int pathWeight;
+    private final int destX;
+    private final int destY;
+    private final ArrayList<Coord> pathCoords;
 
-    /**
-     * 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
-     * @param pathWeight total weight of the path
-     * @param pathCoords list of all coordinates that make up the path, in order
-     */
     public ExtraPath(int destX, int destY, int pathWeight, ArrayList<Coord> pathCoords) {
         this.destX = destX;
         this.destY = destY;
@@ -26,38 +15,18 @@ public class ExtraPath {
         this.pathCoords = pathCoords;
     }
 
-    /**
-     * Returns x position of path destination
-     *
-     * @return x position of path destination
-     */
     public int getDestX() {
         return destX;
     }
 
-    /**
-     * Returns y position of path destination
-     *
-     * @return y position of path destination
-     */
     public int getDestY() {
         return destY;
     }
 
-    /**
-     * Returns total weight of the path
-     *
-     * @return total weight of the path
-     */
     public int getPathWeight() {
         return pathWeight;
     }
 
-    /**
-     * Returns a list of the coordinates that make up the path
-     *
-     * @return coordinates of path
-     */
     public ArrayList<Coord> getPathCoords() {
         return pathCoords;
     }

+ 2 - 106
src/pathgame/algorithm/Node2D.java

@@ -1,15 +1,10 @@
 package pathgame.algorithm;
 
 import pathgame.tilemap.TileType;
-
 import java.util.ArrayList;
 
-/**
- * Class for storing node data for the Dijkstra algorithm
- *
- */
 public class Node2D {
-    private int weight;
+    private final int weight;
     private int costSoFar = Integer.MAX_VALUE;
     private char prevOfPath = '\0';
     private int prevBoatPath = -1;
@@ -19,180 +14,81 @@ public class Node2D {
     private boolean isBlocked = false;
     private boolean isTown = false;
 
-    private ArrayList<ExtraPath> extraPaths = new ArrayList<>();
+    private final ArrayList<ExtraPath> extraPaths = new ArrayList<>();
 
-    /**
-     * Create new Node2D with given weight
-     *
-     * @param weight cost it takes to travel to this node
-     */
     public Node2D(int weight) {
         this.weight = weight;
     }
 
-    /**
-     * Returns the weight of the node
-     *
-     * @return the weight of the node
-     */
     public int getWeight() {
         return weight;
     }
 
-    /**
-     * Returns the lowest total cost of travelling to this node from where the algorithm started
-     *
-     * @return lowest cost to get to this node
-     */
     public int getCostSoFar() {
         return costSoFar;
     }
 
-    /**
-     * 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
-     */
     public void setCostSoFar(int costSoFar) {
         this.costSoFar = costSoFar;
     }
 
-    /**
-     * 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
-     */
     public char getPrevOfPath() {
         return prevOfPath;
     }
 
-    /**
-     * 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
-     */
     public void setPrevOfPath(char prevOfPath) {
         this.prevOfPath = prevOfPath;
     }
 
-    /**
-     * Returns the list of all ExtraPaths of this node
-     *
-     * @return list of ExtraPaths
-     */
     public ArrayList<ExtraPath> getExtraPaths() {
         return extraPaths;
     }
 
-    /**
-     * 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
-     * @param pathCoords list of coordinates of the path
-     */
     public void addExtraPath(Coord dest, int pathWeight, ArrayList<Coord> pathCoords) {
         hasExtraPaths = true;
         extraPaths.add(new ExtraPath(dest.getX(), dest.getY(), pathWeight, pathCoords));
     }
 
-    /**
-     * Returns hasExtraPaths, which is true, if this node has ExtraPaths
-     *
-     * @return whether node has ExtraPaths
-     */
     public boolean hasExtraPaths() {
         return hasExtraPaths;
     }
 
-    /**
-     * Returns isQAdded, which is true, if the node has been added to the queue
-     *
-     * @return whether node has been added to the queue
-     */
     public boolean isQAdded() {
         return isQAdded;
     }
 
-    /**
-     * Sets isQAdded, which is true, if the node has been added to the queue
-     *
-     * @param QAdded whether node has been added to the queue
-     */
     public void setQAdded(boolean QAdded) {
         isQAdded = QAdded;
     }
 
-    /**
-     * Returns isBlocked, which is true, if this node can't be travelled to from adjacent nodes
-     *
-     * @return whether node is blocked from travel
-     */
     public boolean isBlocked() {
         return isBlocked;
     }
 
-    /**
-     * Sets isBlocked, which is true, if this node can't be travelled to from adjacent nodes
-     *
-     * @param blocked whether node is blocked from travel
-     */
     public void setBlocked(boolean blocked) {
         isBlocked = blocked;
     }
 
-    /**
-     * Returns the type of the Tile that is represented by this node
-     *
-     * @return the type of the tile
-     */
     public TileType getType() {
         return type;
     }
 
-    /**
-     * Sets the type of the Tile that is represented by this node
-     *
-     * @param type the type of the tile
-     */
     public void setType(TileType type) {
         this.type = type;
     }
 
-    /**
-     * Returns the index of the the previous ExtraPath
-     *
-     * @return the index of the the previous ExtraPath
-     */
     public int getPrevBoatPath() {
         return prevBoatPath;
     }
 
-    /**
-     * Sets the index of the the previous ExtraPath
-     *
-     * @param prevBoatPath the index of the the previous ExtraPath
-     */
     public void setPrevBoatPath(int prevBoatPath) {
         this.prevBoatPath = prevBoatPath;
     }
 
-    /**
-     * Returns isTown, which is true if the node is a town
-     *
-     * @return whether node is a town
-     */
     public boolean isTown() {
         return isTown;
     }
 
-    /**
-     * Sets isTown, which is true if the node is a town
-     *
-     * @param town whether node is a town
-     */
     public void setTown(boolean town) {
         isTown = town;
     }

+ 2 - 38
src/pathgame/algorithm/OddDegreeList.java

@@ -2,77 +2,41 @@ package pathgame.algorithm;
 
 import java.util.ArrayList;
 
-/**
- * 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<>();
+    private final ArrayList<Integer> items = new ArrayList<>();
+    private final ArrayList<Boolean> itemUsed = new ArrayList<>();
 
-    /**
-     * Adds a vertex to the list
-     *
-     * @param vertex index of the vertex in the list of all vertexes
-     */
     public void add(int vertex) {
         items.add(vertex);
         itemUsed.add(false);
     }
 
-    /**
-     * Returns the size of the list of vertexes
-     *
-     * @return the size of the list of vertexes
-     */
     public int size() {
         return items.size();
     }
 
-    /**
-     * Resets which vertexes have already been used for the permutation
-     *
-     */
     public void resetUsed() {
         for(int i = 0; i < itemUsed.size(); i++) {
             itemUsed.set(i, false);
         }
     }
 
-    /**
-     * 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
-     */
     public int getUnused(int offSet) {
         return items.get(getOffsetPos(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
-     */
     public int makeOffsetUsed(int offSet) {
         int pos = getOffsetPos(offSet);
         itemUsed.set(pos, true);
         return pos;
     }
 
-    /**
-     * makes the vertex at the given position unused
-     *
-     * @param pos index of the vertex that is made unused
-     */
     public void makeUnused(int pos) {
         itemUsed.set(pos, false);
     }
 
     private int getOffsetPos(int offSet) {
         int foundValid = 0;
-
         for(int i = 0; i < items.size(); i++) {
             if(!itemUsed.get(i)) {
                 if(offSet == foundValid) {

+ 2 - 62
src/pathgame/algorithm/Permutation.java

@@ -1,22 +1,12 @@
 package pathgame.algorithm;
 
-/**
- * Class for generating all possible permutations of travelling salesman paths
- *
- */
 public class Permutation {
-    private int size;
+    private final int size;
     private int[] vals;
     private int[] minVals;
     private int minCost = Integer.MAX_VALUE;
-    private int thingsPerPos;
+    private final int thingsPerPos;
 
-    /**
-     * 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;
@@ -24,22 +14,10 @@ public class Permutation {
 
     }
 
-    /**
-     * 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) {
         return vals[pos];
     }
 
-    /**
-     * 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) {
         if(vals[pos] == getMaxOfPos(pos)) {
             return true;
@@ -47,30 +25,14 @@ public class Permutation {
         return false;
     }
 
-    /**
-     * 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) {
         return thingsPerPos * (size - pos);
     }
 
-    /**
-     * Returns the size of the permutation
-     *
-     * @return the size of the permutation
-     */
     public int size() {
         return size;
     }
 
-    /**
-     * 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) {
         vals[pos]++;
         for(int i = pos + 1; i < size; i++) {
@@ -78,37 +40,19 @@ public class Permutation {
         }
     }
 
-    /**
-     * Returns the minimum cost stored in this Permutation
-     *
-     * @return the minimum cost stored in this Permutation
-     */
     public int getMinCost() {
         return minCost;
     }
 
-    /**
-     * Sets the minimum cost stored in this Permutation
-     *
-     * @param minCost the new minimum cost to be set
-     */
     public void setMinCost(int minCost) {
         this.minCost = minCost;
         minVals = vals.clone();
     }
 
-    /**
-     * Makes the current permutation the new minimum permutation to be stored
-     *
-     */
     public void makePermutMinimal() {
         vals = minVals.clone();
     }
 
-    /**
-     * Prints the current permutation
-     *
-     */
     public void printPermut() {
         for(int i = 0; i < size; i++) {
             System.out.print(vals[i] + " ");
@@ -116,10 +60,6 @@ public class Permutation {
         System.out.println();
     }
 
-    /**
-     * Prints the stored minimum permutation
-     *
-     */
     public void printMinPermut() {
         for(int i = 0; i < size; i++) {
             System.out.print(minVals[i] + " ");

+ 3 - 23
src/pathgame/algorithm/SaleRoute.java

@@ -2,39 +2,19 @@ package pathgame.algorithm;
 
 import java.util.ArrayList;
 
-/**
- * Class for storing one value of the Dijkstra results table
- *
- */
 public class SaleRoute {
-    private ArrayList<Coord> path;
-    private int totalCost;
+    private final ArrayList<Coord> path;
+    private final int totalCost;
 
-    /**
-     * 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
-     */
-    SaleRoute(ArrayList<Coord> path, int totalCost) {
+    public SaleRoute(ArrayList<Coord> path, int totalCost) {
         this.path = path;
         this.totalCost = totalCost;
     }
 
-    /**
-     * Returns a list of coordinates making up this path
-     *
-     * @return a list of coordinates making up this path
-     */
     public ArrayList<Coord> getPath() {
         return path;
     }
 
-    /**
-     * Returns the total cost of this path
-     *
-     * @return the total cost of this path
-     */
     public int getTotalCost() {
         return totalCost;
     }

+ 1 - 90
src/pathgame/algorithm/TravellingSalesAlg.java

@@ -5,50 +5,23 @@ 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
- *
- */
 public class TravellingSalesAlg {
-    /**
-     * 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
-     * @return
-     */
     public static int calcSalesPathLen(TileMap map, Player player) {
         DijkstraMagic dijkstra = new DijkstraMagic(map, player);
-
         ArrayList<ArrayList<SaleRoute>> salesPitch = dijkstra.getSalesPitch();
-
-        //make minimum spanning tree
         ArrayList<TreeEdge> MSTree = makeMSTree(salesPitch);
-
-        //find pairs-shortest path for verteces with odd degree and add those edges to MSTree
         ArrayList<TreeEdge> oddDegEdges = makeOddDegEdges(MSTree, salesPitch);
         MSTree.addAll(oddDegEdges);
-
-        //finde euler tour
         ArrayList<Integer> eulerTour = getEulerTour(MSTree);
-
-        //cut short
         cutShort(eulerTour);
-
-        //calculate the total weight of the tour using the edge table (salesPitch)
         int tourWeight = calcTourWeight(eulerTour, salesPitch);
         return tourWeight;
-
-        //brute force
-        //return bruteForce(salesPitch);
     }
 
     private static int calcTourWeight(ArrayList<Integer> tour, ArrayList<ArrayList<SaleRoute>> salesPitch) {
         int totalWeight = 0;
-
         for(int i = 0; i < tour.size() - 1; i++) {
             int startNode, endNode;
-
             if(tour.get(i) < tour.get(i + 1)) {
                 startNode = tour.get(i);
                 endNode = tour.get(i + 1) - startNode - 1;
@@ -63,19 +36,15 @@ public class TravellingSalesAlg {
 
     private static void cutShort(ArrayList<Integer> eulerTour) {
         int counter = 2;
-
         while(counter < eulerTour.size() - 1) {
             int current = eulerTour.get(counter);
-
             boolean found = false;
-
             for(int i = 0; i < counter; i++) {
                 if(eulerTour.get(i) == current) {
                     found = true;
                     break;
                 }
             }
-
             if(found) {
                 eulerTour.remove(counter);
             } else {
@@ -86,13 +55,11 @@ public class TravellingSalesAlg {
 
     private static ArrayList<Integer> getEulerTour(ArrayList<TreeEdge> graph) {
         ArrayList<Integer> tour = new ArrayList<>();
-
         while(graph.size() > 0) {
-            if(tour.size() == 0) {
+            if(tour.isEmpty()) {
                 tour = getSubtour(graph, graph.get(0).getSrc());
             } else {
                 int start = -1;
-
                 for(int e = 0; e < graph.size(); e++) {
                     TreeEdge edge = graph.get(e);
                     for(int tp = 0; tp < tour.size(); tp++) {
@@ -108,32 +75,26 @@ public class TravellingSalesAlg {
                         break;
                     }
                 }
-
                 ArrayList<Integer> subTour = getSubtour(graph, start);
-
                 mergeTours(tour, subTour);
             }
         }
-
         return tour;
     }
 
     private static ArrayList<Integer> getSubtour(ArrayList<TreeEdge> graph, int start) {
         ArrayList<Integer> tour = new ArrayList<>();
         tour.add(start);
-
         int pos = nextTourEdgePos(graph, start);
         int next = graph.get(pos).getOtherVertex(start);
         graph.remove(pos);
         tour.add(next);
-
         while(next != start) {
             pos = nextTourEdgePos(graph, next);
             next = graph.get(pos).getOtherVertex(next);
             graph.remove(pos);
             tour.add(next);
         }
-
         return tour;
     }
 
@@ -143,21 +104,17 @@ public class TravellingSalesAlg {
                 return i;
             }
         }
-
         return -1;
     }
 
     private static void mergeTours(ArrayList<Integer> tour, ArrayList<Integer> subTour) {
         int mergeTo = subTour.get(0);
-
         int mergePos = -1;
-
         for(int i = 0; i < tour.size(); i++) {
             if(tour.get(i) == mergeTo) {
                 mergePos = i;
             }
         }
-
         for(int i = subTour.size() - 1; i > 0; i--) {
             tour.add(mergePos + 1, subTour.get(i));
         }
@@ -165,40 +122,26 @@ public class TravellingSalesAlg {
 
     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++) {
             numOfEdges[msTree.get(i).getSrc()]++;
             numOfEdges[msTree.get(i).getDest()]++;
         }
-
         OddDegreeList oddDegs = new OddDegreeList();
-
         for(int i = 0; i < numOfEdges.length; i++) {
-            //System.out.println(numOfEdges[i]);
             if(numOfEdges[i] % 2 == 1) {
                 oddDegs.add(i);
             }
         }
-
         Permutation permut = new Permutation(oddDegs.size(), 2);
-
         calcPairShortest(oddDegs, salesPitch, permut, 0, 0);
         permut.makePermutMinimal();
-
-        //System.out.println(permut.tempCounter1);
-        //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++) {
             int offSet = permut.getValAtPos(i);
-
             addOddEdge(oddEdges, oddDegs, salesPitch, offSet);
         }
-
         addOddEdge(oddEdges, oddDegs, salesPitch, 0);
-
         return oddEdges;
     }
 
@@ -207,39 +150,24 @@ public class TravellingSalesAlg {
         oddDegs.makeOffsetUsed(0);
         int dest = oddDegs.getUnused(offSet);
         oddDegs.makeOffsetUsed(offSet);
-
         oddEdges.add(new TreeEdge(orig, dest, salesPitch.get(orig).get(dest - orig - 1).getTotalCost()));
     }
 
     private static void calcPairShortest(OddDegreeList oddDegs, ArrayList<ArrayList<SaleRoute>> salesPitch, Permutation permut, int permutPos, int costSoFar) {
         while(true) {
             int offSet;
-
             if(permutPos == permut.size()) {
                 offSet = 0;
             } else {
                 offSet = permut.getValAtPos(permutPos);
             }
-
             int orig = oddDegs.getUnused(0);
             int dest = oddDegs.getUnused(1 + offSet);
-
             int edgeWeight = salesPitch.get(orig).get(dest - orig - 1).getTotalCost();
             int newCost = costSoFar + edgeWeight;
-            //permut.tempCounter1++;
-
-            /*System.out.println();
-            System.out.println("permut pos: " + permutPos);
-            System.out.println(orig + " : " + dest);
-            System.out.println("newCost: " + newCost);
-            permut.printPermut();*/
             if(newCost < permut.getMinCost()) {
                 if(permutPos == permut.size()) {
                     permut.setMinCost(newCost);
-                    /*System.out.println();
-                    System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
-                    System.out.println("New Min: " + newCost);
-                    System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");*/
                 } else {
                     int used1 = oddDegs.makeOffsetUsed(0);
                     int used2 = oddDegs.makeOffsetUsed(offSet);
@@ -248,15 +176,12 @@ public class TravellingSalesAlg {
                     oddDegs.makeUnused(used2);
                 }
             }
-
             if(permutPos == permut.size()) {
-                //permut.tempCounter2++;
                 break;
             }
             if(permut.isPosAtMax(permutPos)) {
                 break;
             }
-
             permut.increaseAtPos(permutPos);
         }
     }
@@ -264,29 +189,19 @@ public class TravellingSalesAlg {
     private static ArrayList<TreeEdge> makeMSTree(ArrayList<ArrayList<SaleRoute>> salesPitch) {
         ArrayList<TreeEdge> allEdges = new ArrayList<>();
         ArrayList<TreeEdge> msTree = new ArrayList<>();
-
         int vertNum = salesPitch.size();
-
         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());
             }
         }
-
-        //System.out.println(vertNum);
         Collections.sort(allEdges);
-
         while(msTree.size() < vertNum - 1) {
-
             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());
             }
             allEdges.remove(0);
         }
-
         return msTree;
     }
 
@@ -296,7 +211,6 @@ public class TravellingSalesAlg {
             if(edge.getSrc() == vertex || edge.getDest() == vertex) {
                 if(!edge.isChecked()) {
                     edgeQ.add(edge);
-                    //System.out.println("src: " + edge.getSrc() + "; dest: " + edge.getDest());
                     edge.setChecked(true);
                 }
             }
@@ -307,9 +221,7 @@ public class TravellingSalesAlg {
         ArrayList<TreeEdge> edgeQ = new ArrayList<>();
         int dest = additon.getDest();
         resetEdges(tree);
-
         qEdges(tree, edgeQ, additon.getSrc());
-
         while(edgeQ.size() > 0) {
             TreeEdge edge = edgeQ.get(0);
             edgeQ.remove(0);
@@ -320,7 +232,6 @@ public class TravellingSalesAlg {
                 qEdges(tree, edgeQ, edge.getDest());
             }
         }
-
         return true;
     }
 

+ 3 - 49
src/pathgame/algorithm/TreeEdge.java

@@ -1,50 +1,25 @@
 package pathgame.algorithm;
 
-/**
- * Class that stores data for a graph edge
- *
- */
 public class TreeEdge implements Comparable< TreeEdge> {
-    private int src, dest, weight;
+    private final int src;
+    private final int dest;
+    private final int weight;
     private boolean checked = false;
 
-    /**
-     * 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
-     * @param weight the weight of the edge
-     */
     public TreeEdge(int src, int dest, int weight) {
         this.src = src;
         this.dest = dest;
         this.weight = weight;
     }
 
-    /**
-     * Returns the index of the source vertex of the edge
-     *
-     * @return the index of the source vertex of the edge
-     */
     public int getSrc() {
         return src;
     }
 
-    /**
-     * Returns the index of the destination vertex of the edge
-     *
-     * @return the index of the destination vertex of the edge
-     */
     public int getDest() {
         return dest;
     }
 
-    /**
-     * 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
-     */
     public int getOtherVertex(int other) {
         if(other == src) {
             return dest;
@@ -53,39 +28,18 @@ public class TreeEdge implements Comparable< TreeEdge> {
         }
     }
 
-    /**
-     * Returns the weight of the edge
-     *
-     * @return the weight of the edge
-     */
     public Integer getWeight() {
         return weight;
     }
 
-    /**
-     * Returns isChecked, which is true if the TreeEdge has been checked
-     *
-     * @return whether this TreeEdge has been checked
-     */
     public boolean isChecked() {
         return checked;
     }
 
-    /**
-     * Sets isChecked, which is true if the TreeEdge has been checked
-     *
-     * @param checked new status of whether this TreeEdge has been checked
-     */
     public void setChecked(boolean checked) {
         this.checked = checked;
     }
 
-    /**
-     * Used for sorting Collections of TreeEdges
-     *
-     * @param o the TreeEdge that this one is being compared to
-     * @return the result of compareTo()
-     */
     @Override
     public int compareTo(TreeEdge o) {
         return this.getWeight().compareTo(o.getWeight());

+ 9 - 21
src/pathgame/gameplay/Gamestate.java

@@ -1,38 +1,26 @@
 package pathgame.gameplay;
 
-/**
- * A container for the gamestate
- *
- * @author julia
- */
 public class Gamestate {
     private Gamestates state = Gamestates.MENU;
+    private boolean running = true;
 
-    /**
-     * Sets the current gamestate
-     *
-     * @param state the desired gamestate
-     */
     public void setState(Gamestates state) {
         this.state = state;
     }
 
-    /**
-     * Returns the current gamestate
-     *
-     * @return the current game state
-     */
     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
-     * @return if current gamestate is same as gamestate from parameter
-     */
     public boolean is(Gamestates gamestate) {
         return state == gamestate;
     }
+
+    public boolean isRunning() {
+        return running;
+    }
+
+    public void stop() {
+        running = false;
+    }
 }

+ 64 - 48
src/pathgame/gameplay/Keys.java

@@ -4,60 +4,76 @@ import java.io.DataInputStream;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
-import me.hammerle.snuviengine.api.KeyBinding;
-import me.hammerle.snuviengine.api.KeyHandler;
+import me.hammerle.snuviengine.api.Key;
 import org.lwjgl.glfw.GLFW;
 
-/**
- * A container for all keys
- *
- * @author julia
- */
 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);
-    public static final KeyBinding RIGHT_KEY = KeyHandler.register(GLFW.GLFW_KEY_D);
-    public static final KeyBinding ZOOM_IN_KEY = KeyHandler.register(GLFW.GLFW_KEY_I);
-    public static final KeyBinding ZOOM_OUT_KEY = KeyHandler.register(GLFW.GLFW_KEY_O);
-    public static final KeyBinding CONFIRM_KEY = KeyHandler.register(GLFW.GLFW_KEY_ENTER);
-    public static final KeyBinding ESCAPE_KEY = KeyHandler.register(GLFW.GLFW_KEY_ESCAPE);
-    public static final KeyBinding CAM_UP_KEY = KeyHandler.register(GLFW.GLFW_KEY_UP);
-    public static final KeyBinding CAM_DOWN_KEY = KeyHandler.register(GLFW.GLFW_KEY_DOWN);
-    public static final KeyBinding CAM_LEFT_KEY = KeyHandler.register(GLFW.GLFW_KEY_LEFT);
-    public static final KeyBinding CAM_RIGHT_KEY = KeyHandler.register(GLFW.GLFW_KEY_RIGHT);
-    public static final KeyBinding TEST_KEY = KeyHandler.register(GLFW.GLFW_KEY_T);
-    public static final KeyBinding OVERLAY_KEY = KeyHandler.register(GLFW.GLFW_KEY_TAB);
-    public static final KeyBinding BOAT_KEY = KeyHandler.register(GLFW.GLFW_KEY_E);
-
-    /**
-     * An array of all rebindable keys
-     */
-    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
+    public final Key up;
+    public final Key down;
+    public final Key left;
+    public final Key right;
+    public final Key zoomIn;
+    public final Key zoomOut;
+    public final Key confirm;
+    public final Key escape;
+    public final Key cameraUp;
+    public final Key cameraDown;
+    public final Key cameraLeft;
+    public final Key cameraRight;
+    public final Key test;
+    public final Key overlay;
+    public final Key boat;
+    
+    public final Key[] keys;
+    
+    public 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"
     };
-
-    /**
-     * 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"
-            };
-
-    static {
+    
+    private final me.hammerle.snuviengine.api.Keys engineKeys;
+    
+    public Keys(me.hammerle.snuviengine.api.Keys keys) {
+        engineKeys = keys;
+        up = keys.register(GLFW.GLFW_KEY_W);
+        down = keys.register(GLFW.GLFW_KEY_S);
+        left = keys.register(GLFW.GLFW_KEY_A);
+        right = keys.register(GLFW.GLFW_KEY_D);
+        zoomIn = keys.register(GLFW.GLFW_KEY_I);
+        zoomOut = keys.register(GLFW.GLFW_KEY_O);
+        confirm = keys.register(GLFW.GLFW_KEY_ENTER);
+        escape = keys.register(GLFW.GLFW_KEY_ESCAPE);
+        cameraUp = keys.register(GLFW.GLFW_KEY_UP);
+        cameraDown = keys.register(GLFW.GLFW_KEY_DOWN);
+        cameraLeft = keys.register(GLFW.GLFW_KEY_LEFT);
+        cameraRight = keys.register(GLFW.GLFW_KEY_RIGHT);
+        test = keys.register(GLFW.GLFW_KEY_T);
+        overlay = keys.register(GLFW.GLFW_KEY_TAB);
+        boat = keys.register(GLFW.GLFW_KEY_E);
+        
+        this.keys = new Key[]{
+            up, down, left, right, zoomIn, zoomOut,
+            cameraUp, cameraDown, cameraLeft,
+            cameraRight, overlay, boat
+        };
+        readConfig();
+    }
+    
+    private void readConfig() {
         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) {
-                    KeyHandler.rebind(KEYS[i], reader.readInt());
-                }
-            } catch(IOException ex) {
+        if(!f.exists()) {
+            return;
+        }
+        try(DataInputStream reader = new DataInputStream(new FileInputStream(f))) {
+            for(Key key : keys) {
+                engineKeys.rebind(key, reader.readInt());
             }
+        } catch(IOException ex) {
         }
     }
+    
+    public void rebind(Key key) {
+        engineKeys.rebindOnNextKeyPress(key);
+    }
 }

+ 3 - 57
src/pathgame/gameplay/Level.java

@@ -4,11 +4,6 @@ import pathgame.algorithm.TravellingSalesAlg;
 import pathgame.tilemap.TileMap;
 import pathgame.tilemap.TileMapGenerator;
 
-/**
- * A level of the game containing the current map and the current player
- *
- * @author julia
- */
 public final class Level {
     public final static float ALGORITHM_1 = 1.0f;
     public final static float ALGORITHM_2 = 1.1f;
@@ -22,42 +17,28 @@ public final class Level {
     private boolean showScoreMenu = false;
     private boolean showAfterScore = false;
 
-    /**
-     * Contructor generating and initializing new Level and Player
-     */
     public Level() {
         reset();
     }
 
-    /**
-     * 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, Keys keys) {
         map.tick();
         if(gamestate.is(Gamestates.GAMEPLAY) && !showScoreMenu) {
-            player.tick(map);
+            player.tick(map, keys);
         }
         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.getTime() == 1) {
             showScoreMenu = false;
             showAfterScore = true;
         }
     }
 
-    /**
-     * Loads the next level
-     */
     public void nextLevel() {
         level++;
         reset();
     }
 
-    /**
-     * Resets the current level
-     */
     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));
@@ -71,65 +52,30 @@ public final class Level {
         player.setEnergySupply(Math.round(algorithm * ALGORITHM_4));
     }
 
-    /**
-     * Returns the map of the current level
-     *
-     * @return the map of the current level
-     */
     public TileMap getMap() {
         return map;
     }
 
-    /**
-     * Returns the player of the current level
-     *
-     * @return the player of the current level
-     */
     public Player getPlayer() {
         return player;
     }
 
-    /**
-     * Returns the current level
-     *
-     * @return the current level
-     */
     public int getLevel() {
         return level;
     }
 
-    /**
-     * Returns the energy use of the algorithm
-     *
-     * @return the energy use of the algorithm
-     */
     public int getAlgorithmValue() {
         return algorithm;
     }
 
-    /**
-     * Returns if the AfterScoreMenu is showed
-     *
-     * @return if the AfterScoreMenu is showed
-     */
     public boolean isShowingAfterScore() {
         return showAfterScore;
     }
 
-    /**
-     * Sets if the AfterScoreMenu should be showed
-     *
-     * @param show sets if the AfterScore should be showed
-     */
     public void setShowAfterScore(boolean show) {
         showAfterScore = show;
     }
 
-    /**
-     * Returns if the ScoreMenu is showed
-     *
-     * @return if the ScoreMenu is showed
-     */
     public boolean isShowingScoreMenu() {
         return showScoreMenu;
     }

+ 0 - 25
src/pathgame/gameplay/MinusStepsValues.java

@@ -1,46 +1,21 @@
 package pathgame.gameplay;
 
-/**
- * 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 {
     private final int minusValue;
     private int lifeTime = 0;
 
-    /**
-     * Contructor initializing a new energyCost with a lifetime
-     *
-     * @param minusValue energyCost of a step of the player
-     */
     public MinusStepsValues(int minusValue) {
         this.minusValue = minusValue;
     }
 
-    /**
-     * Returns the energyCost value
-     *
-     * @return energyCost value
-     */
     public int getValue() {
         return minusValue;
     }
 
-    /**
-     * Returns the energyCost lifetime
-     *
-     * @return energyCost lifetime
-     */
     public int getLifeTime() {
         return lifeTime;
     }
 
-    /**
-     * Recalculates the lifetime every gametick and returns if energyCost is still alive
-     *
-     * @return if energyCost is still alive
-     */
     public boolean tick() {
         lifeTime++;
         return lifeTime >= 10;

+ 6 - 166
src/pathgame/gameplay/Player.java

@@ -6,11 +6,6 @@ import pathgame.tilemap.Tile;
 import pathgame.tilemap.TileMap;
 import pathgame.tilemap.Tiles;
 
-/**
- * A container for holding everything about the player
- *
- * @author julia
- */
 public class Player {
     private static final float SPEED = 0.25f;
 
@@ -39,45 +34,18 @@ public class Player {
 
     private Facing facing = Facing.SOUTH;
 
-    /**
-     * Constructor of the player
-     *
-     */
-    public Player() {
-    }
-
-    /**
-     * Returns x-position of the player of the last frame
-     *
-     * @return x-position of the player of the last frame
-     */
     public float getLastX() {
         return lastX;
     }
 
-    /**
-     * Returns y-position of the player of the last frame
-     *
-     * @return y-position of the player of the last frame
-     */
     public float getLastY() {
         return lastY;
     }
 
-    /**
-     * Returns current x-position of the player
-     *
-     * @return current x-position of the player
-     */
     public float getX() {
         return x;
     }
 
-    /**
-     * Returns current y-position of the player
-     *
-     * @return current y-position of the player
-     */
     public float getY() {
         return y;
     }
@@ -92,12 +60,7 @@ public class Player {
         }
     }
 
-    /**
-     * Recalculates the player position every gametick based on user input
-     *
-     * @param map the current map
-     */
-    public void tick(TileMap map) {
+    public void tick(TileMap map, Keys keys) {
         ticksLived++;
         tickSteps();
 
@@ -118,25 +81,25 @@ public class Player {
                 energyUsed += currSpeedSlowdown;
             }
             isMoving = false;
-            currentTile.isStandingOn(this, map, currentTileX, currentTileY);
+            currentTile.isStandingOn(this, map, currentTileX, currentTileY, keys);
         }
 
-        if(Keys.LEFT_KEY.isDown() && !isMoving && currentTileX > 0 && !map.getTile(currentTileX - 1, currentTileY).isBlockingMovement(this)) {
+        if(keys.left.isDown() && !isMoving && currentTileX > 0 && !map.getTile(currentTileX - 1, currentTileY).isBlockingMovement(this)) {
             facing = Facing.WEST;
             velX = -SPEED;
             isMoving = true;
             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.isDown() && !isMoving && currentTileX < map.getWidth() - 1 && !map.getTile(currentTileX + 1, currentTileY).isBlockingMovement(this)) {
             facing = Facing.EAST;
             velX = SPEED;
             isMoving = true;
             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.isDown() && !isMoving && currentTileY > 0 && !map.getTile(currentTileX, currentTileY - 1).isBlockingMovement(this)) {
             facing = Facing.NORTH;
             velY = -SPEED;
             isMoving = true;
             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.isDown() && !isMoving && currentTileY < map.getHeight() - 1 && !map.getTile(currentTileX, currentTileY + 1).isBlockingMovement(this)) {
             facing = Facing.SOUTH;
             velY = SPEED;
             isMoving = true;
@@ -178,163 +141,74 @@ public class Player {
         return Math.abs(x - Math.round(x)) < 0.01f && Math.abs(y - Math.round(y)) < 0.01f;
     }
 
-    /**
-     * Returns the current x-velocity of the player
-     *
-     * @return the current x-velocity of the player
-     */
     public float getVelX() {
         return velX;
     }
 
-    /**
-     * Returns the current y-velocity of the player
-     *
-     * @return the current y-velocity of the player
-     */
     public float getVelY() {
         return velY;
     }
 
-    /**
-     * Returns the overall energy supply of the player for the current map
-     *
-     * @return the overall energy supply of the player for the current map
-     */
     public int getEnergySupply() {
         return energySupply;
     }
 
-    /**
-     * Returns the current energy of the player that is left for the current map
-     *
-     * @return the current energy of the player that is left for the current map
-     */
     public int getEnergyLeft() {
         return energySupply - energyUsed;
     }
 
-    /**
-     * Returns the energy of the player that is already used for the current map
-     *
-     * @return the energy of the player that is already used for the current map
-     */
     public int getEnergyUsed() {
         return energyUsed;
     }
 
-    /**
-     * Returns the overall amount of objectives that the player has to visit
-     *
-     * @return the overall amount of objectives that the player has to visit
-     */
     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
-     */
     public void setObjectivesAmount(int objectivesAmount) {
         this.objectivesAmount = objectivesAmount;
     }
 
-    /**
-     * Returns the amount of objectives that the player has already to visited
-     *
-     * @return the amount of objectives that the player has already to visited
-     */
     public int getObjectivesVisited() {
         return objectivesVisited;
     }
 
-    /**
-     * Player visits a town and updates the player statistics
-     */
     public void visitTown() {
         objectivesVisited++;
     }
 
-    /**
-     * Returns a list of the last energy costs of the last steps of the player
-     *
-     * @return a list of the last energy costs of the last steps of the player
-     */
     public LinkedList<MinusStepsValues> getLastSteps() {
         return steps;
     }
 
-    /**
-     * Sets the abilities of the player
-     *
-     * @param playerAbilities sets the abilities of the player
-     */
     public void setAbilities(PlayerAbilities playerAbilities) {
         abilities = playerAbilities;
     }
 
-    /**
-     * Returns the abilities of the player
-     *
-     * @return the abilities of the player
-     */
     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
-     */
     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
-     *
-     * @return if player has already visited all towns and is allowed win when going to the start field
-     */
     public boolean canWin() {
         return objectivesVisited >= objectivesAmount;
     }
 
-    /**
-     * Returns if player has already won the current map
-     *
-     * @return if player has already won the current map
-     */
     public boolean hasWon() {
         return hasWon;
     }
 
-    /**
-     * Player wins and updates the player statistics
-     */
     public void win(TileMap map) {
         this.hasWon = true;
     }
 
-    /**
-     * Returns if player has lost the current map
-     *
-     * @return if player has lost the current map
-     */
     public boolean hasLost() {
         return energyUsed > energySupply || (currentTile != Tiles.HOME_TOWN && energyUsed == energySupply);
     }
 
-    /**
-     * Player is resetted
-     *
-     * @param sx start x-position
-     * @param sy start y-position
-     * @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) {
         ticksLived = 0;
 
@@ -358,64 +232,30 @@ public class Player {
         this.objectivesAmount = objectivesAmount;
     }
 
-    /**
-     * 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) {
         reset(sx, sy, 1000, 10);
     }
 
-    /**
-     * Returns if player is currently moving
-     *
-     * @return if player is currently moving
-     */
     public boolean isMoving() {
         return isMoving;
     }
 
-    /**
-     * Changes Player state to sailing
-     */
     public void switchSailing() {
         isSailing = !isSailing;
     }
 
-    /**
-     * Returns if player is currently sailing
-     *
-     * @return if player is currently sailing
-     */
     public boolean isSailing() {
         return isSailing;
     }
 
-    /**
-     * Returns the tile the player is currently standing on
-     *
-     * @return the tile the player is currently standing on
-     */
     public Tile getCurrTile() {
         return currentTile;
     }
 
-    /**
-     * Returns how much ticks this player is alive.
-     *
-     * @return how much ticks this player is alive
-     */
     public int getTicksLived() {
         return ticksLived;
     }
 
-    /**
-     * Returns the direction the player is facing.
-     *
-     * @return the direction the player is facing
-     */
     public Facing getFacing() {
         return facing;
     }

+ 1 - 60
src/pathgame/gameplay/PlayerAbilities.java

@@ -1,10 +1,5 @@
 package pathgame.gameplay;
 
-/**
- * A container for holding all player abilities
- *
- * @author julia
- */
 public class PlayerAbilities {
     private final String name;
     private final int fasterGrass;
@@ -15,18 +10,6 @@ public class PlayerAbilities {
     private final int fasterMountain;
     private final int fasterSwamp;
 
-    /**
-     * 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
-     */
     private PlayerAbilities(String name, int fasterGrass, int fasterForest, int fasterShallowWater,
             int fasterDeepWater, int fasterHill, int fasterMountain, int fasterSwamp) {
         this.name = name;
@@ -44,81 +27,39 @@ public class PlayerAbilities {
     public final static PlayerAbilities HUNTER = new PlayerAbilities("Hunter", 0, 1, 0, 0, 0, 0, 1);
     public final static PlayerAbilities SWIMMER = new PlayerAbilities("Swimmer", 0, 0, 3, 0, 0, 0, 0);
     public final static PlayerAbilities SAILOR = new PlayerAbilities("Sailor", 0, 0, 0, 1, 0, 0, 0);
-    /**
-     * Array of all character types
-     */
+
     public final static PlayerAbilities[] ABILITIES = new PlayerAbilities[]{
         NORMAL, HIKER, HUNTER, SWIMMER, SAILOR
     };
 
-    /**
-     * Returns the energyCostPoints the player is faster on grass tiles
-     *
-     * @return the energyCostPoints the player is faster on grass tiles
-     */
     public int getFasterGrass() {
         return fasterGrass;
     }
 
-    /**
-     * Returns the energyCostPoints the player is faster on forest tiles
-     *
-     * @return the energyCostPoints the player is faster on forest tiles
-     */
     public int getFasterForest() {
         return fasterForest;
     }
 
-    /**
-     * Returns the energyCostPoints the player is faster on shallow water tiles
-     *
-     * @return the energyCostPoints the player is faster on shallow water tiles
-     */
     public int getFasterShallowWater() {
         return fasterShallowWater;
     }
 
-    /**
-     * Returns the energyCostPoints the player is faster on deep water tiles
-     *
-     * @return the energyCostPoints the player is faster on deep water tiles
-     */
     public int getFasterDeepWater() {
         return fasterDeepWater;
     }
 
-    /**
-     * Returns the energyCostPoints the player is faster on hill tiles
-     *
-     * @return the energyCostPoints the player is faster on hill tiles
-     */
     public int getFasterHill() {
         return fasterHill;
     }
 
-    /**
-     * Returns the energyCostPoints the player is faster on mountain tiles
-     *
-     * @return the energyCostPoints the player is faster on mountain tiles
-     */
     public int getFasterMountain() {
         return fasterMountain;
     }
 
-    /**
-     * Returns the energyCostPoints the player is faster on swamp tiles
-     *
-     * @return the energyCostPoints the player is faster on swamp tiles
-     */
     public int getFasterSwamp() {
         return fasterSwamp;
     }
 
-    /**
-     * Returns the name of the current character type
-     *
-     * @return the name of the current character type
-     */
     public String getName() {
         return name;
     }

+ 3 - 23
src/pathgame/gameplay/menu/AfterScoreMenu.java

@@ -2,53 +2,33 @@ package pathgame.gameplay.menu;
 
 import pathgame.gameplay.Gamestates;
 
-/**
- * A container for holding all options of the AfterScoreMenu
- *
- * @author julia
- */
 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) {
         super(id);
 
         options = new MenuButton[]{
-            new MenuButton("Next Level", (gamestate, level)
-            -> {
+            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);
             }),};
     }
 
-    /**
-     * Returns the options of the AfterScoreMenu
-     *
-     * @return the options of the AfterScoreMenu
-     */
     @Override
     public MenuButton[] getOptions() {
         return options;
     }
-
 }

+ 6 - 51
src/pathgame/gameplay/menu/BaseMenu.java

@@ -1,15 +1,10 @@
 package pathgame.gameplay.menu;
 
-import me.hammerle.snuviengine.api.KeyBinding;
+import me.hammerle.snuviengine.api.Key;
 import pathgame.gameplay.Gamestate;
 import pathgame.gameplay.Keys;
 import pathgame.gameplay.Level;
 
-/**
- * Base class of the menus
- *
- * @author julia
- */
 public abstract class BaseMenu {
     private final int id;
     private int index = 0;
@@ -17,49 +12,26 @@ public abstract class BaseMenu {
     public abstract MenuButton[] getOptions();
     private int returnId;
 
-    /**
-     * Contructor generating and initializing the menu
-     *
-     * @param id the id of the desired menu
-     */
     public BaseMenu(int id) {
         this.id = id;
     }
 
-    /**
-     * Returns the index of the active menu button
-     *
-     * @return the index of the active menu button
-     */
     public int getActiveIndex() {
         return index;
     }
 
-    /**
-     * Returns if this is the OptionMenu
-     *
-     * @return if this is the OptionMenu
-     */
     public boolean isOptionMenu() {
         return false;
     }
 
-    /**
-     * 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, Keys keys) {
         returnId = id;
-        if(isKeyPressed(Keys.UP_KEY) || isKeyPressed(Keys.CAM_UP_KEY)) {
+        if(isKeyPressed(keys.up) || isKeyPressed(keys.cameraUp)) {
             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) || isKeyPressed(keys.cameraDown)) {
             index = (index + 1) % getOptions().length;
-        } else if(isKeyPressed(Keys.CONFIRM_KEY)) {
+        } else if(isKeyPressed(keys.confirm)) {
             getOptions()[index].run(gamestate, level);
         }
         if(returnId != id) {
@@ -68,32 +40,15 @@ public abstract class BaseMenu {
         return returnId;
     }
 
-    /**
-     * Sets the id of the current menu
-     *
-     * @param id the id of the current menu
-     *
-     */
     public void setReturnId(int id) {
         returnId = id;
     }
 
-    /**
-     * Resets the index of the current button to the first button
-     *
-     */
     public void resetIndex() {
         index = 0;
     }
 
-    /**
-     * Returns if the key of the parameter is pressed
-     *
-     * @param key the key that is checked
-     * @return if the key is pressed
-     */
-    private boolean isKeyPressed(KeyBinding key) {
+    private boolean isKeyPressed(Key key) {
         return key.getTime() == 1 || (key.getTime() >= 20 && key.getTime() % 5 == 1);
     }
-
 }

+ 2 - 22
src/pathgame/gameplay/menu/CharacterMenu.java

@@ -3,46 +3,26 @@ package pathgame.gameplay.menu;
 import pathgame.gameplay.Gamestates;
 import pathgame.gameplay.PlayerAbilities;
 
-/**
- * A container for holding all options of the CharacterMenu
- *
- * @author julia
- */
 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) {
         super(id);
         options = new MenuButton[PlayerAbilities.ABILITIES.length + 1];
         for(int i = 0; i < options.length - 1; ++i) {
             options[i] = getAbilityOption(PlayerAbilities.ABILITIES[i]);
         }
-        options[options.length - 1] = new MenuButton("Back", (gamestate)
-                -> {
-            setReturnId(mainId);
-        });
+        options[options.length - 1] = new MenuButton("Back", (gamestate) -> setReturnId(mainId));
     }
 
     private static MenuButton getAbilityOption(PlayerAbilities pa) {
-        return new MenuButton(pa.getName(), (gamestate, level)
-                -> {
+        return new MenuButton(pa.getName(), (gamestate, level) -> {
             level.reset();
             level.getPlayer().setAbilities(pa);
             gamestate.setState(Gamestates.GAMEPLAY);
         });
     }
 
-    /**
-     * Returns the options of the CharacterMenu
-     *
-     * @return the options of the CharacterMenu
-     */
     @Override
     public MenuButton[] getOptions() {
         return options;

+ 6 - 22
src/pathgame/gameplay/menu/EscMenu.java

@@ -1,43 +1,27 @@
 package pathgame.gameplay.menu;
 
-import me.hammerle.snuviengine.api.Engine;
 import pathgame.gameplay.Gamestates;
 
-/**
- * A container for holding all options of the EscapeMenu
- *
- * @author julia
- */
 public class EscMenu extends BaseMenu {
     private final MenuButton[] options;
 
-    /**
-     * Contructor generating and initializing the EscapeMenu
-     *
-     * @param id the id of the EscapeMenu
-     * @param mainId the id to the MainMenu
-     */
     public EscMenu(int id, int mainId) {
         super(id);
 
         options = new MenuButton[]{
-            new MenuButton("Continue", (gamestate)
-            -> {
+            new MenuButton("Continue", (gamestate) -> {
                 gamestate.setState(Gamestates.GAMEPLAY);
             }),
-            new MenuButton("Retry", (gamestate, level)
-            -> {
+            new MenuButton("Retry", (gamestate, level) -> {
                 level.reset();
                 gamestate.setState(Gamestates.GAMEPLAY);
             }),
-            new MenuButton("Main Menu", (gamestate)
-            -> {
+            new MenuButton("Main Menu", (gamestate) -> {
                 setReturnId(mainId);
             }),
-            new MenuButton("Exit", (gamestate)
-            -> {
-                Engine.stop();
-            }),};
+            new MenuButton("Exit", (gamestate) -> {
+                gamestate.stop();
+            })};
     }
 
     /**

+ 3 - 31
src/pathgame/gameplay/menu/MainMenu.java

@@ -1,46 +1,18 @@
 package pathgame.gameplay.menu;
 
-import me.hammerle.snuviengine.api.Engine;
-
-/**
- * A container for holding all options of the MainMenu
- *
- * @author julia
- */
 public class MainMenu extends BaseMenu {
     private final MenuButton[] options;
 
-    /**
-     * Contructor generating and initializing the MainMenu
-     *
-     * @param id the id of the MainMenu
-     * @param optionsId the id to the OptionMenu
-     * @param characterId the id to the CharacterMenu
-     */
     public MainMenu(int id, int optionsId, int characterId) {
         super(id);
 
         options = new MenuButton[]{
-            new MenuButton("Start", (gamestate)
-            -> {
-                setReturnId(characterId);
-            }),
-            new MenuButton("Options", (gamestate)
-            -> {
-                setReturnId(optionsId);
-            }),
-            new MenuButton("Exit", (gamestate)
-            -> {
-                Engine.stop();
-            })
+            new MenuButton("Start", (gamestate) -> setReturnId(characterId)),
+            new MenuButton("Options", (gamestate) -> setReturnId(optionsId)),
+            new MenuButton("Exit", (gamestate) -> gamestate.stop())
         };
     }
 
-    /**
-     * Returns the options of the MainMenu
-     *
-     * @return the options of the MainMenu
-     */
     @Override
     public MenuButton[] getOptions() {
         return options;

+ 17 - 43
src/pathgame/gameplay/menu/Menu.java

@@ -5,11 +5,6 @@ import pathgame.gameplay.Gamestates;
 import pathgame.gameplay.Keys;
 import pathgame.gameplay.Level;
 
-/**
- * A container for holding and manages all kinds of menus
- *
- * @author julia
- */
 public class Menu {
     private final static int MAIN_ID;
     private final static int ESCAPE_ID;
@@ -26,32 +21,30 @@ public class Menu {
         AFTER_SCORE_ID = id++;
     }
 
-    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),
-        new CharacterMenu(CHARACTER_ID, MAIN_ID),
-        new AfterScoreMenu(AFTER_SCORE_ID, MAIN_ID)
-    };
+    private final BaseMenu[] menus;
 
     private int currentIndex = 0;
 
-    /**
-     * Updates the menu state every gametick based on user input
-     *
-     * @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) {
-            currentIndex = menus[currentIndex].tick(gamestate, level);
-            if(currentIndex == ESCAPE_ID && Keys.ESCAPE_KEY.getTime() == 1) {
+    public Menu(Keys keys) {
+        menus = new BaseMenu[]{
+            new MainMenu(MAIN_ID, OPTION_ID, CHARACTER_ID),
+            new EscMenu(ESCAPE_ID, MAIN_ID),
+            new OptionMenu(OPTION_ID, MAIN_ID, keys),
+            new CharacterMenu(CHARACTER_ID, MAIN_ID),
+            new AfterScoreMenu(AFTER_SCORE_ID, MAIN_ID)
+        };
+    }
+
+    public void tick(Gamestate gamestate, Level level, Keys keys) {
+        if(gamestate.is(Gamestates.MENU)) {
+            currentIndex = menus[currentIndex].tick(gamestate, level, keys);
+            if(currentIndex == ESCAPE_ID && keys.escape.getTime() == 1) {
                 gamestate.setState(Gamestates.GAMEPLAY);
             } else if((currentIndex == OPTION_ID || currentIndex == CHARACTER_ID)
-                    && Keys.ESCAPE_KEY.getTime() == 1) {
+                    && keys.escape.getTime() == 1) {
                 currentIndex = MAIN_ID;
             }
-        } else if(gamestate.getState() == Gamestates.GAMEPLAY && Keys.ESCAPE_KEY.getTime() == 1) {
+        } else if(gamestate.is(Gamestates.GAMEPLAY) && keys.escape.getTime() == 1) {
             currentIndex = ESCAPE_ID;
             gamestate.setState(Gamestates.MENU);
             menus[currentIndex].resetIndex();
@@ -62,37 +55,18 @@ public class Menu {
         }
     }
 
-    /**
-     * Returns the array of menu buttons of the menu
-     *
-     * @return the array of menu buttons of the menu
-     */
     public MenuButton[] getOptions() {
         return menus[currentIndex].getOptions();
     }
 
-    /**
-     * Returns the index of the active menu button
-     *
-     * @return the index of the active menu button
-     */
     public int getActiveIndex() {
         return menus[currentIndex].getActiveIndex();
     }
 
-    /**
-     * Returns if this is the OptionMenu
-     *
-     * @return if this is the OptionMenu
-     */
     public boolean isOptionMenu() {
         return menus[currentIndex].isOptionMenu();
     }
 
-    /**
-     * Opens the escape menu
-     *
-     */
     public void showEscapeMenu() {
         currentIndex = ESCAPE_ID;
     }

+ 0 - 28
src/pathgame/gameplay/menu/MenuButton.java

@@ -5,51 +5,23 @@ import java.util.function.Consumer;
 import pathgame.gameplay.Gamestate;
 import pathgame.gameplay.Level;
 
-/**
- * A container for holding everything about a menu button
- *
- * @author julia
- */
 public class MenuButton {
     private final String name;
     private final BiConsumer<Gamestate, Level> r;
 
-    /**
-     * Contructor initializing a menu button
-     *
-     * @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) {
         this.name = name;
         this.r = r;
     }
 
-    /**
-     * Contructor initializing a menu button
-     *
-     * @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) {
         this(name, (gamestate, level) -> r.accept(gamestate));
     }
 
-    /**
-     * Returns the name of the button
-     *
-     * @return the name of the button
-     */
     public String getName() {
         return name;
     }
 
-    /**
-     * runs the button function
-     *
-     * @param gamestate the gamestate
-     * @param level the current level
-     */
     public void run(Gamestate gamestate, Level level) {
         r.accept(gamestate, level);
     }

+ 8 - 20
src/pathgame/gameplay/menu/OptionMenu.java

@@ -4,36 +4,24 @@ import java.io.File;
 import java.io.FileOutputStream;
 import java.io.DataOutputStream;
 import java.io.IOException;
-import me.hammerle.snuviengine.api.KeyBinding;
-import me.hammerle.snuviengine.api.KeyHandler;
+import me.hammerle.snuviengine.api.Key;
 import pathgame.gameplay.Keys;
 
-/**
- * A container for holding all options of the OptionMenu
- *
- * @author julia
- */
 public class OptionMenu extends BaseMenu {
     private final MenuButton[] options;
 
-    /**
-     * Contructor generating and initializing the OptionMenu
-     *
-     * @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, Keys keys) {
         super(id);
-        int menuLength = Keys.KEYS.length;
+        int menuLength = keys.keys.length;
         options = new MenuButton[menuLength + 1];
         for(int i = 0; i < menuLength; ++i) {
-            options[i] = getButton(Keys.KEYNAMES[i], Keys.KEYS[i]);
+            options[i] = getButton(keys.keyNames[i], keys, keys.keys[i]);
         }
         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) {
-                    writer.writeInt(Keys.KEYS[i].getKey());
+                for(int i = 0; i < keys.keys.length; ++i) {
+                    writer.writeInt(keys.keys[i].getKey());
                 }
             } catch(IOException ex) {
             }
@@ -41,9 +29,9 @@ public class OptionMenu extends BaseMenu {
         });
     }
 
-    private MenuButton getButton(String name, KeyBinding key) {
+    private MenuButton getButton(String name, Keys keys, Key key) {
         return new MenuButton(name, (gamestate) -> {
-            KeyHandler.rebind(key);
+            keys.rebind(key);
         });
     }
 

+ 7 - 51
src/pathgame/rendering/Camera.java

@@ -5,11 +5,6 @@ import pathgame.gameplay.Gamestates;
 import pathgame.gameplay.Keys;
 import pathgame.gameplay.Level;
 
-/**
- * A container for all camera specific functions
- *
- * @author julia
- */
 public class Camera {
     private final static int CAM_SPEED = 64;
 
@@ -21,44 +16,33 @@ public class Camera {
     private float camOffsetX = 0.0f;
     private float camOffsetY = 0.0f;
 
-    /**
-     * Recalculates the camera position every gametick based on user input
-     *
-     * @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, Keys keys) {
         lastCamOffsetX = camOffsetX;
         lastCamOffsetY = camOffsetY;
         lastScale = scale;
 
         if(!level.getPlayer().isMoving() && gamestate.is(Gamestates.GAMEPLAY)) {
-            if(Keys.ZOOM_IN_KEY.isDown()) {
+            if(keys.zoomIn.isDown()) {
                 scale *= 1.1f;
-            } else if(Keys.ZOOM_OUT_KEY.isDown()) {
+            } else if(keys.zoomOut.isDown()) {
                 scale /= 1.1f;
             }
 
-            if(Keys.CAM_UP_KEY.isDown()) {
+            if(keys.cameraUp.isDown()) {
                 camOffsetY += CAM_SPEED;
             }
-            if(Keys.CAM_DOWN_KEY.isDown()) {
+            if(keys.cameraDown.isDown()) {
                 camOffsetY -= CAM_SPEED;
             }
-            if(Keys.CAM_LEFT_KEY.isDown()) {
+            if(keys.cameraLeft.isDown()) {
                 camOffsetX += CAM_SPEED;
             }
-            if(Keys.CAM_RIGHT_KEY.isDown()) {
+            if(keys.cameraRight.isDown()) {
                 camOffsetX -= CAM_SPEED;
             }
         }
     }
 
-    /**
-     * Limits scale of camera
-     *
-     * @param zoomRestriction the lower zoom factor restriction (zooming out restriction)
-     */
     public void limitScale(float zoomRestriction) {
         if(scale <= zoomRestriction) {
             scale = zoomRestriction;
@@ -69,10 +53,6 @@ public class Camera {
 
     }
 
-    /**
-     * Resetting the camera to focus the player
-     *
-     */
     public void reset() {
         camOffsetX = 0.0f;
         camOffsetY = 0.0f;
@@ -80,25 +60,10 @@ public class Camera {
         lastCamOffsetY = 0.0f;
     }
 
-    /**
-     * Returns the interpolated scale
-     *
-     * @param lag the render lag
-     * @return the interpolated scale
-     */
     public float getInterpolatedScale(float lag) {
         return lastScale + (scale - lastScale) * lag;
     }
 
-    /**
-     * 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 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) {
         float interCamX = lastCamOffsetX + (camOffsetX - lastCamOffsetX) * lag;
         if(offX + interCamX > 0.0f) {
@@ -118,15 +83,6 @@ public class Camera {
         return offX + interCamX;
     }
 
-    /**
-     * 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 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) {
         float interCamY = lastCamOffsetY + (camOffsetY - lastCamOffsetY) * lag;
         if(offY + interCamY > 0.0f) {

+ 6 - 20
src/pathgame/rendering/HUDRenderer.java

@@ -6,25 +6,11 @@ import me.hammerle.snuviengine.api.Texture;
 import pathgame.gameplay.MinusStepsValues;
 import pathgame.gameplay.Player;
 
-/**
- * A container for holding everything about the renderer for the Head-Up-Display
- *
- * @author julia
- */
 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
-     *
-     * @param r the renderer
-     * @param p the current player
-     * @param lag the current lag
-     */
-    public void renderTick(Renderer r, Player p, float lag)//TileMap map, TileMapRenderer map, float lag, float offX, float offY)
-    {
+    public void renderTick(Renderer r, Player p, float lag) {
         r.translateTo(0.0f, 0.0f);
         r.scale(2.0f, 2.0f);
         r.updateMatrix();
@@ -40,9 +26,9 @@ public class HUDRenderer {
         r.setMixColorEnabled(true);
         r.setColorEnabled(true);
         r.setTextureEnabled(false);
-        r.setBlendingEnabled(true);
+        r.enableBlending();
 
-        r.getColorRenderer().drawRectangle(0, 0, r.getViewWidth(), 20, 0xFF_00_00_00);//ABGR
+        r.getColorRenderer().drawRectangle(0, 0, r.getViewWidth(), 20, 0xFF_00_00_00);
     }
 
     private void renderObjectiveTracker(Renderer r, Player p) {
@@ -63,7 +49,7 @@ public class HUDRenderer {
 
         r.getFontRenderer().drawString(
                 r.getViewWidth() * 0.5f
-                - r.getFontRenderer().getSize(energy).getWidth() - 15,
+                - r.getFontRenderer().getSize(energy).getStringWidth() - 15,
                 6, energy);
     }
 
@@ -71,7 +57,7 @@ public class HUDRenderer {
         r.setMixColorEnabled(true);
         r.setColorEnabled(false);
         r.setTextureEnabled(true);
-        r.setBlendingEnabled(true);
+        r.enableBlending();
 
         float energyPercent = 100 / (float) p.getEnergySupply() * (float) p.getEnergyLeft() / 100;
         if(energyPercent < 0) {
@@ -90,7 +76,7 @@ public class HUDRenderer {
 
         LinkedList<MinusStepsValues> steps = p.getLastSteps();
         for(MinusStepsValues step : steps) {
-            String minusEnergy = String.format("&4-%d", step.getValue());
+            String minusEnergy = String.format("#AA0000-%d", step.getValue());
             r.getFontRenderer().drawString(r.getViewWidth() * 0.5f - 63, 9 + step.getLifeTime() + lag, minusEnergy);
         }
     }

+ 5 - 25
src/pathgame/rendering/LevelRenderer.java

@@ -3,15 +3,11 @@ package pathgame.rendering;
 import me.hammerle.snuviengine.api.Renderer;
 import pathgame.gameplay.Gamestate;
 import pathgame.gameplay.Gamestates;
+import pathgame.gameplay.Keys;
 import pathgame.gameplay.Level;
 import pathgame.gameplay.Player;
 import pathgame.tilemap.TileMap;
 
-/**
- * A container for holding everything about the renderer for the player
- *
- * @author julia
- */
 public class LevelRenderer {
     private final PlayerRenderer playerRenderer = new PlayerRenderer();
     private final TileMapRenderer mapRenderer = new TileMapRenderer();
@@ -19,30 +15,15 @@ public class LevelRenderer {
     private final Camera cam = new Camera();
     private final ScoreMenuRenderer scoreRenderer = new ScoreMenuRenderer();
 
-    /**
-     * 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) {
-        cam.tick(level, gamestate);
+    public void tick(Level level, Gamestate gamestate, Keys keys) {
+        cam.tick(level, gamestate, keys);
         mapRenderer.tick();
         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
-     *
-     * @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) {
+    public void renderTick(Renderer r, float lag, Level level, Gamestate gamestate, Keys keys) {
         if(level.isShowingAfterScore() || level.isShowingScoreMenu()) {
             lag = 0.0f;
         }
@@ -60,7 +41,7 @@ public class LevelRenderer {
         float offX = getMapOffsetX(map, player, r, lag, interScale);
         float offY = getMapOffsetY(map, player, r, lag, interScale) + HUDRenderer.OFFSET_Y;
 
-        mapRenderer.renderTick(map, r, player, false, offX, offY);
+        mapRenderer.renderTick(map, r, player, false, offX, offY, keys);
 
         if(gamestate.is(Gamestates.GAMEPLAY)) {
             playerRenderer.renderTick(map, mapRenderer, r, player, lag, offX, offY);
@@ -70,7 +51,6 @@ public class LevelRenderer {
                 scoreRenderer.renderTick(r, lag, level);
             }
         }
-
     }
 
     private float getMapOffsetX(TileMap map, Player player, Renderer r, float lag, float interScale) {

+ 15 - 24
src/pathgame/rendering/MenuRenderer.java

@@ -1,28 +1,19 @@
 package pathgame.rendering;
 
-import me.hammerle.snuviengine.api.KeyBinding;
+import me.hammerle.snuviengine.api.Key;
 import me.hammerle.snuviengine.api.Renderer;
 import pathgame.gameplay.Keys;
 import pathgame.gameplay.menu.Menu;
 import pathgame.gameplay.menu.MenuButton;
 
-/**
- * A container for holding everything about the renderer for the menus
- *
- * @author julia
- */
 public class MenuRenderer {
-    private final float keyWidths[] = new float[Keys.KEYS.length];
+    private final float[] keyWidths;
 
-    /**
-     * 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 MenuRenderer(Keys keys) {
+        keyWidths = new float[keys.keys.length];
+    }
+
+    public void renderTick(Renderer r, float lag, Menu menu, Keys keys) {
         r.translateTo(0.0f, 0.0f);
         float scale = 2.0f;
         r.scale(scale, scale);
@@ -39,12 +30,12 @@ public class MenuRenderer {
 
         float y = (windowHeight - baseBoxHeight) * 0.5f + textBoxPaddingY;
         float textBoxHeight = baseBoxHeight - textBoxPaddingY * 2;
-        float step = (textBoxHeight - r.getFontRenderer().getHeight()) / (options.length - 1) - lastGap / (options.length - 2);
+        float step = (textBoxHeight - r.getFontRenderer().getCharHeight()) / (options.length - 1) - lastGap / (options.length - 2);
 
         r.setMixColorEnabled(false);
         r.setColorEnabled(true);
         r.setTextureEnabled(false);
-        r.setBlendingEnabled(true);
+        r.enableBlending();
 
         r.getColorRenderer().drawRectangle(windowWidth * 0.10f, y - textBoxPaddingY * 0.5f, windowWidth * 0.90f, y + textBoxHeight + textBoxPaddingY * 0.5f, 0x50000000);
 
@@ -59,8 +50,8 @@ public class MenuRenderer {
             renderText(options[options.length - 1].getName(), menu.getActiveIndex() == options.length - 1, r, windowWidth, y, false);
         } else {
             float max = Float.MIN_VALUE;
-            for(int i = 0; i < Keys.KEYS.length; i++) {
-                keyWidths[i] = r.getFontRenderer().getSize(getKeyName(Keys.KEYS[i])).getWidth();
+            for(int i = 0; i < keys.keys.length; i++) {
+                keyWidths[i] = r.getFontRenderer().getSize(getKeyName(keys.keys[i])).getStringWidth();
                 if(keyWidths[i] > max) {
                     max = keyWidths[i];
                 }
@@ -69,7 +60,7 @@ public class MenuRenderer {
             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));
+                r.getFontRenderer().drawString(windowWidth * 0.85f - max * 0.5f - keyWidths[i] * 0.5f, y, addColor(getKeyName(keys.keys[i]), active));
                 y += step;
             }
             y += lastGap;
@@ -81,15 +72,15 @@ public class MenuRenderer {
         if(left) {
             r.getFontRenderer().drawString(wWidth * 0.15f, y, addColor(s, active));
         } else {
-            r.getFontRenderer().drawString(wWidth * 0.5f - (r.getFontRenderer().getSize(s).getWidth() * 0.5f), y, addColor(s, active));
+            r.getFontRenderer().drawString(wWidth * 0.5f - (r.getFontRenderer().getSize(s).getStringWidth() * 0.5f), y, addColor(s, active));
         }
     }
 
     private String addColor(String s, boolean active) {
-        return (active ? "&f" : "&7") + s;
+        return (active ? "#FFFFFF" : "#AAAAAA") + s;
     }
 
-    private String getKeyName(KeyBinding key) {
+    private String getKeyName(Key key) {
         if(key.isRebinding()) {
             return "[...]";
         } else {

+ 0 - 23
src/pathgame/rendering/PlayerRenderer.java

@@ -7,11 +7,6 @@ import pathgame.gameplay.PlayerAbilities;
 import pathgame.tilemap.TileMap;
 import pathgame.tilemap.TileRenderType;
 
-/**
- * A container for holding everything about the renderer for the player
- *
- * @author julia
- */
 public class PlayerRenderer {
     private static final Texture CHARACTER = new Texture("resources/character.png");
     private static final Texture CHARACTER_HIKER = new Texture("resources/hiker.png");
@@ -19,18 +14,6 @@ public class PlayerRenderer {
     private static final Texture CHARACTER_SAILOR = new Texture("resources/sailor.png");
     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
-     *
-     * @param map the current map
-     * @param mapR the map renderer
-     * @param r the renderer
-     * @param p the current player
-     * @param lag the current lag
-     * @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) {
         boolean inWater = p.getCurrTile().getRenderType() == TileRenderType.WATER;
         float playerSize = mapR.getScale() * TileRenderer.TILE_SIZE;
@@ -59,25 +42,19 @@ public class PlayerRenderer {
         bindTexture(p, inWater);
 
         if(p.getVelX() > 0) {
-            //go right
             yIndex = 2;
             tIndex = checkForAnimationIndex(baseX);
         } else if(p.getVelX() < 0) {
-            //go left
             yIndex = 1;
             tIndex = checkForAnimationIndex(baseX);
         } else if(p.getVelY() > 0) {
-            //go down
             yIndex = 0;
             tIndex = checkForAnimationIndex(baseY);
         } else if(p.getVelY() < 0) {
-            //go up
             yIndex = 3;
             tIndex = checkForAnimationIndex(baseY);
         } else {
-            //stand still
             yIndex = p.getFacing().getIndex();
-            // idle animation on water
             if(inWater && (p.getTicksLived() % 20) < 10) {
                 tIndex = 1;
             }

+ 5 - 19
src/pathgame/rendering/ScoreMenuRenderer.java

@@ -4,20 +4,7 @@ import me.hammerle.snuviengine.api.Renderer;
 import pathgame.gameplay.Level;
 import pathgame.gameplay.Player;
 
-/**
- * A container for holding everything about the renderer for the score menu
- *
- * @author julia
- */
 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
-     *
-     * @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) {
         float windowWidth = r.getViewWidth();
         float windowHeight = r.getViewHeight();
@@ -26,7 +13,7 @@ public class ScoreMenuRenderer {
         r.setMixColorEnabled(false);
         r.setColorEnabled(true);
         r.setTextureEnabled(false);
-        r.setBlendingEnabled(true);
+        r.enableBlending();
         r.getColorRenderer().drawRectangle(paddingX, paddingY, windowWidth - paddingX, windowHeight - paddingY, 0x90000000);
 
         r.setTextureEnabled(true);
@@ -34,7 +21,7 @@ public class ScoreMenuRenderer {
         float scale = scale(r, 1);
 
         Player p = level.getPlayer();
-        String message = String.format("&2%d&f of &2%d&f Energy used",
+        String message = String.format("#00AA00%d#FFFFFF of #00AA00%d#FFFFFF Energy used",
                 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);
@@ -51,17 +38,16 @@ public class ScoreMenuRenderer {
         }
         r.getFontRenderer().drawString((windowWidth * scale - getWidth(r, message)) / 2, (windowHeight * scale - getHeight(r, message)) / 2, message);
 
-        message = "[&7PRESS ENTER&f]";
+        message = "[#AAAAAAPRESS ENTER#FFFFFF]";
         r.getFontRenderer().drawString((windowWidth * scale - getWidth(r, message)) / 2, (windowHeight * scale - paddingY * scale - getHeight(r, message)) - 10, message);
-
     }
 
     private float getWidth(Renderer r, String s) {
-        return r.getFontRenderer().getSize(s).getWidth();
+        return r.getFontRenderer().getSize(s).getStringWidth();
     }
 
     private float getHeight(Renderer r, String s) {
-        return r.getFontRenderer().getSize(s).getHeight();
+        return r.getFontRenderer().getSize(s).getStringHeight();
     }
 
     private float scale(Renderer r, int scale) {

+ 4 - 15
src/pathgame/rendering/StaticTextureProvider.java

@@ -3,26 +3,15 @@ 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}.
- *
- * @author kajetan
- */
 public class StaticTextureProvider implements TileTextureProvider {
-    private final TileTexture tt;
+    private final TileTexture tileTexture;
 
-    /**
-     * Creates a new static texture provider.
-     *
-     * @param tt a tile texture
-     */
-    public StaticTextureProvider(TileTexture tt) {
-        this.tt = tt;
+    public StaticTextureProvider(TileTexture tileTexture) {
+        this.tileTexture = tileTexture;
     }
 
     @Override
     public TileTexture getTexture(TileMap map, Tile t, int x, int y) {
-        return tt;
+        return tileTexture;
     }
 }

+ 18 - 79
src/pathgame/rendering/TileMapRenderer.java

@@ -11,13 +11,7 @@ import pathgame.tilemap.TileMap;
 import pathgame.tilemap.TileRenderType;
 import pathgame.tilemap.TileType;
 
-/**
- * A renderer for tile maps.
- *
- * @author kajetan
- */
 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,7 +24,7 @@ public class TileMapRenderer {
     private float scale = 1.0f;
 
     private final static String[] OVERLAY = new String[]{
-        "&a1", "&a2", "&a3", "&e4", "&e5", "&66", "&67", "&68", "&c9"
+        "#55FF551", "#55FF552", "#55FF553", "#FFFF554", "#FFFF555", "#FFAA006", "#FFAA007", "#FFAA008", "#FF55559"
     };
 
     private static String[] getWavePath() {
@@ -44,47 +38,18 @@ public class TileMapRenderer {
     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() {
-    }
-
-    /**
-     * Sets the scale of the map.
-     *
-     * @param scale the scale of the map
-     */
     public void setScale(float scale) {
         this.scale = scale;
     }
 
-    /**
-     * Returns the scale of the map.
-     *
-     * @return the scale of the map
-     */
     public float getScale() {
         return scale;
     }
 
-    /**
-     * Returns the scaled render width of a map.
-     *
-     * @param map a map
-     * @return the scaled render width of a map
-     */
     public float getWidth(TileMap map) {
         return map.getWidth() * TileRenderer.TILE_SIZE * scale;
     }
 
-    /**
-     * Returns the scaled render height of a map.
-     *
-     * @param map a map
-     * @return the scaled render height of a map
-     */
     public float getHeight(TileMap map) {
         return map.getHeight() * TileRenderer.TILE_SIZE * scale;
     }
@@ -131,20 +96,16 @@ public class TileMapRenderer {
         boolean s = isSwamp(map, x, y + 1);
         boolean w = isSwamp(map, x - 1, y);
 
-        if(!n && !w && isSwamp(map, x - 1, y - 1)) // upper, left corner
-        {
+        if(!n && !w && isSwamp(map, x - 1, y - 1)) {
             addTileOverlay(swampWaterOverlayRenderer, x, y, 7, 13);
         }
-        if(!n && !e && isSwamp(map, x + 1, y - 1)) // upper, right corner
-        {
+        if(!n && !e && isSwamp(map, x + 1, y - 1)) {
             addTileOverlay(swampWaterOverlayRenderer, x, y, 6, 13);
         }
-        if(!s && !w && isSwamp(map, x - 1, y + 1)) // lower, left corner
-        {
+        if(!s && !w && isSwamp(map, x - 1, y + 1)) {
             addTileOverlay(swampWaterOverlayRenderer, x, y, 5, 13);
         }
-        if(!s && !e && isSwamp(map, x + 1, y + 1)) // lower, right corner
-        {
+        if(!s && !e && isSwamp(map, x + 1, y + 1)) {
             addTileOverlay(swampWaterOverlayRenderer, x, y, 4, 13);
         }
 
@@ -165,20 +126,16 @@ public class TileMapRenderer {
         boolean s = isShallowWater(map, x, y + 1);
         boolean w = isShallowWater(map, x - 1, y);
 
-        if(!n && !w && isShallowWater(map, x - 1, y - 1)) // upper, left corner
-        {
+        if(!n && !w && isShallowWater(map, x - 1, y - 1)) {
             addTileOverlay(waterOverlayRenderer, x, y, 11, 13);
         }
-        if(!n && !e && isShallowWater(map, x + 1, y - 1)) // upper, right corner
-        {
+        if(!n && !e && isShallowWater(map, x + 1, y - 1)) {
             addTileOverlay(waterOverlayRenderer, x, y, 10, 13);
         }
-        if(!s && !w && isShallowWater(map, x - 1, y + 1)) // lower, left corner
-        {
+        if(!s && !w && isShallowWater(map, x - 1, y + 1)) {
             addTileOverlay(waterOverlayRenderer, x, y, 9, 13);
         }
-        if(!s && !e && isShallowWater(map, x + 1, y + 1)) // lower, right corner
-        {
+        if(!s && !e && isShallowWater(map, x + 1, y + 1)) {
             addTileOverlay(waterOverlayRenderer, x, y, 8, 13);
         }
 
@@ -199,20 +156,16 @@ public class TileMapRenderer {
         boolean s = isSwampOrWaterOrBorder(map, x, y + 1);
         boolean w = isSwampOrWaterOrBorder(map, x - 1, y);
 
-        if(n && w && !isSwampOrWaterOrBorder(map, x - 1, y - 1)) // upper, left corner
-        {
+        if(n && w && !isSwampOrWaterOrBorder(map, x - 1, y - 1)) {
             addTileOverlay(grassOverlayRenderer, x, y, 3, 13);
         }
-        if(n && e && !isSwampOrWaterOrBorder(map, x + 1, y - 1)) // upper, right corner
-        {
+        if(n && e && !isSwampOrWaterOrBorder(map, x + 1, y - 1)) {
             addTileOverlay(grassOverlayRenderer, x, y, 2, 13);
         }
-        if(s && w && !isSwampOrWaterOrBorder(map, x - 1, y + 1)) // lower, left corner
-        {
+        if(s && w && !isSwampOrWaterOrBorder(map, x - 1, y + 1)) {
             addTileOverlay(grassOverlayRenderer, x, y, 1, 13);
         }
-        if(s && e && !isSwampOrWaterOrBorder(map, x + 1, y + 1)) // lower, right corner
-        {
+        if(s && e && !isSwampOrWaterOrBorder(map, x + 1, y + 1)) {
             addTileOverlay(grassOverlayRenderer, x, y, 0, 13);
         }
 
@@ -261,12 +214,7 @@ public class TileMapRenderer {
         grassOverlayRenderer.build();
     }
 
-    /**
-     * Ticks the renderer. Used for animated tiles.
-     *
-     */
     public void tick() {
-        // tick tile animations here
         counter++;
         if(counter >= 1) {
             tileTexture.bind();
@@ -275,16 +223,7 @@ public class TileMapRenderer {
         }
     }
 
-    /**
-     * Draws the given map at the given offset.
-     *
-     * @param map a map
-     * @param r the renderer given by the engine
-     * @param forceUpdate whether an update of the render data should be forced
-     * @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, Keys keys) {
         r.setTextureEnabled(true);
         r.setColorEnabled(false);
         r.setMixColorEnabled(false);
@@ -309,7 +248,7 @@ public class TileMapRenderer {
         swampWaterOverlayRenderer.draw();
         grassOverlayRenderer.draw();
 
-        if(Keys.OVERLAY_KEY.isDown()) {
+        if(keys.overlay.isDown()) {
             r.translateTo(0.0f, 0.0f);
             r.updateMatrix();
             r.setTextureEnabled(false);
@@ -323,15 +262,15 @@ public class TileMapRenderer {
 
             FontRenderer fr = r.getFontRenderer();
 
-            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;
+            float midX = (TileRenderer.TILE_SIZE - fr.getCharWidth() * 2) * 0.5f * 0.5f;
+            float midY = (TileRenderer.TILE_SIZE - (fr.getCharHeight() - 1) * 2) * 0.5f * 0.5f;
             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)) {
-                        fr.drawString(tx, ty, true, "&4-");
+                        fr.drawString(tx, ty, true, "#AA0000-");
                     } else {
                         fr.drawString(tx, ty, true, OVERLAY[map.getTile(x, y).getEnergyCost(p) - 1]);
                     }

+ 0 - 17
src/pathgame/rendering/TileRenderer.java

@@ -4,15 +4,7 @@ import pathgame.tilemap.Tile;
 import pathgame.tilemap.TileMap;
 import pathgame.tilemap.Tiles;
 
-/**
- * Registry for rendering all possible tiles.
- *
- * @author kajetan
- */
 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];
@@ -71,15 +63,6 @@ public class TileRenderer {
         register(Tiles.PATH_N_E_S_W, new StaticTextureProvider(TileTexture.fromTextureId(38)));
     }
 
-    /**
-     * Returns a tile texture of a given map tile.
-     *
-     * @param map a map
-     * @param t a tile
-     * @param x the x coordinate of the given tile
-     * @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) {
             return null;

+ 0 - 39
src/pathgame/rendering/TileTexture.java

@@ -1,21 +1,10 @@
 package pathgame.rendering;
 
-/**
- * A container for tile texture coordinates.
- *
- * @author kajetan
- */
 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.
-     *
-     * @param textureId a texture id
-     * @return a tile texture constructed from a given texture id
-     */
     public static TileTexture fromTextureId(int textureId) {
         float tMinX = (textureId % TILES_PER_LINE) * TILE_TEXTURE_PERCENT;
         float tMinY = (textureId / TILES_PER_LINE) * TILE_TEXTURE_PERCENT;
@@ -29,14 +18,6 @@ public class TileTexture {
     private final float tMaxX;
     private final float tMaxY;
 
-    /**
-     * 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) {
         this.tMinX = tMinX;
         this.tMinY = tMinY;
@@ -44,38 +25,18 @@ public class TileTexture {
         this.tMaxY = tMaxY;
     }
 
-    /**
-     * Returns the the left x coordinate in the texture atlas.
-     *
-     * @return the left x coordinate in the texture atlas
-     */
     public float getMinX() {
         return tMinX;
     }
 
-    /**
-     * Returns the upper y coordinate in the texture atlas.
-     *
-     * @return the upper y coordinate in the texture atlas
-     */
     public float getMinY() {
         return tMinY;
     }
 
-    /**
-     * Returns the right x coordinate in the texture atlas.
-     *
-     * @return the right x coordinate in the texture atlas
-     */
     public float getMaxX() {
         return tMaxX;
     }
 
-    /**
-     * Returns the lower y coordinate in the texture atlas.
-     *
-     * @return the lower y coordinate in the texture atlas
-     */
     public float getMaxY() {
         return tMaxY;
     }

+ 0 - 14
src/pathgame/rendering/TileTextureProvider.java

@@ -3,21 +3,7 @@ package pathgame.rendering;
 import pathgame.tilemap.Tile;
 import pathgame.tilemap.TileMap;
 
-/**
- * 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.
-     *
-     * @param map a map
-     * @param t a tile
-     * @param x the x coordinate of the tile
-     * @param y the y coordinate of the tile
-     * @return a tile texture corresponding to the given tile at the given position
-     */
     public TileTexture getTexture(TileMap map, Tile t, int x, int y);
 }

+ 0 - 21
src/pathgame/tilemap/HighMap.java

@@ -2,23 +2,10 @@ package pathgame.tilemap;
 
 import java.util.Random;
 
-/**
- * Class for generating two dimensional highmaps of arbitrary size.
- *
- * @author kajetan
- */
 public class HighMap {
     private static final float LOW_FREQUENCY = 8.0f;
     private static final float HIGH_FREQUENCY = 7.0f;
 
-    /**
-     * 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) {
         HighMap map = new HighMap(seed, width, height);
         map.zoom();
@@ -37,19 +24,11 @@ public class HighMap {
         this.data = new float[width][height];
     }
 
-    /**
-     * 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) {
         return data[x][y];
     }
 
     private float[][] randomizeBase() {
-        // +1 for neighbours
         int w = (int) Math.ceil(width / HIGH_FREQUENCY) + 1;
         int h = (int) Math.ceil(height / HIGH_FREQUENCY) + 1;
         float[][] base = new float[w][h];

+ 2 - 148
src/pathgame/tilemap/Tile.java

@@ -1,19 +1,10 @@
 package pathgame.tilemap;
 
 import java.util.function.Function;
+import pathgame.gameplay.Keys;
 import pathgame.gameplay.Player;
 
-/**
- * Base class for tiles. Tiles are registered on construction.
- *
- * @author kajetan
- */
 public class Tile {
-
-    /**
-     * A builder for tiles.
-     *
-     */
     public static class TileBuilder {
         private int energyCost = 2;
         private float forestReplaceChance = 1.0f;
@@ -28,115 +19,55 @@ public class Tile {
         private TileBuilder() {
         }
 
-        /**
-         * Returns a new tile builder;
-         *
-         * @return a new tile builder
-         */
         public static TileBuilder create() {
             return new TileBuilder();
         }
 
-        /**
-         * 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) {
             this.energyCost = energyCost;
             return this;
         }
 
-        /**
-         * 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) {
             this.forestReplaceChance = forestReplaceChance;
             return this;
         }
 
-        /**
-         * Sets the function for handling speed ups.
-         *
-         * @param speedUp a function.
-         * @return the tile builder
-         */
         public TileBuilder setSpeedUp(Function<Player, Integer> speedUp) {
             this.speedUp = speedUp;
             return this;
         }
 
-        /**
-         * Marks the tile as non host for towns.
-         *
-         * @return the tile builder
-         */
         public TileBuilder noTown() {
             this.canHostTown = false;
             return this;
         }
 
-        /**
-         * Marks the tile as blocked for every movement.
-         *
-         * @return the tile builder
-         */
         public TileBuilder noMovement() {
             this.blocksMovement = true;
             return this;
         }
 
-        /**
-         * Sets the type of the tile.
-         *
-         * @param type a tile type
-         * @return the tile builder
-         */
         public TileBuilder setType(TileType type) {
             this.type = type;
             return this;
         }
 
-        /**
-         * Marks the tile as host for paths.
-         *
-         * @return the tile builder
-         */
         public TileBuilder pathHost() {
             this.canHostPath = true;
             return this;
         }
 
-        /**
-         * Marks the tile as path.
-         *
-         * @return the tile builder
-         */
         public TileBuilder path() {
             this.path = true;
             return this;
         }
 
-        /**
-         * Sets the render type of the tile.
-         *
-         * @param type a render type
-         * @return the tile builder
-         */
         public TileBuilder setRenderType(TileRenderType type) {
             this.renderType = type;
             return this;
         }
 
-        /**
-         * Returns the built tile.
-         *
-         * @return the built tile.
-         */
         public Tile build() {
             return new Tile(energyCost, forestReplaceChance, speedUp, canHostTown, blocksMovement, type, canHostPath, path, renderType);
         }
@@ -155,12 +86,6 @@ public class Tile {
         return idCounter++;
     }
 
-    /**
-     * 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) {
             return null;
@@ -194,120 +119,49 @@ public class Tile {
         this.renderType = renderType;
     }
 
-    /**
-     * Returns the id of the tile.
-     *
-     * @return the id of the tile
-     */
     public final int getId() {
         return id;
     }
 
-    /**
-     * 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) {
         return energyCost - speedUp.apply(p);
     }
 
-    /**
-     * Returns the chance that this tile is replaced by forest.
-     *
-     * @return the chance that this tile is replaced by forest
-     */
     public float getForestReplaceChance() {
         return forestReplaceChance;
     }
 
-    /**
-     * 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() {
         return canHostTown;
     }
 
-    /**
-     * 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) {
     }
 
-    /**
-     * 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) {
     }
 
-    /**
-     * 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);
     }
 
-    /**
-     * Returns the type of the tile.
-     *
-     * @return the type of the tile
-     */
     public TileType getType() {
         return type;
     }
 
-    /**
-     * 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() {
         return canHostPath;
     }
 
-    /**
-     * Returns true if this tile is a path.
-     *
-     * @return true if this tile is a path
-     */
     public boolean isPath() {
         return path;
     }
 
-    /**
-     * Returns the rendering type for overlays.
-     *
-     * @return the rendering type for overlays
-     */
     public TileRenderType getRenderType() {
         return renderType;
     }
 
-    /**
-     * 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, Keys keys) {
     }
 }

+ 0 - 5
src/pathgame/tilemap/TileHomeTown.java

@@ -2,11 +2,6 @@ package pathgame.tilemap;
 
 import pathgame.gameplay.Player;
 
-/**
- * Class for home towns to have special behaviour.
- *
- * @author kajetan
- */
 public class TileHomeTown extends Tile {
     public TileHomeTown() {
         super(1, 0.0f, (pa) -> 0, false, false, TileType.LAND, false, false, TileRenderType.NORMAL);

+ 0 - 75
src/pathgame/tilemap/TileMap.java

@@ -3,11 +3,6 @@ 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.
- *
- * @author kajetan
- */
 public class TileMap {
     private static class TownConverter {
         private int x;
@@ -26,43 +21,20 @@ public class TileMap {
     private int homeX;
     private int homeY;
 
-    /**
-     * 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) {
         this.width = width;
         this.height = height;
         tiles = new int[width][height];
     }
 
-    /**
-     * Returns the width of the map.
-     *
-     * @return the width of the map
-     */
     public int getWidth() {
         return width;
     }
 
-    /**
-     * Returns the height of the map.
-     *
-     * @return the height of the map
-     */
     public int getHeight() {
         return height;
     }
 
-    /**
-     * 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) {
         dirty = true;
         if(tiles[x][y] == Tiles.TOWN.getId()) {
@@ -74,38 +46,18 @@ public class TileMap {
         tiles[x][y] = tile.getId();
     }
 
-    /**
-     * 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) {
         return Tile.fromId(tiles[x][y]);
     }
 
-    /**
-     * Returns true if the map was modified. This is used for rendering.
-     *
-     * @return true if the map was modified
-     */
     public boolean isDirty() {
         return dirty;
     }
 
-    /**
-     * Clears the dirty flag of the map.
-     *
-     */
     public void clean() {
         dirty = false;
     }
 
-    /**
-     * Ticks the tilemap.
-     *
-     */
     public void tick() {
         Iterator<TownConverter> iter = townConverters.iterator();
         while(iter.hasNext()) {
@@ -122,12 +74,6 @@ public class TileMap {
         }
     }
 
-    /**
-     * 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) {
         TownConverter tc = new TownConverter();
         tc.x = x;
@@ -135,40 +81,19 @@ public class TileMap {
         townConverters.add(tc);
     }
 
-    /**
-     * Returns the number of active towns.
-     *
-     * @return the number of active towns
-     */
     public int getNumberOfTowns() {
         return towns;
     }
 
-    /**
-     * Sets the position 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) {
         homeX = x;
         homeY = y;
     }
 
-    /**
-     * Returns the x coordinate of the home town.
-     *
-     * @return the x coordinate of the home town
-     */
     public int getHomeX() {
         return homeX;
     }
 
-    /**
-     * Returns the y coordinate of the home town.
-     *
-     * @return the y coordinate of the home town
-     */
     public int getHomeY() {
         return homeY;
     }

+ 0 - 24
src/pathgame/tilemap/TileMapGenerator.java

@@ -3,35 +3,13 @@ package pathgame.tilemap;
 import java.util.ArrayList;
 import java.util.Random;
 
-/**
- * Static class to generate tile maps.
- *
- * @author kajetan
- */
 public class TileMapGenerator {
     private static long seed = 1;
 
-    /**
-     * 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) {
         return getMap(width, height, seed++, towns);
     }
 
-    /**
-     * Returns a random generated map
-     *
-     * @param width the width of the map
-     * @param height the height of the map
-     * @param seed the seed for the random number generator
-     * @param towns the amount of towns
-     * @return a random generated map
-     */
     public static TileMap getMap(int width, int height, long seed, int towns) {
         Random r = new Random(seed);
 
@@ -236,8 +214,6 @@ public class TileMapGenerator {
 
         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;

+ 2 - 7
src/pathgame/tilemap/TilePort.java

@@ -3,19 +3,14 @@ package pathgame.tilemap;
 import pathgame.gameplay.Keys;
 import pathgame.gameplay.Player;
 
-/**
- * Class for ports to have special behaviour.
- *
- * @author kajetan
- */
 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, Keys keys) {
+        if(keys.boat.getTime() == 1) {
             p.switchSailing();
         }
     }

+ 0 - 5
src/pathgame/tilemap/TileRenderType.java

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

+ 0 - 5
src/pathgame/tilemap/TileTown.java

@@ -2,11 +2,6 @@ package pathgame.tilemap;
 
 import pathgame.gameplay.Player;
 
-/**
- * Class for towns to have special behaviour.
- *
- * @author kajetan
- */
 public class TileTown extends Tile {
     public TileTown() {
         super(2, 0.0f, (pa) -> 0, false, false, TileType.LAND, false, false, TileRenderType.NORMAL);

+ 0 - 5
src/pathgame/tilemap/TileType.java

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

+ 4 - 19
src/pathgame/tilemap/Tiles.java

@@ -2,13 +2,7 @@ package pathgame.tilemap;
 
 import pathgame.gameplay.PlayerAbilities;
 
-/**
- * Static class for all existing tiles.
- *
- * @author kajetan
- */
 public class Tiles {
-
     public final static Tile GRASS = buildGrass();
     public final static Tile GRASS_WITH_STONE = buildGrass();
     public final static Tile GRASS_WITH_6_BUSHES = buildGrass();
@@ -85,7 +79,7 @@ public class Tiles {
 
     public final static Tile PORT = new TilePort();
 
-    private final static Tile buildGrass() {
+    private static Tile buildGrass() {
         return Tile.TileBuilder.create()
                 .setSpeedUp((p) -> p.getAbilities().getFasterGrass())
                 .pathHost()
@@ -93,7 +87,7 @@ public class Tiles {
                 .build();
     }
 
-    private final static Tile buildSwamp() {
+    private static Tile buildSwamp() {
         return Tile.TileBuilder.create()
                 .setEnergyCost(5)
                 .setForestReplaceChance(0.0f)
@@ -102,7 +96,7 @@ public class Tiles {
                 .build();
     }
 
-    private final static Tile buildBlockedTown() {
+    private static Tile buildBlockedTown() {
         return Tile.TileBuilder.create()
                 .setForestReplaceChance(0.0f)
                 .noTown()
@@ -111,7 +105,7 @@ public class Tiles {
 
     public final static Tile HOME_TOWN = new TileHomeTown();
 
-    private final static Tile buildPath() {
+    private static Tile buildPath() {
         return Tile.TileBuilder.create()
                 .setForestReplaceChance(0.0f)
                 .path()
@@ -141,15 +135,6 @@ public class Tiles {
         PATH_S_W, PATH_S, PATH_W, GRASS
     };
 
-    /**
-     * 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
-     * @param south true if there is a connection to the south tile
-     * @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) {
         return PATH[(north ? 0 : 8) + (east ? 0 : 4) + (south ? 0 : 2) + (west ? 0 : 1)];
     }