diff --git a/core/src/com/me/pacman/Constants.java b/core/src/com/me/pacman/Constants.java index f212bea..d584ee7 100644 --- a/core/src/com/me/pacman/Constants.java +++ b/core/src/com/me/pacman/Constants.java @@ -1,5 +1,7 @@ package com.me.pacman; +import com.me.pacman.entity.Direction; + public final class Constants { public static final String TITLE = "Pac-Dude"; @@ -29,4 +31,14 @@ public final class Constants { // and is close to the 75.75757625 pixels/second claimed in: // https://pacman.holenet.info/#LvlSpecs public static final float FULL_SPEED = 9.375f; + + // Ghost spawn directions, should remain constant assuming they always exit the ghost house + // from the top + public static final Direction[] GHOST_SPAWN_DIRS = { + Direction.LEFT, // Blinky + Direction.UP, // Pinky + Direction.DOWN, // Inky + Direction.DOWN, // Clyde + }; + } diff --git a/core/src/com/me/pacman/level/Level.java b/core/src/com/me/pacman/level/Level.java index 32cbf46..1b59530 100644 --- a/core/src/com/me/pacman/level/Level.java +++ b/core/src/com/me/pacman/level/Level.java @@ -7,6 +7,13 @@ import com.me.pacman.PacDude; public class Level { + public static final Vector2[] GHOST_SPAWN_POINTS = { + new Vector2(14f, 19.5f), + new Vector2(14f, 16.5f), + new Vector2(12f, 16.5f), + new Vector2(16f, 16.5f), + }; + private PacDude game; private TextureRegion pellet; diff --git a/core/src/com/me/pacman/state/PlayState.java b/core/src/com/me/pacman/state/PlayState.java index 921ea3d..0fe7fc0 100644 --- a/core/src/com/me/pacman/state/PlayState.java +++ b/core/src/com/me/pacman/state/PlayState.java @@ -22,20 +22,6 @@ import java.util.Random; public class PlayState extends LevelState { - public static final Vector2[] GHOST_SPAWN_POINTS = { - new Vector2(14f, 19.5f), - new Vector2(14f, 16.5f), - new Vector2(12f, 16.5f), - new Vector2(16f, 16.5f), - }; - - public static final Direction[] GHOST_SPAWN_DIRS = { - Direction.LEFT, - Direction.UP, - Direction.DOWN, - Direction.DOWN, - }; - private Texture levelBackground, winBackground; private TextureRegion lifeSprite; @@ -129,17 +115,17 @@ public class PlayState extends LevelState { private void spawnGhosts() { ghosts = new Ghost[4]; - ghosts[0] = new Blinky(this, new Vector2(GHOST_SPAWN_POINTS[0]), GHOST_SPAWN_DIRS[0]); - ghosts[1] = new Pinky(this, new Vector2(GHOST_SPAWN_POINTS[1]), GHOST_SPAWN_DIRS[1]); - ghosts[2] = new Inky(this, new Vector2(GHOST_SPAWN_POINTS[2]), GHOST_SPAWN_DIRS[2]); - ghosts[3] = new Clyde(this, new Vector2(GHOST_SPAWN_POINTS[3]), GHOST_SPAWN_DIRS[3]); + ghosts[0] = new Blinky(this, new Vector2(Level.GHOST_SPAWN_POINTS[0]), Constants.GHOST_SPAWN_DIRS[0]); + ghosts[1] = new Pinky(this, new Vector2(Level.GHOST_SPAWN_POINTS[1]), Constants.GHOST_SPAWN_DIRS[1]); + ghosts[2] = new Inky(this, new Vector2(Level.GHOST_SPAWN_POINTS[2]), Constants.GHOST_SPAWN_DIRS[2]); + ghosts[3] = new Clyde(this, new Vector2(Level.GHOST_SPAWN_POINTS[3]), Constants.GHOST_SPAWN_DIRS[3]); } public void resetGhosts() { for (int i = 0; i < 4; i++) { if (ghosts[i] == null) continue; - ghosts[i].pos = new Vector2(GHOST_SPAWN_POINTS[i]); - ghosts[i].currDirection = GHOST_SPAWN_DIRS[i]; + ghosts[i].pos = new Vector2(Level.GHOST_SPAWN_POINTS[i]); + ghosts[i].currDirection = Constants.GHOST_SPAWN_DIRS[i]; ghosts[i].currentPath = null; ghosts[i].caught = false; ghosts[i].inHouse = i > 0;