Package gui

Class MazePanel

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class MazePanel extends JPanel
An instance is responsible for drawing the underlying maze on the screen.
The MazePanel should contain only static images that don't need to change
unless the screen is redrawn.
See Also:
  • Field Details

    • TILE_WIDTH

      public static int TILE_WIDTH
      The width and height (in pixels) of a tile on the grid
    • TILE_HEIGHT

      public static int TILE_HEIGHT
      The width and height (in pixels) of a tile on the grid
    • entrance

      protected final BufferedImage entrance
      Images representing entrance at beginning and a man emerging from hole
    • exitEnd

      protected final BufferedImage exitEnd
      Images representing entrance at beginning and a man emerging from hole
  • Constructor Details

    • MazePanel

      public MazePanel(Sewers sew, int screenWidth, int screenHeight, GUI gui)
      Create a new MazePanel of a given size.
      Parameters:
      sew - The Sewer to display
      screenWidth - The width of the panel, in pixels
      screenHeight - The height of the panel, in pixels
      gui - The GUI that owns this MazePanel
  • Method Details

    • setLighting

      public void setLighting(boolean light)
      Set the sewers to be all light (light = true) or all dark.
    • setVisited

      public void setVisited(int row, int col)
      Update the GUI to inform it that tile (row, col) was visited.
    • getIcon

      public BufferedImage getIcon(Tile.TileType tileType)
      Return an image representing tile type type.
    • getCoinsIcon

      public BufferedImage getCoinsIcon(Node n)
      Return an icon for the coins on tile n, or null if no coins.
    • paintComponent

      public void paintComponent(Graphics page)
      Draw the maze on the screen.
      Overrides:
      paintComponent in class JComponent
    • paintEntranceExit

      public void paintEntranceExit(Graphics page, int row, int col)
      If tile (row, col) is the entrance/exit, draw the graphic for it.