Browse Source

added the collision function player vs Ghosts

remotes/origin/ghostsbehaviour
fdai2751 11 months ago
parent
commit
9ffc4af8df
  1. 10
      src/main/java/pacmanGame/GhostBehaviorRandom.java

10
src/main/java/pacmanGame/GhostBehaviorRandom.java

@ -1,7 +1,9 @@
package pacmanGame;
import java.util.Random;
public class GhostBehaviorRandom implements GhostBehavior {
public int player;
public int ghost;
public boolean isPlayerAlive = true;
@Override
public Vector2 GetDirection(Ghost ghost) {
Random random = new Random();
@ -20,5 +22,9 @@ public class GhostBehaviorRandom implements GhostBehavior {
}
return null;
}
public void checkCollision() {
if (player == ghost) {
isPlayerAlive = false;
}
}
}
Loading…
Cancel
Save