Forráskód Böngészése

inline commenting, bug fixing

Hudriwudri 4 éve
szülő
commit
a521c04abe

+ 52 - 5
src/pathgame/gameplay/Camera.java

@@ -1,8 +1,12 @@
 package pathgame.gameplay;
 
+/**
+ * A container for all camera specific functions
+ *
+ * @author julia
+ */
 public class Camera
 {
-
     private final static int CAM_SPEED = 64;
 
     private float lastScale = 1.0f;
@@ -13,6 +17,12 @@ 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)
     {
         lastCamOffsetX = camOffsetX;
@@ -29,7 +39,7 @@ public class Camera
             {
                 scale /= 1.1f;
             }
-            
+
             if(Keys.CAM_UP_KEY.isDown())
             {
                 camOffsetY += CAM_SPEED;
@@ -49,6 +59,13 @@ public class Camera
         }
     }
 
+    /**
+     * Limits scale of camera
+     *
+     * @param zoomRestriction the lower zoom factor restriction (zooming out
+     * restriction)
+     * @return a tile texture constructed from a given texture id
+     */
     public void limitScale(float zoomRestriction)
     {
         if(scale <= zoomRestriction)
@@ -61,7 +78,11 @@ public class Camera
         }
 
     }
-    
+
+    /**
+     * Resetting the camera to focus the player
+     *
+     */
     public void reset()
     {
         camOffsetX = 0.0f;
@@ -70,11 +91,27 @@ 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;
@@ -98,7 +135,17 @@ 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;

+ 23 - 1
src/pathgame/gameplay/Gamestate.java

@@ -1,19 +1,41 @@
 package pathgame.gameplay;
 
+/**
+ * A container for the gamestate
+ *
+ * @author julia
+ */
 public class Gamestate
 {
     private Gamestates state = Gamestates.MENU;
 
+    /**
+     * 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;

+ 15 - 5
src/pathgame/gameplay/Keys.java

@@ -8,9 +8,13 @@ import me.hammerle.snuviengine.api.KeyBinding;
 import me.hammerle.snuviengine.api.KeyHandler;
 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);
@@ -27,18 +31,24 @@ public class Keys
     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, 
+        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"
+        "Cam Right Key", "Overlay Key", "Boat Key"
     };
 
     static

+ 58 - 7
src/pathgame/gameplay/Level.java

@@ -5,6 +5,11 @@ import pathgame.logging.Logger;
 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
 {
     private final Player player = new Player();
@@ -13,11 +18,20 @@ 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)
     {
         map.tick();
@@ -36,55 +50,92 @@ public final class Level
         }
     }
 
+    /**
+     * 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));
         int towns = Math.round(2.0f + level * 0.5f);
-        
+
         map = TileMapGenerator.getMap(levelW, levelH, level, towns);
         player.reset(map.getHomeX(), map.getHomeY());
         player.setObjectivesAmount(map.getNumberOfTowns());
-        
+
         int algoEnergy = TravellingSalesAlg.calcSalesPathLen(map, player);
-        
+
         player.setEnergySupply(algoEnergy);
-        
+
         Logger.onLevelReset(level, player, map);
     }
 
+    /**
+     * 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 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; 
+        return showScoreMenu;
     }
 }

+ 28 - 1
src/pathgame/gameplay/MinusStepsValues.java

@@ -1,28 +1,55 @@
 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;
     }
-}
+}

+ 154 - 3
src/pathgame/gameplay/Player.java

@@ -6,9 +6,13 @@ import pathgame.logging.Logger;
 import pathgame.tilemap.Tile;
 import pathgame.tilemap.TileMap;
 
+/**
+ * A container for holding everything about the player
+ *
+ * @author julia
+ */
 public class Player
 {
-
     private static final float SPEED = 0.25f;
 
     private PlayerAbilities abilities = PlayerAbilities.NORMAL;
@@ -32,25 +36,49 @@ public class Player
     private final LinkedList<MinusStepsValues> steps = new LinkedList<>();
     private Tile currentTile;// = Tiles.GRASS;
 
+    /**
+     * 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;
@@ -69,6 +97,11 @@ public class Player
         }
     }
 
+    /**
+     * Recalculates the player position every gametick based on user input
+     *
+     * @param map the current map
+     */
     public void tick(TileMap map)
     {
         tickSteps();
@@ -172,92 +205,185 @@ 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;
         Logger.onWin(this, map);
     }
 
+    /**
+     * Returns if player has lost the current map
+     *
+     * @return if player has lost the current map
+     */
     public boolean hasLost()
     {
         return 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)
     {
         lastX = sx;
@@ -280,26 +406,51 @@ 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;

+ 71 - 5
src/pathgame/gameplay/PlayerAbilities.java

@@ -1,5 +1,10 @@
 package pathgame.gameplay;
 
+/**
+ * A container for holding all player abilities
+ *
+ * @author julia
+ */
 public class PlayerAbilities
 {
     private final String name;
@@ -10,8 +15,27 @@ public class PlayerAbilities
     private final int fasterHill;
     private final int fasterMountain;
     private final int fasterSwamp;
-    
-    public PlayerAbilities(String name, int fasterGrass, int fasterForest, int fasterShallowWater, 
+
+    /**
+     * 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
+     */
+    public PlayerAbilities(String name, int fasterGrass, int fasterForest, int fasterShallowWater,
             int fasterDeepWater, int fasterHill, int fasterMountain, int fasterSwamp)
     {
         this.name = name;
@@ -29,49 +53,91 @@ 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);
-    
-    public final static PlayerAbilities[] ABILITIES = new PlayerAbilities[] 
+    /**
+     * 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;
     }
-}
+}

+ 16 - 1
src/pathgame/gameplay/menu/AfterScoreMenu.java

@@ -2,11 +2,21 @@ 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);
@@ -35,6 +45,11 @@ public class AfterScoreMenu extends BaseMenu
         };
     }
 
+    /**
+     * Returns the options of the AfterScoreMenu
+     *
+     * @return the options of the AfterScoreMenu
+     */
     @Override
     public MenuButton[] getOptions()
     {

+ 55 - 10
src/pathgame/gameplay/menu/BaseMenu.java

@@ -5,28 +5,58 @@ 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;
+
     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)
     {
         returnId = id;
@@ -49,21 +79,36 @@ 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)
     {
         return key.getTime() == 1 || (key.getTime() >= 20 && key.getTime() % 5 == 1);
     }
-    
-    
-}
+
+}

+ 16 - 1
src/pathgame/gameplay/menu/CharacterMenu.java

@@ -3,11 +3,21 @@ 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);
@@ -32,6 +42,11 @@ public class CharacterMenu extends BaseMenu
         });
     }
 
