/** *
 *  Ghost.java
 *
 *  Revisions: 1.0 Nov. 12, 2002
 *               Created the Ghost class
 *
 *  
* * Collaboration Statement: * I worked on the homework assignment alone, using only * course materials. * * Created with JCreatorLE, some indents are off when viewed through notepad * or EMACS * * @author Jose Manuel Caban * @version Version 1.0, Nov. 12, 2002 */ public class Ghost extends MoveablePiece{ /** *number of the ghost */ private int ghostNum; /** *true if the ghost is running away from pacman */ private boolean runAwayFlag; /** *Times ghost will run from Pacman */ private int runAwayCount; /** *Starting coordinates of the ghost */ private int startX; private int startY; public Ghost(int x, int y, int ghostNum){ super(x,y); startX = x; startY = y; this.ghostNum = ghostNum; runAwayCount=0; } ///////////// //Accessors// ///////////// /** *@return ghostNumber */ public int getGhostNum(){ return ghostNum; } /** *@return runaway y/n */ public boolean getRunAwayFlag(){ return runAwayFlag; } /** *@return the XstartPos */ public int getStartX(){ return startX; } /** *@return the YstartPos */ public int getStartY(){ return startY; } /////////// //Methods// /////////// /** *Make the ghost run like hell */ public void runAway(){ runAwayFlag = true; runAwayCount = RUN_AWAY_DURATION; } /** *reset the stupid ghost */ public void resetGhost(){ runAwayFlag = false; setPosition(startX,startY); } /** *@param x, the x coord of Pacman *@param y, the y coord of Pacman *@return an array of moves for the ghost */ public int[] getMove(int x, int y){ runAwayCount--; if(runAwayCount<1){ runAwayFlag = false; } if(!runAwayFlag){ return GhostAI.getGhostMove(this.x,this.y,x,y); } else{ int[] array = GhostAI.getGhostMove(this.x,this.y,x,y); int[] tmpArray = new int[array.length]; for(int i=0; i
* @param args a String array of command line arguments. */ public static void main(String[] args) { }// end of main(String[] args) }// end of class Ghost