Give + render points for capturing ghost

Slow frightened ghosts down
This commit is contained in:
Matt Low 2019-12-28 01:19:36 +04:00
parent d33435bf42
commit ac347dc6d8

View File

@ -44,9 +44,12 @@ public class PlayState extends LevelState {
private float gameOverTimer;
private float newGameTimer;
private float deathTimer;
private float pointsTimer;
public float frightTimer;
private boolean pacmanCaught;
private int ghostsCaught;
private Ghost lastGhostCaptured;
public Pacman pacman;
public Ghost[] ghosts;
@ -76,11 +79,15 @@ public class PlayState extends LevelState {
game.batch.draw(lifeSprite, i * 16, 0);
}
pacman.render(game.batch, 0, 16);
if (pointsTimer > 0) {
game.batch.draw(game.assets.points[0][ghostsCaught-1], (lastGhostCaptured.pos.x * 8) - 8, (lastGhostCaptured.pos.y * 8) + 8);
} else {
pacman.render(game.batch, 0, 16);
}
if (pacman.alive) {
for (Ghost ghost : ghosts) {
if (ghost == null) {
if (ghost == null || (pointsTimer > 0 && ghost == lastGhostCaptured)) {
continue;
}
ghost.render(game.batch, 0, 16);
@ -114,6 +121,11 @@ public class PlayState extends LevelState {
dt = 1/60f;
}
pointsTimer -= dt;
if (pointsTimer > 0) {
return;
}
if (gameOverTimer > 0) {
gameOverTimer -= dt;
if (gameOverTimer <= 0) {
@ -212,7 +224,7 @@ public class PlayState extends LevelState {
pacman = new Pacman(this, false);
if (newGameTimer <= 0) {
placeGhosts();
spawnGhosts();
}
game.assets.siren.stop(sirenId);
@ -238,10 +250,10 @@ public class PlayState extends LevelState {
random = new Random(897198256012865L);
pacman = new Pacman(this, false);
placeGhosts();
spawnGhosts();
}
public void placeGhosts() {
public void spawnGhosts() {
ghosts[0] = new Ghost(this, 14, 19.5f, Direction.LEFT, 0, new BlinkyChaseBehaviour(this), new StaticTargetBehaviour(this, BLINKY_SCATTER_TARGET));
ghosts[1] = new Ghost(this, 14f, 16.5f, Direction.DOWN, 1, new PinkyChaseBehaviour(this), new StaticTargetBehaviour(this, PINKY_SCATTER_TARGET));
ghosts[2] = new Ghost(this, 12f, 16.5f, Direction.UP, 2, new InkyChaseBehaviour(this), new StaticTargetBehaviour(this, INKY_SCATTER_TARGET));
@ -284,8 +296,10 @@ public class PlayState extends LevelState {
ghost.caught = false;
ghost.currentBehaviour = ghost.frightBehaviour;
ghost.currDirection = ghost.currDirection.getOpposite();
ghost.speed = Ghost.GHOST_TUNNEL_SPEED;
}
frightTimer = 6f;
ghostsCaught = 0;
score += 50;
}
@ -300,6 +314,11 @@ public class PlayState extends LevelState {
ghost.caught = true;
ghost.currentBehaviour = new ReturnToBase(this);
ghost.speed = Ghost.EYES_SPEED;
lastGhostCaptured = ghost;
ghostsCaught++;
score += ghostsCaught * 200;
pointsTimer = 1f;
}
@Override