Skip to content

Commit

Permalink
fixed orange ghost
Browse files Browse the repository at this point in the history
  • Loading branch information
vickiic committed Mar 12, 2018
1 parent 04748e9 commit 88e3d3b
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 88e3d3b

Please sign in to comment.