Skip to content

Commit a8d6803

Browse files
Refac
1 parent 2bb3065 commit a8d6803

File tree

11 files changed

+65
-47
lines changed

11 files changed

+65
-47
lines changed

pacman-app-allgames/src/main/java/de/amr/pacmanfx/allgames/app/PacManGames3dApp.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import de.amr.pacmanfx.tengen.ms_pacman.model.TengenMsPacMan_GameModel;
1717
import de.amr.pacmanfx.ui.api.GameUI;
1818
import de.amr.pacmanfx.ui.GameUI_Builder;
19-
import de.amr.pacmanfx.ui.api.DefaultGameVariants;
19+
import de.amr.pacmanfx.model.DefaultGameVariants;
2020
import de.amr.pacmanfx.ui.dashboard.DashboardID;
2121
import javafx.application.Application;
2222
import javafx.stage.Screen;

pacman-app-arcade-mspacman/src/main/java/de/amr/pacmanfx/arcade/ms_pacman/ArcadeMsPacMan_App.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import de.amr.pacmanfx.ui.api.GameUI;
88
import de.amr.pacmanfx.ui.GameUI_Builder;
9-
import de.amr.pacmanfx.ui.api.DefaultGameVariants;
9+
import de.amr.pacmanfx.model.DefaultGameVariants;
1010
import de.amr.pacmanfx.ui.dashboard.DashboardID;
1111
import javafx.application.Application;
1212
import javafx.stage.Screen;

pacman-app-arcade-mspacman/src/main/java/de/amr/pacmanfx/arcade/ms_pacman/ArcadeMsPacMan_StartPage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
package de.amr.pacmanfx.arcade.ms_pacman;
66

77
import de.amr.pacmanfx.ui.api.GameUI;
8-
import de.amr.pacmanfx.ui.api.DefaultGameVariants;
8+
import de.amr.pacmanfx.model.DefaultGameVariants;
99
import de.amr.pacmanfx.ui.layout.StartPage;
1010
import de.amr.pacmanfx.ui.layout.StartPagesView;
1111
import de.amr.pacmanfx.uilib.assets.ResourceManager;

pacman-app-arcade-pacman/src/main/java/de/amr/pacmanfx/arcade/pacman/ArcadePacMan_StartPage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
package de.amr.pacmanfx.arcade.pacman;
66

77
import de.amr.pacmanfx.ui.api.GameUI;
8-
import de.amr.pacmanfx.ui.api.DefaultGameVariants;
8+
import de.amr.pacmanfx.model.DefaultGameVariants;
99
import de.amr.pacmanfx.ui.layout.StartPage;
1010
import de.amr.pacmanfx.ui.layout.StartPagesView;
1111
import de.amr.pacmanfx.uilib.assets.ResourceManager;

pacman-app-arcade-pacman/src/main/java/de/amr/pacmanfx/arcade/pacman/app/ArcadePacMan_App.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import de.amr.pacmanfx.arcade.pacman.ArcadePacMan_UIConfig;
1010
import de.amr.pacmanfx.ui.api.GameUI;
1111
import de.amr.pacmanfx.ui.GameUI_Builder;
12-
import de.amr.pacmanfx.ui.api.DefaultGameVariants;
12+
import de.amr.pacmanfx.model.DefaultGameVariants;
1313
import de.amr.pacmanfx.ui.dashboard.DashboardID;
1414
import javafx.application.Application;
1515
import javafx.stage.Screen;

pacman-app-arcade-pacmanxxl/src/main/java/de/amr/pacmanfx/arcade/pacman_xxl/PacManXXL_Common_App.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
import javafx.stage.Stage;
1313

1414
import static de.amr.pacmanfx.Globals.theGameContext;
15-
import static de.amr.pacmanfx.ui.api.DefaultGameVariants.MS_PACMAN_XXL;
16-
import static de.amr.pacmanfx.ui.api.DefaultGameVariants.PACMAN_XXL;
15+
import static de.amr.pacmanfx.model.DefaultGameVariants.MS_PACMAN_XXL;
16+
import static de.amr.pacmanfx.model.DefaultGameVariants.PACMAN_XXL;
1717