+    /**
+     * Returns the options of the CharacterMenu
+     *
+     * @return the options of the CharacterMenu
+     */
     @Override
     public MenuButton[] getOptions()
     {

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

@@ -3,31 +3,47 @@ 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[] 
+
+        options = new MenuButton[]
         {
-            new MenuButton("Continue", (gamestate) -> 
+            new MenuButton("Continue", (gamestate) ->
             {
                 gamestate.setState(Gamestates.GAMEPLAY);
             }),
-            new MenuButton("Main Menu", (gamestate) -> 
+            new MenuButton("Main Menu", (gamestate) ->
             {
                 setReturnId(mainId);
             }),
-            new MenuButton("Exit", (gamestate) -> 
+            new MenuButton("Exit", (gamestate) ->
             {
                 Engine.stop();
             }),
         };
     }
 
+    /**
+     * Returns the options of the EscapeMenu
+     *
+     * @return the options of the EscapeMenu
+     */
     @Override
     public MenuButton[] getOptions()
     {

+ 26 - 9
src/pathgame/gameplay/menu/MainMenu.java

@@ -2,31 +2,48 @@ 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;
-    
-    public MainMenu(int id, int optionsId, int charaterId)
+
+    /**
+     * 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[] 
+
+        options = new MenuButton[]
         {
-            new MenuButton("Start", (gamestate) -> 
+            new MenuButton("Start", (gamestate) ->
             {
-                setReturnId(charaterId);
+                setReturnId(characterId);
             }),
-            new MenuButton("Options", (gamestate) -> 
+            new MenuButton("Options", (gamestate) ->
             {
                 setReturnId(optionsId);
             }),
-            new MenuButton("Exit", (gamestate) -> 
+            new MenuButton("Exit", (gamestate) ->
             {
                 Engine.stop();
             })
-        }; 
+        };
     }
 
+    /**
+     * Returns the options of the MainMenu
+     *
+     * @return the options of the MainMenu
+     */
     @Override
     public MenuButton[] getOptions()
     {

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

@@ -5,6 +5,11 @@ 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;
@@ -34,6 +39,12 @@ public class Menu
 
     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)
@@ -63,21 +74,40 @@ 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;

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

@@ -5,27 +5,55 @@ 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);

+ 21 - 1
src/pathgame/gameplay/menu/OptionMenu.java

@@ -8,11 +8,21 @@ import me.hammerle.snuviengine.api.KeyBinding;
 import me.hammerle.snuviengine.api.KeyHandler;
 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)
     {
         super(id);
@@ -47,12 +57,22 @@ public class OptionMenu extends BaseMenu
         });
     }
 
