Implement BinkyScatterBehaviour

This commit is contained in:
Matt Low 2019-12-26 16:26:37 +04:00
parent afad1017a5
commit 0bd4d7f042
2 changed files with 28 additions and 4 deletions

View File

@ -0,0 +1,18 @@
package com.me.pacman.entity.ai;
import com.me.pacman.PacDude;
import com.me.pacman.state.PlayState;
public class BlinkyScatterBehaviour extends Behaviour {
private static final Target target = new Target((PacDude.LEVEL_WIDTH / 8) - 2, PacDude.LEVEL_HEIGHT / 8);
public BlinkyScatterBehaviour(PlayState state) {
super(state);
}
@Override
public Target getTarget() {
return target;
}
}

View File

@ -12,6 +12,7 @@ import com.me.pacman.entity.Direction;
import com.me.pacman.entity.Ghost; import com.me.pacman.entity.Ghost;
import com.me.pacman.entity.Pacman; import com.me.pacman.entity.Pacman;
import com.me.pacman.entity.ai.BlinkyChaseBehaviour; import com.me.pacman.entity.ai.BlinkyChaseBehaviour;
import com.me.pacman.entity.ai.BlinkyScatterBehaviour;
import com.me.pacman.level.Level; import com.me.pacman.level.Level;
import com.me.pacman.level.LevelTile; import com.me.pacman.level.LevelTile;
@ -189,8 +190,9 @@ public class PlayState extends LevelState {
level = new Level(game,"level"); level = new Level(game,"level");
pacman = new Pacman(this, false); pacman = new Pacman(this, false);
ghosts[0] = new Ghost(this, 14, 19.5f, Direction.LEFT, 0, new BlinkyChaseBehaviour(this), null); if (newGameTimer <= 0) {
ghosts[0].currentBehaviour = ghosts[0].chaseBehaviour; placeGhosts();
}
game.assets.siren.stop(sirenId); game.assets.siren.stop(sirenId);
@ -213,8 +215,12 @@ public class PlayState extends LevelState {
random = new Random(897198256012865L); random = new Random(897198256012865L);
pacman = new Pacman(this, false); pacman = new Pacman(this, false);
ghosts[0] = new Ghost(this, 14, 19.5f, Direction.LEFT, 0, new BlinkyChaseBehaviour(this), null); placeGhosts();
ghosts[0].currentBehaviour = ghosts[0].chaseBehaviour; }
public void placeGhosts() {
ghosts[0] = new Ghost(this, 14, 19.5f, Direction.LEFT, 0, new BlinkyChaseBehaviour(this), new BlinkyScatterBehaviour(this));
ghosts[0].currentBehaviour = ghosts[0].scatterBehaviour;
} }
public void startGame() { public void startGame() {