import javax.swing.*; //includes Timer import java.awt.event.*; //ActionListener /** * CS1322: Programming Assignment #6 - Fall 2002 * *
 * IDBox for: PacmanEngine.java
 *
 * Revisions: 1.0 Nov. 24, 2002
 *              Created the PacmanEngine class
 *
 * 
* * Collaboration statement: * "I worked on the homework assignment alone, using only * course materials." * * @author Roland Krystian Alberciak * @version Version 1.0, Nov. 24, 2002 */ // imports are listed above IDBox /* * CONTROLLER */ public class PacmanEngine implements ActionListener, KeyListener { /** Debug value for toggling System.out.* output */ public static boolean DEBUG = false; public static boolean DEBUG_CODE = false; public static boolean DEBUG_MAIN = false; /* // ======================================================================= // Constructors // ======================================================================= */ /** * Constructor 1. Specified default-overriding constructor for PacmanEngine. * @param void No parameters. * @return PacmanEngine instance/object. * public PacmanEngine() { } //end of PacmanEngine() */ /** * Constructor 2. Specified default-overloading constructor for PacmanEngine. * @param void No parameters. * @return PacmanEngine instance/object. */ public PacmanEngine(PacmanFrame pmf, GameBoard gb) { this.setPmf( pmf ); this.setBoard( gb ); this.setGhosts( gb.getPfr().getGhosts() ); this.setPacman( gb.getPfr().getPacman() ); /* GhostTimer= new Timer(P6Constants.GHOST_INTERVAL, ); //add AL PacmanTimer = new Timer(P6Constants.PACMAN_INTERVAL, ); //add AL */ } //end of PacmanEngine() /* // ======================================================================= // Methods which override class Object methods // ======================================================================= */ /** * Equal instance comparison. Compares if two instances are equal. * @param o object-type reference of (hopefully) an PacmanEngine. * @return boolean whether objects are equal. * public boolean equals (Object o) { } //end of equals(Object) */ /** * toString instance printer. Prints properties of PacmanEngine. * @return System.out.println(PacmanEngine instance) instance print. * public String toString() { } //end of toString() */ /* // ======================================================================= // Class specific methods local to this instance (ex: forced by interface) // ======================================================================= */ public void actionPerformed(ActionEvent ae) { int togglePG=0; //CALL REPAINT if( (ae.getSource() instanceof Timer) ==true ) { //Now to determine if moves are legal if ( (ae.getActionCommand()=="PacmanTimer") || (ae.getActionCommand()=="GhostTimer") ) { checkMoveValid( pacman.getDirection(), pacman.getX(), pacman.getY(), this.board.getPieceArray()[pacman.getX()][pacman.getY()] ); } else System.out.println(this.getClass()+" error: wrong Timer."); if (this.legal==true) { if (ae.getActionCommand()=="PacmanTimer") getPacman().move(pacman.getDirection()); if (ae.getActionCommand()=="GhostTimer") { int gMoves[]; for(int itr=0; itr
* @param args a String array of command line arguments. */ public static void main(String[] args) { if ( (args.length==1) && (args[0].equals("-db") ) ) DEBUG_MAIN=true; //else leave false: ignore input. if (DEBUG_MAIN) { // NOTE: This {} encapsulates most of main and is leftmost margin as a flag. // redundant ifs left in, in case the main if(DEBUG) statement was ommitted, // this would then print out neat output, as an example of real running. if (DEBUG) System.out.println("end main(String[] args) call:"); } //end of DEBUG if } //end of main(String[] args) } //end of class PacmanEngine