+    /**
+     * Returns the options of the OptionMenu
+     *
+     * @return the options of the OptionMenu
+     */
     @Override
     public MenuButton[] getOptions()
     {
         return options;
     }
 
+    /**
+     * Returns if this is the OptionMenu
+     *
+     * @return if this is the OptionMenu
+     */
     @Override
     public boolean isOptionMenu()
     {

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

@@ -6,15 +6,29 @@ 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)
     {
         r.translateTo(0.0f, 0.0f);
-        r.scale(2.0f, 2.0f);    
+        r.scale(2.0f, 2.0f);
         r.updateMatrix();
 
         renderHUDBackgound(r);
@@ -24,7 +38,7 @@ public class HUDRenderer
         renderMinusEnergy(r, p, lag);
     }
 
-    void renderHUDBackgound(Renderer r)
+    private void renderHUDBackgound(Renderer r)
     {
         r.setMixColorEnabled(true);
         r.setColorEnabled(true);
@@ -34,7 +48,7 @@ public class HUDRenderer
         r.getColorRenderer().drawRectangle(0, 0, r.getViewWidth(), 20, 0xFF_00_00_00);//ABGR
     }
 
-    void renderObjectiveTracker(Renderer r, Player p)
+    private void renderObjectiveTracker(Renderer r, Player p)
     {
         r.setMixColorEnabled(false);
         r.setColorEnabled(true);
@@ -44,7 +58,7 @@ public class HUDRenderer
         r.getFontRenderer().drawString(2, 6, objectiveTracker);
     }
 
-    void renderEnergyText(Renderer r, Player p)
+    private void renderEnergyText(Renderer r, Player p)
     {
         r.setMixColorEnabled(false);
         r.setColorEnabled(true);
@@ -58,7 +72,7 @@ public class HUDRenderer
                 6, energy);
     }
 
-    void renderEnergyBar(Renderer r, Player p)
+    private void renderEnergyBar(Renderer r, Player p)
     {
         r.setMixColorEnabled(true);
         r.setColorEnabled(false);
@@ -66,17 +80,17 @@ public class HUDRenderer
         r.setBlendingEnabled(true);
 
         float energyPercent = 100 / (float) p.getEnergySupply() * (float) p.getEnergyLeft() / 100;
-        if(energyPercent<0)
+        if(energyPercent < 0)
         {
             energyPercent = 0;
         }
-        ENERGYBAR.bind();        
-        r.getTextureRenderer().drawRectangle(100, 5, (r.getViewWidth() / 2 - 5), 17, 0, 0.0625f, 1, 0.0625f*2);
+        ENERGYBAR.bind();
+        r.getTextureRenderer().drawRectangle(100, 5, (r.getViewWidth() / 2 - 5), 17, 0, 0.0625f, 1, 0.0625f * 2);
         r.getTextureRenderer().drawRectangle(100, 5, (((r.getViewWidth() / 2 - 5) - 100) * (energyPercent)) + 100, 17, 0, 0, 1 * energyPercent, 0.0625f);
 
     }
 
-    void renderMinusEnergy(Renderer r, Player p, float lag)
+    private void renderMinusEnergy(Renderer r, Player p, float lag)
     {
         r.setMixColorEnabled(false);
         r.setColorEnabled(true);
@@ -89,4 +103,4 @@ public class HUDRenderer
             r.getFontRenderer().drawString(r.getViewWidth() * 0.5f - 63, 9 + step.getLifeTime() + lag, minusEnergy);
         }
     }
