diff options
author | Nao Pross <naopross@thearcway.org> | 2018-11-20 18:20:36 +0100 |
---|---|---|
committer | Nao Pross <naopross@thearcway.org> | 2018-11-20 18:21:33 +0100 |
commit | dab2ea78c67a97a4219a4671cb29b417ea05fcbe (patch) | |
tree | 2b357c58959bb159431ac0db2921dbfc5048d6a7 | |
parent | Refractor MapScene (diff) | |
download | Subconscious-java-dab2ea78c67a97a4219a4671cb29b417ea05fcbe.tar.gz Subconscious-java-dab2ea78c67a97a4219a4671cb29b417ea05fcbe.zip |
Add currentMap to Game, waitStateChange now returns the new state
Diffstat (limited to '')
-rw-r--r-- | src/subconscious/Game.java | 9 | ||||
-rw-r--r-- | src/subconscious/graphics/GameWindow.java | 4 |
2 files changed, 10 insertions, 3 deletions
diff --git a/src/subconscious/Game.java b/src/subconscious/Game.java index dc7d109..7fd8b33 100644 --- a/src/subconscious/Game.java +++ b/src/subconscious/Game.java @@ -24,6 +24,7 @@ public class Game { private ArrayList<Actor> actors; private ArrayList<Map> maps; + private Map currentMap; public Game() { this.setState(State.MENU); @@ -39,6 +40,10 @@ public class Game { this.setState(State.DREAM); } + public Map getCurrentMap() { + return currentMap; + } + /* methods to manage the state */ public void setState(State state) { if (this.state == state) @@ -52,9 +57,11 @@ public class Game { return this.state; } - public void waitStateChange() { + public State waitStateChange() { while (!this.stateChanged); this.stateChanged = false; + + return this.state; } /* accessors */ diff --git a/src/subconscious/graphics/GameWindow.java b/src/subconscious/graphics/GameWindow.java index ce99df5..19f8ce1 100644 --- a/src/subconscious/graphics/GameWindow.java +++ b/src/subconscious/graphics/GameWindow.java @@ -88,9 +88,9 @@ public class GameWindow extends JFrame implements ActionListener { // ovserver of this.game private void loop() { while (this.game.isRunning()) { - this.game.waitStateChange(); + Game.State newState = this.game.waitStateChange(); - switch (this.game.getState()) { + switch (newState) { case MENU: this.loadMenu(); break; |