1818
public class PacManXXL_Common_App extends Application {
1919

pacman-app-arcade-pacmanxxl/src/main/java/de/amr/pacmanfx/arcade/pacman_xxl/PacManXXL_Common_StartPageMenu.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import de.amr.pacmanfx.model.actors.Pac;
1313
import de.amr.pacmanfx.ui.api.GameUI;
1414
import de.amr.pacmanfx.ui.api.GameUI_Config;
15-
import de.amr.pacmanfx.ui.api.DefaultGameVariants;
15+
import de.amr.pacmanfx.model.DefaultGameVariants;
1616
import de.amr.pacmanfx.ui._2d.ArcadePalette;
1717
import de.amr.pacmanfx.ui._2d.GameRenderer;
1818
import de.amr.pacmanfx.uilib.widgets.OptionMenu;

pacman-app-tengen-mspacman/src/main/java/de/amr/pacmanfx/tengen/ms_pacman/TengenMsPacMan_StartPage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
package de.amr.pacmanfx.tengen.ms_pacman;
66

77
import de.amr.pacmanfx.ui.api.GameUI;
8-
import de.amr.pacmanfx.ui.api.DefaultGameVariants;
8+
import de.amr.pacmanfx.model.DefaultGameVariants;
99
import de.amr.pacmanfx.ui.layout.StartPage;
1010
import de.amr.pacmanfx.ui.layout.StartPagesView;
1111
import de.amr.pacmanfx.uilib.assets.ResourceManager;

pacman-app-tengen-mspacman/src/main/java/de/amr/pacmanfx/tengen/ms_pacman/app/TengenMsPacMan_App.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import javafx.stage.Stage;
1616

1717
import static de.amr.pacmanfx.tengen.ms_pacman.TengenMsPacMan_UIConfig.NES_ASPECT;
18-
import static de.amr.pacmanfx.ui.api.DefaultGameVariants.MS_PACMAN_TENGEN;
18+
import static de.amr.pacmanfx.model.DefaultGameVariants.MS_PACMAN_TENGEN;
1919

2020
public class TengenMsPacMan_App extends Application {
2121

pacman-core/src/main/java/de/amr/pacmanfx/controller/GameState.java

Lines changed: 54 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import de.amr.pacmanfx.lib.timer.Pulse;
1212
import de.amr.pacmanfx.lib.timer.TickTimer;
1313
import de.amr.pacmanfx.model.AbstractGameModel;
14+
import de.amr.pacmanfx.model.DefaultGameVariants;
1415
import de.amr.pacmanfx.model.GameLevel;
1516
import de.amr.pacmanfx.model.actors.Bonus;
1617
import de.amr.pacmanfx.model.actors.Ghost;
@@ -23,7 +24,8 @@
2324
*/
2425
public enum GameState implements FsmState<GameContext> {
2526

26-
BOOT { // "Das muss das Boot abkönnen!"
27+
// "Das muss das Boot abkönnen!"
28+
BOOT {
2729
@Override
2830
public void onEnter(GameContext context) {
2931
timer.restartIndefinitely();
@@ -62,6 +64,9 @@ public void onUpdate(GameContext context) {
6264
},
6365

6466

67+
/**
68+
* In Tengen Ms. Pac-Man, the credited people are shown.
69+
*/
6570
SHOWING_CREDITS {
6671
@Override
6772
public void onEnter(GameContext context) {
@@ -88,45 +93,57 @@ public void onEnter(GameContext context) {
8893
context.eventManager().publishEvent(GameEventType.STOP_ALL_SOUNDS);
8994
}
9095

96+
private void startNewGame(GameContext context) {
97+
if (timer.tickCount() == 1) {
98+
context.game().startNewGame();
99+
}
100+
else if (timer.tickCount() == 2) {
101+
context.game().startLevel();
102+
}
103+
else if (timer.tickCount() == TICK_NEW_GAME_SHOW_GUYS) {
104+
context.gameLevel().showPacAndGhosts();
105+
}
106+
else if (timer.tickCount() == TICK_NEW_GAME_START_HUNTING) {
107+
context.game().setPlaying(true);
108+
context.gameController().changeGameState(GameState.HUNTING);
109+
}
110+
}
111+
112+
private void continueGame(GameContext context) {
113+
if (timer.tickCount() == 1) {
114+
context.game().continueGame();
115+
} else if (timer.tickCount() == TICK_RESUME_HUNTING) {
116+
context.gameController().changeGameState(GameState.HUNTING);
117+
}
118+
}
119+
120+
private void startDemoLevel(GameContext context) {
121+
if (timer.tickCount() == 1) {
122+
context.game().buildDemoLevel();
123+
context.eventManager().publishEvent(GameEventType.LEVEL_CREATED);
124+
}
125+
else if (timer.tickCount() == 2) {
126+
context.game().startLevel();
127+
}
128+
else if (timer.tickCount() == 3) {
129+
// Now, actor animations are available
130+
context.gameLevel().showPacAndGhosts();
131+
}
132+
else if (timer.tickCount() == TICK_DEMO_LEVEL_START_HUNTING) {
133+
context.gameController().changeGameState(GameState.HUNTING);
134+
}
135+
}
136+
91137
@Override
92138
public void onUpdate(GameContext context) {
93139
if (context.game().isPlaying()) {
94-
if (timer.tickCount() == 1) {
95-
context.game().continueGame();
96-
} else if (timer.tickCount() == TICK_RESUME_HUNTING) {
97-
context.gameController().changeGameState(GameState.HUNTING);
98-
}
140+
continueGame(context);
99141
}
100142
else if (context.game().canStartNewGame()) {
101-
if (timer.tickCount() == 1) {
102-
context.game().startNewGame();
103-
}
104-
else if (timer.tickCount() == 2) {
105-
context.game().startLevel();
106-
}
107-
else if (timer.tickCount() == TICK_NEW_GAME_SHOW_GUYS) {
108-
context.gameLevel().showPacAndGhosts();
109-
}
110-
else if (timer.tickCount() == TICK_NEW_GAME_START_HUNTING) {
111-
context.game().setPlaying(true);
112-
context.gameController().changeGameState(GameState.HUNTING);
113-
}
143+
startNewGame(context);
114144
}
115-
else { // start demo level
116-
if (timer.tickCount() == 1) {
117-
context.game().buildDemoLevel();
118-
context.eventManager().publishEvent(GameEventType.LEVEL_CREATED);
119-
}
120-
else if (timer.tickCount() == 2) {
121-
context.game().startLevel();
122-
}
123-
else if (timer.tickCount() == 3) {
124-
// Now, actor animations are available
125-
context.gameLevel().showPacAndGhosts();
126-
}
127-
else if (timer.tickCount() == TICK_DEMO_LEVEL_START_HUNTING) {
128-
context.gameController().changeGameState(GameState.HUNTING);
129-
}
145+
else {
146+
startDemoLevel(context);
130147
}
131148
}
132149
},
@@ -185,14 +202,15 @@ public void onUpdate(GameContext context) {
185202
}
186203

187204
//TODO this is crap. Maybe Tengen Ms. Pac-Man needs its own state machine?
188-
if (context.gameController().isSelected("MS_PACMAN_TENGEN") && context.gameLevel().isDemoLevel()) {
205+
if (context.gameController().isSelected(DefaultGameVariants.MS_PACMAN_TENGEN.name())
206+
&& context.gameLevel().isDemoLevel()) {
189207
context.gameController().changeGameState(SHOWING_CREDITS);
190208
return;
191209
}
192210

193211
if (timer.hasExpired()) {
194212
if (context.gameLevel().isDemoLevel()) {
195-
// just in case: if demo level is complete, go back to intro scene
213+
// just in case: if demo level was completed, go back to intro scene
196214
context.gameController().changeGameState(INTRO);
197215
} else if (context.game().cutScenesEnabled()
198216
&& context.game().cutSceneNumber(context.gameLevel().number()).isPresent()) {

0 commit comments

Comments
 (0)