Skip to content

Commit

Permalink
Merge pull request #9 from Aregluss/animation
Browse files Browse the repository at this point in the history
fixed orange ghost
  • Loading branch information
vickiic authored Mar 12, 2018
2 parents 04748e9 + 88e3d3b commit 9d7e326
Showing 1 changed file with 4 additions and 23 deletions.
27 changes: 4 additions & 23 deletions src/edu/ucsb/cs56/projects/games/pacman/Ghost.java
Original file line number Diff line number Diff line change
Expand Up @@ -376,29 +376,10 @@ else if (aheadY < 0)
}
else if (type == TYPE_ORANGE) {
distance = Math.sqrt(Math.pow(this.x - p.x, 2.0) + Math.pow(this.y - p.y, 2.0));
if(distance>8.0){
int aheadX = p.x;
int aheadY = p.y;
PacPlayer pacman = (PacPlayer)p;
if (pacman.direction == Direction.LEFT)
aheadX = p.x - 4;
else if (pacman.direction == Direction.UP)
aheadX = p.y - 4;
else if (pacman.direction == Direction.RIGHT)
aheadX = p.x + 4;
else
aheadY= p.y + 4;

if(aheadX > 16)
aheadX = 16;
else if(aheadX < 0)
aheadX = 0;
if(aheadY > 16)
aheadY = 16;
else if (aheadY < 0)
aheadY = 0;
distance = Math.sqrt(Math.pow(this.x - aheadX, 2.0) + Math.pow(this.y - aheadY, 2.0));
}
if(distance<8.0){
if(Math.random() < 0.5)
moveRandom(grid);
}
else
distance = Math.sqrt(Math.pow(this.x - p.x, 2.0) + Math.pow(this.y - p.y, 2.0));
}
Expand Down

0 comments on commit 9d7e326

Please sign in to comment.