107 lines
2.5 KiB
Java
107 lines
2.5 KiB
Java
/**
|
|
* <PRE>
|
|
* CNode.java
|
|
*
|
|
* Revisions: 1.0 Nov. 17, 2002
|
|
* Created the CNode class
|
|
* 1.1 Nov. 17, 2002
|
|
* Added Primary code, Commented, Finished
|
|
*
|
|
* </PRE>
|
|
*
|
|
* @author <A HREF="mailto:gtg184g@mail.gatech.edu">Jose Manuel Caban</A>
|
|
* @version Version 1.1, Nov. 17, 2002
|
|
*/
|
|
|
|
/**
|
|
*The Engine class (CEngine) can take in a board and turn it into a game map.
|
|
*The Engine class then creates another grid which will below the game map
|
|
* that holds the nodes for the Intelligence class (CIntelligence).
|
|
*The Node classes hold the data for where a ghost can move and are used to
|
|
* send ghosts after the player. If pacman is between Node A and Node B and
|
|
* a ghost finds itself in Node A, it will turn and head in the direction of
|
|
* Node B. These Intelligence specifics are handled in the
|
|
* CIntelligence->CIntelGhost class
|
|
*/
|
|
public class CNode extends CCoord{
|
|
|
|
/**
|
|
*Define where the ghost can move when at this node
|
|
*/
|
|
private boolean MV_LEFT;
|
|
private boolean MV_RIGHT;
|
|
private boolean MV_UP;
|
|
private boolean MV_DN;
|
|
private boolean INC_HEIGHT;
|
|
|
|
///////////////
|
|
//Constructor//
|
|
///////////////
|
|
|
|
/**
|
|
*@param up, can move up?
|
|
*@param down, can move down?
|
|
*@param left, can move left?
|
|
*@param right, can move right?
|
|
*@param incH, can increase height by using node?
|
|
*@param x, x-coord
|
|
*@param y, y-coord
|
|
*@param h, h-coord
|
|
*/
|
|
public CNode(boolean up, boolean down, boolean left, boolean right,
|
|
boolean incH, int x, int y, int h){
|
|
super(x,y,h);
|
|
MV_UP = up;
|
|
MV_DN = down;
|
|
MV_LEFT = left;
|
|
MV_RIGHT = right;
|
|
INC_HEIGHT = incH;
|
|
}
|
|
|
|
///////////
|
|
//Methods//
|
|
///////////
|
|
|
|
/**
|
|
*@return true if can go up from node
|
|
*/
|
|
public boolean canMV_UP(){
|
|
return MV_UP;
|
|
}
|
|
|
|
/**
|
|
*@return true if can go down from node
|
|
*/
|
|
public boolean canMV_DN(){
|
|
return MV_DN;
|
|
}
|
|
|
|
/**
|
|
*@return true if can move left from node
|
|
*/
|
|
public boolean canMV_LEFT(){
|
|
return MV_LEFT;
|
|
}
|
|
|
|
/**
|
|
*@return true if can move right
|
|
*/
|
|
public boolean canMV_RIGHT(){
|
|
return MV_RIGHT;
|
|
}
|
|
|
|
/**
|
|
*@return true if can increase height at this node
|
|
*/
|
|
public boolean canINC_HEIGHT(){
|
|
return INC_HEIGHT;
|
|
}
|
|
|
|
/**
|
|
*@return Coordinates of the Node
|
|
*/
|
|
public CCoord getNodeCoord(){
|
|
return (new CCoord(this.getX(), this.getY(), this.getH()));
|
|
}
|
|
}// end of class CNode
|