import javax.swing.*; import java.awt.*; /** * Creates the drawing panel, listens for the key event, * and is the window the game is observed in * * @author * @version November 2, 2017 * Lab 11 */ public class GameFrame extends JFrame { /** Useful for serialization purposes (coming soon!) */ private static final long serialVersionUID = 1L; /** panel where the game is drawn */ private GamePanel panel; /** * constructor for the window to observe the game * * @param superhero Reference to the current superhero being played * @param width Width of window in pixels * @param height Height of window in pixels */ public GameFrame(Superhero superhero, int width, int height) { panel = new GamePanel(width, height, superhero); add(panel); // Set information about the JFrame getContentPane().setPreferredSize(new Dimension(width, height)); setDefaultCloseOperation(EXIT_ON_CLOSE); setTitle("Super Showdown"); pack(); setVisible(true); // TODO: Listen for arrow key input (add action listener) // TODO: Don't move the player if the villain is caught // TODO: Move the player based on the key pressed /* TODO: if the space is available, in the desired direction, update the player's position */ // TODO: redraw the player // TODO: Check if the player has caught the villain } /** * get the panel with the game objects * * @return panel GamePanel that draws the game objects */ public GamePanel getPanel() { return panel; } }