-}
+}

+ 21 - 0
src/pathgame/rendering/LevelRenderer.java

@@ -8,6 +8,11 @@ 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();
@@ -16,6 +21,13 @@ 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);
@@ -26,6 +38,15 @@ public class LevelRenderer
         }
     }
 
+    /**
+     * Recalculates the rendering position and settings of everything in the
+     * level every rendertick based on the gamelogic in the gametick
+     *
+     * @param r the renderer
+     * @param lag the current lag
+     * @param level the current level containing the map and the player
+     * @param gamestate the gamestate
+     */
     public void renderTick(Renderer r, float lag, Level level, Gamestate gamestate)
     {
         if(level.isShowingAfterScore() || level.isShowingScoreMenu())

+ 13 - 0
src/pathgame/rendering/MenuRenderer.java

@@ -6,10 +6,23 @@ 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];
 
+        /**
+     * 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)
     {
         r.translateTo(0.0f, 0.0f);

+ 21 - 4
src/pathgame/rendering/PlayerRenderer.java

@@ -6,10 +6,27 @@ import pathgame.gameplay.Player;
 import pathgame.tilemap.TileMap;
 import pathgame.tilemap.Tiles;
 
+/**
+ * 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");
 
+    /**
+     * 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)
     {
         float playerSize = mapR.getScale() * TileRenderer.TILE_SIZE;
@@ -65,20 +82,20 @@ public class PlayerRenderer
             //stand still
             yIndex = 0;
         }
-        
+
         if(p.isSailing())
         {
             yTexOff = 0.5f;
         }
-        else if(p.getCurrTile()== Tiles.SHALLOW_WATER)
+        else if(p.getCurrTile() == Tiles.SHALLOW_WATER)
         {
             xTexOff = 0.5f;
         }
-        
+
         float viewScale = r.getViewScale();
         ix = (int) (ix * viewScale) / viewScale;
         iy = (int) (iy * viewScale) / viewScale;
-        
+
         r.getTextureRenderer().drawRectangle(ix, iy, ix + playerSize, iy + playerSize,
                 tIndex * 0.125f + xTexOff, yIndex * 0.125f + yTexOff,
                 (tIndex + 1) * 0.125f + xTexOff, yIndex * 0.125f + 0.125f + yTexOff);

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

@@ -3,8 +3,21 @@ package pathgame.rendering;
 import me.hammerle.snuviengine.api.Renderer;
 import pathgame.gameplay.Level;
 
+/**
+ * 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();
@@ -21,7 +34,7 @@ public class ScoreMenuRenderer
         r.translateTo(0.0f, 0.0f);
         float scale = scale(r, 1);
 
-        String message = String.format("&2%d&f of &2%d&f Energy used", 
+        String message = String.format("&2%d&f of &2%d&f Energy used",
                 level.getPlayer().getEnergyUsed(), level.getPlayer().getEnergySupply());
 
         r.getFontRenderer().drawString((windowWidth * scale - getWidth(r, message)) / 2, (windowHeight * scale - getHeight(r, message)) / 2 - windowHeight * scale * 0.5f * 0.15f, message);
@@ -42,6 +55,10 @@ public class ScoreMenuRenderer
         {
             message = "Only twice the energy use of the algorithm!";
         }
+        else if((float) level.getPlayer().getEnergyUsed() / level.getPlayer().getEnergySupply() == 1)
+        {
+            message = "As good as the algorithm!";
+        }
         else if((float) level.getPlayer().getEnergyUsed() / level.getPlayer().getEnergySupply() > 1)
         {
             message = "More than twice the energy use of the algorithm!";
@@ -50,7 +67,7 @@ public class ScoreMenuRenderer
         r.getFontRenderer().drawString((windowWidth * scale - getWidth(r, message)) / 2, (windowHeight * scale - getHeight(r, message)) / 2 - windowHeight * scale * 0.5f * (-0.15f), message);
 
         scale = scale(r, 2);
-        if((float) level.getPlayer().getEnergyUsed() / level.getPlayer().getEnergySupply() < 1)
+        if((float) level.getPlayer().getEnergyUsed() / level.getPlayer().getEnergySupply() <= 1)
         {
 
             message = "Congratulations!";