diff --git a/core/assets/data/level.txt b/core/assets/data/level.txt index 9732f8c..d030b2f 100644 --- a/core/assets/data/level.txt +++ b/core/assets/data/level.txt @@ -11,9 +11,9 @@ ######*##### ## #####*###### ######*## ##*###### ######*## ^^^__^^^ ##*###### -######*## ^^^^^^^^ ##*###### -------* ^^^^^^^^ *------ -######*## ^^^^^^^^ ##*###### +######*## ^ ^ ##*###### +------* ^ ^ *------ +######*## ^ ^ ##*###### ######*## ^^^^^^^^ ##*###### ######*## ##*###### ######*## ######## ##*###### diff --git a/core/src/com/me/pacman/entity/Ghost.java b/core/src/com/me/pacman/entity/Ghost.java index ad2ce1e..dfc1ae5 100644 --- a/core/src/com/me/pacman/entity/Ghost.java +++ b/core/src/com/me/pacman/entity/Ghost.java @@ -33,16 +33,18 @@ public class Ghost extends MovableEntity { public Behaviour scatterBehaviour; public Behaviour frightBehaviour; + public boolean inHouse; public boolean caught; public Ghost(PlayState state, float x, float y, Direction direction, int spriteIndex, - Behaviour chaseBehaviour, Behaviour scatterBehaviour) { + Behaviour chaseBehaviour, Behaviour scatterBehaviour, boolean inHouse) { super(state, x, y, GHOST_SPEED, true, direction, 0.1f); this.state = state; this.spriteIndex = spriteIndex; this.chaseBehaviour = chaseBehaviour; this.scatterBehaviour = scatterBehaviour; this.frightBehaviour = new FrightenedBehaviour(state); + this.inHouse = inHouse; this.caught = false; sprite = state.getGame().assets.ghosts; } @@ -77,7 +79,7 @@ public class Ghost extends MovableEntity { public void update(float dt) { super.update(dt); - if (age % 20 == 0) { + if (age % 15 == 0) { counter++; } @@ -96,6 +98,15 @@ public class Ghost extends MovableEntity { } } + if (inHouse) { + speed = GHOST_TUNNEL_SPEED; + if (pos.y >= 17) { + currDirection = Direction.DOWN; + } else if (pos.y <= 16) { + currDirection = Direction.UP; + } + } + if (currentBehaviour == null) { return; } diff --git a/core/src/com/me/pacman/state/PlayState.java b/core/src/com/me/pacman/state/PlayState.java index d839cbf..3f22d3e 100644 --- a/core/src/com/me/pacman/state/PlayState.java +++ b/core/src/com/me/pacman/state/PlayState.java @@ -254,10 +254,10 @@ public class PlayState extends LevelState { } 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)); - ghosts[3] = new Ghost(this, 16f, 16.5f, Direction.UP, 3, new ClydeChaseBehaviour(this), new StaticTargetBehaviour(this, CLYDE_SCATTER_TARGET)); + ghosts[0] = new Ghost(this, 14, 19.5f, Direction.LEFT, 0, new BlinkyChaseBehaviour(this), new StaticTargetBehaviour(this, BLINKY_SCATTER_TARGET), false); + ghosts[1] = new Ghost(this, 14f, 16.5f, Direction.DOWN, 1, new PinkyChaseBehaviour(this), new StaticTargetBehaviour(this, PINKY_SCATTER_TARGET), true); + ghosts[2] = new Ghost(this, 12f, 16.5f, Direction.UP, 2, new InkyChaseBehaviour(this), new StaticTargetBehaviour(this, INKY_SCATTER_TARGET), true); + ghosts[3] = new Ghost(this, 16f, 16.5f, Direction.UP, 3, new ClydeChaseBehaviour(this), new StaticTargetBehaviour(this, CLYDE_SCATTER_TARGET), true); for (int i = 0; i < 4; i++) { ghosts[i].currentBehaviour = ghosts[i].chaseBehaviour;