Initialize all state vars in intializeField before new game
Fixed ghosts remaining frightened at the start of a new round Fixed ghosts staying slow after being frightened Reduce wait time after death to 2 seconds
This commit is contained in:
parent
c32451a597
commit
906ef93a11
@ -158,6 +158,7 @@ public class PlayState extends LevelState {
|
||||
if (ghost == null || ghost.currentBehaviour instanceof ReturnToBase) continue;
|
||||
ghost.caught = false;
|
||||
ghost.currentBehaviour = ghost.chaseBehaviour;
|
||||
ghost.speed = Ghost.GHOST_SPEED;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -188,7 +189,7 @@ public class PlayState extends LevelState {
|
||||
if (pacman.deathFrame == 13) {
|
||||
if (lives > 0) {
|
||||
setupGame();
|
||||
readyTimer = 3f;
|
||||
readyTimer = 2f;
|
||||
} else {
|
||||
gameOverTimer = 2f;
|
||||
}
|
||||
@ -200,6 +201,18 @@ public class PlayState extends LevelState {
|
||||
pacman.update(dt);
|
||||
}
|
||||
|
||||
public void initializeField() {
|
||||
frightTimer = 0f;
|
||||
deathTimer = 0f;
|
||||
pacmanCaught = false;
|
||||
ghostsCaught = 0;
|
||||
lastGhostCaptured = null;
|
||||
|
||||
random = new Random(897198256012865L);
|
||||
ghosts = new Ghost[4];
|
||||
pacman = new Pacman(this, false);
|
||||
}
|
||||
|
||||
public void newGame() {
|
||||
pelletCount = 0;
|
||||
pelletEatenCount = 0;
|
||||
@ -207,31 +220,24 @@ public class PlayState extends LevelState {
|
||||
lives = 3;
|
||||
round = 0;
|
||||
|
||||
pacmanCaught = false;
|
||||
deathTimer = 0f;
|
||||
|
||||
newGameTimer = 2.3f;
|
||||
|
||||
ghosts = new Ghost[4];
|
||||
pacman = new Pacman(this, false);
|
||||
|
||||
newRound();
|
||||
}
|
||||
|
||||
public void newRound() {
|
||||
round++;
|
||||
level = new Level(game,"level");
|
||||
|
||||
pacman = new Pacman(this, false);
|
||||
level = new Level(game,"level");
|
||||
pelletCount = level.getTileCount(LevelTile.PELLET);
|
||||
pelletCount += level.getTileCount(LevelTile.POWER_PELLET);
|
||||
|
||||
initializeField();
|
||||
if (newGameTimer <= 0) {
|
||||
spawnGhosts();
|
||||
}
|
||||
|
||||
game.assets.siren.stop(sirenId);
|
||||
|
||||
pelletCount = level.getTileCount(LevelTile.PELLET);
|
||||
pelletCount += level.getTileCount(LevelTile.POWER_PELLET);
|
||||
|
||||
if (round == 1) {
|
||||
readyTimer = 4.2f;
|
||||
game.assets.beginning_alt.play(1.0f);
|
||||
@ -243,13 +249,7 @@ public class PlayState extends LevelState {
|
||||
|
||||
public void setupGame() {
|
||||
lives--;
|
||||
pacmanCaught = false;
|
||||
|
||||
frightTimer = 0f;
|
||||
|
||||
random = new Random(897198256012865L);
|
||||
|
||||
pacman = new Pacman(this, false);
|
||||
initializeField();
|
||||
spawnGhosts();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user