From 1caf4818eba3ed74d248effec8f7786f5460cefe Mon Sep 17 00:00:00 2001 From: Jan Philipp Timme Date: Thu, 6 Nov 2014 23:09:27 +0100 Subject: [PATCH] Add comments to screen package. --- .../spacescooter/screen/GameOverScreen.java | 5 +++++ .../spacescooter/screen/GamePausedScreen.java | 8 +++++++- .../spacescooter/screen/GameScreen.java | 6 ++++++ .../spacescooter/screen/LoadingScreen.java | 5 +++++ .../spacescooter/screen/MainMenuScreen.java | 3 +++ .../teamteamteam/spacescooter/screen/Screen.java | 9 +++++++++ .../spacescooter/screen/SuperScreen.java | 15 +++++++++++++++ 7 files changed, 50 insertions(+), 1 deletion(-) diff --git a/src/de/teamteamteam/spacescooter/screen/GameOverScreen.java b/src/de/teamteamteam/spacescooter/screen/GameOverScreen.java index 8c3bd6d..9cdd9e0 100644 --- a/src/de/teamteamteam/spacescooter/screen/GameOverScreen.java +++ b/src/de/teamteamteam/spacescooter/screen/GameOverScreen.java @@ -15,6 +15,11 @@ import de.teamteamteam.spacescooter.gui.Button; import de.teamteamteam.spacescooter.utility.GameConfig; import de.teamteamteam.spacescooter.utility.Loader; +/** + * This is the GameOverScreen, which is displayed once the player + * died and the game is over. + * It allows to start a new game or going to the MainMenuScreen. + */ public class GameOverScreen extends Screen { private BufferedImage img; diff --git a/src/de/teamteamteam/spacescooter/screen/GamePausedScreen.java b/src/de/teamteamteam/spacescooter/screen/GamePausedScreen.java index 3f836cb..87353e0 100644 --- a/src/de/teamteamteam/spacescooter/screen/GamePausedScreen.java +++ b/src/de/teamteamteam/spacescooter/screen/GamePausedScreen.java @@ -15,6 +15,11 @@ import de.teamteamteam.spacescooter.gui.Button; import de.teamteamteam.spacescooter.utility.GameConfig; import de.teamteamteam.spacescooter.utility.Loader; +/** + * This GamePausedScreen shows up when the user pressed VK_ESCAPE ingame. + * It allows to return back into the game or going back to the MainMenuScreen, + * discarding the current GameScreen completely. + */ public class GamePausedScreen extends Screen { private BufferedImage img; @@ -88,10 +93,11 @@ public class GamePausedScreen extends Screen { } else if(this.animationStatus == 2) { switch (this.menuPoint) { case 0: + //Removes itself from the GameScreen, so the player can continue playing. this.parent.setOverlay(null); break; case 1: - //Replace our parents (the game) parent (the SuperScreen) overlay. + //Replaces its parents (the GameScreen) parent (the SuperScreen) overlay. this.parent.parent.setOverlay(new MainMenuScreen(this.parent.parent)); break; } diff --git a/src/de/teamteamteam/spacescooter/screen/GameScreen.java b/src/de/teamteamteam/spacescooter/screen/GameScreen.java index 9d187a6..442e0ff 100644 --- a/src/de/teamteamteam/spacescooter/screen/GameScreen.java +++ b/src/de/teamteamteam/spacescooter/screen/GameScreen.java @@ -16,6 +16,12 @@ import de.teamteamteam.spacescooter.entity.Player; import de.teamteamteam.spacescooter.entity.enemy.EnemyFour; import de.teamteamteam.spacescooter.entity.enemy.EnemyThree; +/** + * In this GameScreen, the actual gameplay takes place. + * All Entities are updated and painted by it. + * Also, it offers the GamePausedScreen when the user presses VK_ESCAPE. + * When the Player died in the game, the GameOverScreen replaces this Screen. + */ public class GameScreen extends Screen { private ArrayList points = new ArrayList(); diff --git a/src/de/teamteamteam/spacescooter/screen/LoadingScreen.java b/src/de/teamteamteam/spacescooter/screen/LoadingScreen.java index e089fd5..71143b2 100644 --- a/src/de/teamteamteam/spacescooter/screen/LoadingScreen.java +++ b/src/de/teamteamteam/spacescooter/screen/LoadingScreen.java @@ -5,6 +5,11 @@ import java.awt.Font; import java.awt.Graphics2D; import de.teamteamteam.spacescooter.utility.GameConfig; +/** + * This is the LoadingScreen, which is displayed when the game is started. + * It vanishes when all available resources have been processed by the loader, + * showing the MainMenuScreen. + */ public class LoadingScreen extends Screen { private int currentProcessed; diff --git a/src/de/teamteamteam/spacescooter/screen/MainMenuScreen.java b/src/de/teamteamteam/spacescooter/screen/MainMenuScreen.java index 19d4532..5eb5dc7 100644 --- a/src/de/teamteamteam/spacescooter/screen/MainMenuScreen.java +++ b/src/de/teamteamteam/spacescooter/screen/MainMenuScreen.java @@ -15,6 +15,9 @@ import de.teamteamteam.spacescooter.entity.Player; import de.teamteamteam.spacescooter.gui.Button; import de.teamteamteam.spacescooter.utility.GameConfig; +/** + * This Screen show the games main menu. + */ public class MainMenuScreen extends Screen { private Player player; diff --git a/src/de/teamteamteam/spacescooter/screen/Screen.java b/src/de/teamteamteam/spacescooter/screen/Screen.java index c0f8c93..c91b803 100644 --- a/src/de/teamteamteam/spacescooter/screen/Screen.java +++ b/src/de/teamteamteam/spacescooter/screen/Screen.java @@ -54,14 +54,23 @@ public abstract class Screen { */ protected abstract void update(); + /** + * Add an Entity to this Screen, so it will be updated and drawn. + */ public void addEntity(Entity e) { this.entities.add(e); } + /** + * Remove an Entity from this Screen. + */ public void removeEntity(Entity e) { this.entities.remove(e); } + /** + * Get a copy of the List of the Entities this Screen takes care of. + */ public List getEntities() { return new LinkedList(this.entities); } diff --git a/src/de/teamteamteam/spacescooter/screen/SuperScreen.java b/src/de/teamteamteam/spacescooter/screen/SuperScreen.java index af0eab5..99fc68c 100644 --- a/src/de/teamteamteam/spacescooter/screen/SuperScreen.java +++ b/src/de/teamteamteam/spacescooter/screen/SuperScreen.java @@ -2,17 +2,32 @@ package de.teamteamteam.spacescooter.screen; import java.awt.Graphics2D; +/** + * This is the SuperScreen. + * It is the root of our Screen hierarchy and therefore exists at all times. + * Its overlay represents things like the MainMenuScreen, the actual GameScreen, + * and many more. + */ public class SuperScreen extends Screen { + /** + * Default constructor. + */ public SuperScreen(Screen parent) { super(null); } + /** + * Blank implementation of the paint method. + */ @Override public void paint(Graphics2D g) { //nothing to paint, we're so meta meta. } + /** + * Blank implementation of the update method. + */ @Override public void update() { //dummy method