first commit
This commit is contained in:
131
CS1322/p6/PacmanFrame.java
Normal file
131
CS1322/p6/PacmanFrame.java
Normal file
@@ -0,0 +1,131 @@
|
||||
/**
|
||||
* CS1322: Programming Assignment #6 - Fall 2002
|
||||
*
|
||||
* <PRE>
|
||||
* IDBox for: PacmanFrame.java
|
||||
*
|
||||
* Revisions: 1.0 Nov. 24, 2002
|
||||
* Created the PacmanFrame class
|
||||
* 1.1 Nov. 26, 2002
|
||||
* Compiled, Finished, Done
|
||||
*
|
||||
* </PRE>
|
||||
*
|
||||
* Collaboration statement:
|
||||
* I worked on this assignment with Roland Krystian Alberciak
|
||||
*
|
||||
* @author
|
||||
*<A HREF="mailto:gtg142g@mail.gatech.edu">Roland Krystian Alberciak</A>
|
||||
*@author <A HREF="mailto:gtg184g@mail.gatech.edu">Jose Manuel Caban</A>
|
||||
*@version Version 1.1, Nov. 24, 2002
|
||||
*/
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
|
||||
public class PacmanFrame extends JFrame implements ActionListener{
|
||||
|
||||
/**
|
||||
*Stores the gameboard
|
||||
*/
|
||||
private GameBoard cGameBoard;
|
||||
|
||||
/**
|
||||
*Variables to hold GUI sh...stuff
|
||||
*/
|
||||
private JMenu cGameMenu;
|
||||
private JMenuItem jNewGame;
|
||||
private JMenuItem jExitGame; //why the heck would you want to do that!!
|
||||
private JMenuBar jMenuBar;
|
||||
|
||||
/**
|
||||
*holds the Pacman Engine
|
||||
*/
|
||||
private PacmanEngine pacEngine;
|
||||
|
||||
////////////////
|
||||
//Constructors//
|
||||
////////////////
|
||||
|
||||
/**
|
||||
*PacmanFrame Default Constructor
|
||||
*Basically sets up the game
|
||||
*/
|
||||
public PacmanFrame(){
|
||||
super("Pacman: the Cheap Way");
|
||||
super.getContentPane().setLayout(new BorderLayout());
|
||||
|
||||
this.cGameBoard = new GameBoard(P6Constants.BOARD_FILE);
|
||||
super.getContentPane().add(cGameBoard,BorderLayout.CENTER);
|
||||
|
||||
this.initGUI();
|
||||
setSize(520,520);
|
||||
setResizable(false);
|
||||
setDefaultCloseOperation(EXIT_ON_CLOSE);
|
||||
super.show();
|
||||
pacEngine = new PacmanEngine(this,cGameBoard);
|
||||
//pacEngine.addKeyListener(this);
|
||||
}
|
||||
|
||||
/**
|
||||
*Initialize GUI
|
||||
*/
|
||||
private void initGUI(){
|
||||
jNewGame = new JMenuItem("New Game");
|
||||
jExitGame = new JMenuItem("Close");
|
||||
jMenuBar = new JMenuBar();
|
||||
|
||||
cGameMenu = new JMenu("File");
|
||||
|
||||
cGameMenu.add(jNewGame);
|
||||
cGameMenu.add(jExitGame);
|
||||
|
||||
jMenuBar.add(cGameMenu);
|
||||
|
||||
super.setJMenuBar(jMenuBar);
|
||||
|
||||
jNewGame.addActionListener(this);
|
||||
jExitGame.addActionListener(this);
|
||||
cGameMenu.addActionListener(this);
|
||||
}
|
||||
|
||||
|
||||
///////////
|
||||
//Methods//
|
||||
///////////
|
||||
|
||||
/**
|
||||
*Action Method
|
||||
*/
|
||||
public void actionPerformed(ActionEvent ae){
|
||||
if(ae.getSource() instanceof JMenuItem){
|
||||
if(ae.getActionCommand().equals("New Game")){
|
||||
System.out.println("Restarting Game...");
|
||||
setVisible(false);
|
||||
this.dispose();
|
||||
new PacmanFrame();
|
||||
}
|
||||
else if(ae.getActionCommand().equals("Close")){
|
||||
System.out.println("User Command: Exit...@##&%($");
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}//end actionPerformed
|
||||
|
||||
/**
|
||||
*@return the GameBoard
|
||||
*/
|
||||
public GameBoard getGB(){
|
||||
return cGameBoard;
|
||||
}
|
||||
|
||||
public static void main(String args[]){
|
||||
PacmanFrame pf = new PacmanFrame();
|
||||
}//end main()
|
||||
|
||||
} //end of class PacmanFrame
|
||||
Reference in New Issue
Block a user