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;
|
if (ghost == null || ghost.currentBehaviour instanceof ReturnToBase) continue;
|
||||||
ghost.caught = false;
|
ghost.caught = false;
|
||||||
ghost.currentBehaviour = ghost.chaseBehaviour;
|
ghost.currentBehaviour = ghost.chaseBehaviour;
|
||||||
|
ghost.speed = Ghost.GHOST_SPEED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -188,7 +189,7 @@ public class PlayState extends LevelState {
|
|||||||
if (pacman.deathFrame == 13) {
|
if (pacman.deathFrame == 13) {
|
||||||
if (lives > 0) {
|
if (lives > 0) {
|
||||||
setupGame();
|
setupGame();
|
||||||
readyTimer = 3f;
|
readyTimer = 2f;
|
||||||
} else {
|
} else {
|
||||||
gameOverTimer = 2f;
|
gameOverTimer = 2f;
|
||||||
}
|
}
|
||||||
@ -200,6 +201,18 @@ public class PlayState extends LevelState {
|
|||||||
pacman.update(dt);
|
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() {
|
public void newGame() {
|
||||||
pelletCount = 0;
|
pelletCount = 0;
|
||||||
pelletEatenCount = 0;
|
pelletEatenCount = 0;
|
||||||
@ -207,31 +220,24 @@ public class PlayState extends LevelState {
|
|||||||
lives = 3;
|
lives = 3;
|
||||||
round = 0;
|
round = 0;
|
||||||
|
|
||||||
pacmanCaught = false;
|
|
||||||
deathTimer = 0f;
|
|
||||||
|
|
||||||
newGameTimer = 2.3f;
|
newGameTimer = 2.3f;
|
||||||
|
|
||||||
ghosts = new Ghost[4];
|
|
||||||
pacman = new Pacman(this, false);
|
|
||||||
|
|
||||||
newRound();
|
newRound();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void newRound() {
|
public void newRound() {
|
||||||
round++;
|
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) {
|
if (newGameTimer <= 0) {
|
||||||
spawnGhosts();
|
spawnGhosts();
|
||||||
}
|
}
|
||||||
|
|
||||||
game.assets.siren.stop(sirenId);
|
game.assets.siren.stop(sirenId);
|
||||||
|
|
||||||
pelletCount = level.getTileCount(LevelTile.PELLET);
|
|
||||||
pelletCount += level.getTileCount(LevelTile.POWER_PELLET);
|
|
||||||
|
|
||||||
if (round == 1) {
|
if (round == 1) {
|
||||||
readyTimer = 4.2f;
|
readyTimer = 4.2f;
|
||||||
game.assets.beginning_alt.play(1.0f);
|
game.assets.beginning_alt.play(1.0f);
|
||||||
@ -243,13 +249,7 @@ public class PlayState extends LevelState {
|
|||||||
|
|
||||||
public void setupGame() {
|
public void setupGame() {
|
||||||
lives--;
|
lives--;
|
||||||
pacmanCaught = false;
|
initializeField();
|
||||||
|
|
||||||
frightTimer = 0f;
|
|
||||||
|
|
||||||
random = new Random(897198256012865L);
|
|
||||||
|
|
||||||
pacman = new Pacman(this, false);
|
|
||||||
spawnGhosts();
|
spawnGhosts();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user