Class Game

All Implemented Interfaces:
KeyListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, RootPaneContainer, WindowConstants

public class Game extends JFrame implements KeyListener
A GUI game that involves a professor chasing treasure and goblins chasing the professor.
See Also:
  • Field Details

    • brush

      private Graphics brush
    • display

      private Graphics display
    • canvas

      private Image canvas
      off-screen graphics buffer
    • professor

      private Human professor
      the professor, who is our hero
    • XBOUND

      public static final int XBOUND
      width of window
      See Also:
    • YMIN_DISPLAY

      public static final int YMIN_DISPLAY
      the top 20 pixels (or so) are cut off by the menu bar
      See Also:
    • YBOUND

      public static final int YBOUND
      height of window
      See Also:
    • BACKGROUND_COLOR

      private static final Color BACKGROUND_COLOR
    • FDELAY

      private static final int FDELAY
      See Also:
  • Constructor Details

    • Game

      public Game()
      Creates the GUI, sets up the state for the game
  • Method Details

    • main

      public static void main(String[] args)
    • paint

      public void paint(Graphics g)
      Overrides:
      paint in class Window
    • clearBuffer

      public void clearBuffer()
    • nextFrame

      public void nextFrame(int delay)
      Parameters:
      delay - in ms
    • keyPressed

      public void keyPressed(KeyEvent e)
      Pressing certain keys controls direction of professor
      Specified by:
      keyPressed in interface KeyListener
    • keyReleased

      public void keyReleased(KeyEvent e)
      ignore released keys
      Specified by:
      keyReleased in interface KeyListener
    • keyTyped

      public void keyTyped(KeyEvent e)
      ignore typed keys
      Specified by:
      keyTyped in interface KeyListener
    • play

      public void play()
      plays the game
    • getHuman

      public Human getHuman()
      Returns a copy of the human (the professor) in the Game
      Returns:
      a copy of the human (the professor) in the Game