Answer To: its a Pacman game on claras world.
Abr Writing answered on Oct 17 2021
Ghost.java
Ghost.java
/**
* Ghost Class
*
* Available functions (see Assignment document for explanations on what each function does):
* treeFront, treeAbove, treeBelow, treeToLeft, treeToRight,
* getDirection, setDirection,
* move,
* isScared,
* animate, animateDead, animateScared,
* getClara, getGhostHealer,
* isAboveMe, isBelowMe, isToMyLeft, isToMyRight,
* makeClaraDead,
* playGhostEatenSound,
* isPacmanIntroStillPlaying,
* wrapAroundWorld
*/
class Ghost extends Character
{
//Add and initialise Ghost variables here
public final String UP = "up";
public final String DOWN = "down";
public final String LEFT = "left";
public final String RIGHT = "right";
public final int moveby = 10;
String[] directions = {UP, DOWN, LEFT, RIGHT};
/**
* Act method, runs on every frame
*/
public void act()
{
//Make the Ghost do things here
int random = Clara.getRandomNumber(4);
String direction = directions[random];
setDirection(direction);
if (!treeFront()) {
move(moveby);
wrapAroundWorld();
}
animate();
if (intersects(getClara())) {
makeClaraDead();
}
}
//Give the Ghost functions here
}
MyClara.java
MyClara.java
/**
* MyClara
*
* Available functions (see Assignment document for explanations on what each function does):
* treeFront, ghostWallFront,
* getDirection, setDirection,
* move,
* makeScared, isScared,
* animate, animateDead,
* onLeaf, removeLeaf,
* onMushroom, removeMushroom,
* allLeavesEaten,
* isClaraDead,
* playC...