diff --git a/src/de/teamteamteam/spacescooter/Main.java b/src/de/teamteamteam/spacescooter/Main.java index e34f7a3..bead95e 100644 --- a/src/de/teamteamteam/spacescooter/Main.java +++ b/src/de/teamteamteam/spacescooter/Main.java @@ -29,12 +29,12 @@ public class Main { final GameFrame gameFrame = new GameFrame(); //Initialize SuperScreen and add to GameFrame, so we can call doPaint() on it. - SuperScreen superScreen = new SuperScreen(null); - gameFrame.setSuperScreen(superScreen); + final SuperScreen superScreen = new SuperScreen(null); //Initialize the GameFrame properly within the AWT EventQueue EventQueue.invokeLater(new Runnable() { public void run() { + gameFrame.setSuperScreen(superScreen); gameFrame.init(); gameFrame.draw(); //Draw nothing for the first time. } diff --git a/src/de/teamteamteam/spacescooter/screen/GamePausedScreen.java b/src/de/teamteamteam/spacescooter/screen/GamePausedScreen.java new file mode 100644 index 0000000..b9697a5 --- /dev/null +++ b/src/de/teamteamteam/spacescooter/screen/GamePausedScreen.java @@ -0,0 +1,34 @@ +package de.teamteamteam.spacescooter.screen; + +import java.awt.Color; +import java.awt.Font; +import java.awt.Graphics; +import java.awt.event.KeyEvent; + +import de.teamteamteam.spacescooter.control.Keyboard; +import de.teamteamteam.spacescooter.utility.GameConfig; + +public class GamePausedScreen extends Screen { + + public GamePausedScreen(Screen parent) { + super(parent); + } + + @Override + protected void paint(Graphics g) { + g.setColor(new Color(0,0,120)); + g.fillRect(0, 0, GameConfig.windowWidth, GameConfig.windowHeight); + g.setColor(new Color(255,255,255)); + g.setFont(new Font("Monospace", 0, 50)); + g.drawString("Pause Menu. LOL", 100, 100); + g.drawString("Press space to continue!", 100, 400); + } + + @Override + protected void update() { + if(Keyboard.isKeyDown(KeyEvent.VK_SPACE)) { + this.parent.setOverlay(null); + } + } + +} diff --git a/src/de/teamteamteam/spacescooter/screen/GameScreen.java b/src/de/teamteamteam/spacescooter/screen/GameScreen.java index 3d9ada4..63f8dca 100644 --- a/src/de/teamteamteam/spacescooter/screen/GameScreen.java +++ b/src/de/teamteamteam/spacescooter/screen/GameScreen.java @@ -41,7 +41,7 @@ public class GameScreen extends Screen { i.next().update(); } if (Keyboard.isKeyDown(KeyEvent.VK_ESCAPE)) { - this.parent.setOverlay(new MainMenuScreen(this.parent)); + this.setOverlay(new GamePausedScreen(this)); } } diff --git a/src/de/teamteamteam/spacescooter/screen/MainMenuScreen.java b/src/de/teamteamteam/spacescooter/screen/MainMenuScreen.java index 7dcbfce..59119ee 100644 --- a/src/de/teamteamteam/spacescooter/screen/MainMenuScreen.java +++ b/src/de/teamteamteam/spacescooter/screen/MainMenuScreen.java @@ -7,7 +7,6 @@ import java.awt.Graphics; import java.awt.event.KeyEvent; import de.teamteamteam.spacescooter.control.Keyboard; -import de.teamteamteam.spacescooter.entity.Entity; import de.teamteamteam.spacescooter.utility.GameConfig; public class MainMenuScreen extends Screen { @@ -28,9 +27,9 @@ public class MainMenuScreen extends Screen { @Override public void update() { - for(Entity entity : this.entities) { + /*for(Entity entity : this.entities) { entity.update(); - } + }*/ if(Keyboard.isKeyDown(KeyEvent.VK_SPACE)) { this.parent.setOverlay(new GameScreen(this.parent)); } diff --git a/src/de/teamteamteam/spacescooter/screen/Screen.java b/src/de/teamteamteam/spacescooter/screen/Screen.java index 8862b90..f3d4123 100644 --- a/src/de/teamteamteam/spacescooter/screen/Screen.java +++ b/src/de/teamteamteam/spacescooter/screen/Screen.java @@ -9,13 +9,13 @@ public abstract class Screen { public static Screen currentScreen; - protected Screen overlay; + public Screen overlay; protected Screen parent; protected LinkedList entities; public Screen(Screen parent) { - this.overlay = null; + this.setOverlay(null); this.parent = parent; this.entities = new LinkedList(); } @@ -43,13 +43,17 @@ public abstract class Screen { public void doUpdate() { if(this.overlay != null) { this.overlay.doUpdate(); - return; + } else { + this.update(); } - this.update(); } public void setOverlay(Screen screen) { this.overlay = screen; - Screen.currentScreen = screen; + if(screen == null) { + Screen.currentScreen = this; + } else { + Screen.currentScreen = screen; + } } }