Fixed ghost in-house behaviour
Speed up ghost cape animation
This commit is contained in:
parent
906ef93a11
commit
0d42aac28d
@ -11,9 +11,9 @@
|
|||||||
######*##### ## #####*######
|
######*##### ## #####*######
|
||||||
######*## ##*######
|
######*## ##*######
|
||||||
######*## ^^^__^^^ ##*######
|
######*## ^^^__^^^ ##*######
|
||||||
######*## ^^^^^^^^ ##*######
|
######*## ^ ^ ##*######
|
||||||
------* ^^^^^^^^ *------
|
------* ^ ^ *------
|
||||||
######*## ^^^^^^^^ ##*######
|
######*## ^ ^ ##*######
|
||||||
######*## ^^^^^^^^ ##*######
|
######*## ^^^^^^^^ ##*######
|
||||||
######*## ##*######
|
######*## ##*######
|
||||||
######*## ######## ##*######
|
######*## ######## ##*######
|
||||||
|
@ -33,16 +33,18 @@ public class Ghost extends MovableEntity {
|
|||||||
public Behaviour scatterBehaviour;
|
public Behaviour scatterBehaviour;
|
||||||
public Behaviour frightBehaviour;
|
public Behaviour frightBehaviour;
|
||||||
|
|
||||||
|
public boolean inHouse;
|
||||||
public boolean caught;
|
public boolean caught;
|
||||||
|
|
||||||
public Ghost(PlayState state, float x, float y, Direction direction, int spriteIndex,
|
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);
|
super(state, x, y, GHOST_SPEED, true, direction, 0.1f);
|
||||||
this.state = state;
|
this.state = state;
|
||||||
this.spriteIndex = spriteIndex;
|
this.spriteIndex = spriteIndex;
|
||||||
this.chaseBehaviour = chaseBehaviour;
|
this.chaseBehaviour = chaseBehaviour;
|
||||||
this.scatterBehaviour = scatterBehaviour;
|
this.scatterBehaviour = scatterBehaviour;
|
||||||
this.frightBehaviour = new FrightenedBehaviour(state);
|
this.frightBehaviour = new FrightenedBehaviour(state);
|
||||||
|
this.inHouse = inHouse;
|
||||||
this.caught = false;
|
this.caught = false;
|
||||||
sprite = state.getGame().assets.ghosts;
|
sprite = state.getGame().assets.ghosts;
|
||||||
}
|
}
|
||||||
@ -77,7 +79,7 @@ public class Ghost extends MovableEntity {
|
|||||||
public void update(float dt) {
|
public void update(float dt) {
|
||||||
super.update(dt);
|
super.update(dt);
|
||||||
|
|
||||||
if (age % 20 == 0) {
|
if (age % 15 == 0) {
|
||||||
counter++;
|
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) {
|
if (currentBehaviour == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -254,10 +254,10 @@ public class PlayState extends LevelState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void spawnGhosts() {
|
public void spawnGhosts() {
|
||||||
ghosts[0] = new Ghost(this, 14, 19.5f, Direction.LEFT, 0, new BlinkyChaseBehaviour(this), new StaticTargetBehaviour(this, BLINKY_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));
|
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));
|
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));
|
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++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
ghosts[i].currentBehaviour = ghosts[i].chaseBehaviour;
|
ghosts[i].currentBehaviour = ghosts[i].chaseBehaviour;
|
||||||
|
Loading…
Reference in New Issue
Block a user