Exemplo n.º 1
0
    /**
     * Constructor
     *
     * @param maze
     */
    public RoomPanel(Room room, int size) {
      if ((this.room = room) == null || size <= 0)
        throw new IllegalArgumentException(
            "Maze or room is null and/or scaleFactor is not positive");

      this.size = size;
      this.setPreferredSize(new Dimension(room.getRoomWidth() * size, room.getRoomHeight() * size));
      this.setDoubleBuffered(true);
    }
Exemplo n.º 2
0
    /** Draw the shapes in the model */
    public void paintComponent(Graphics g) {
      super.paintComponent(g); // clears drawing area

      // draw the background image if one exists
      if (room.hasBackgroundImage()) {
        g.drawImage(room.getBackgroundImage(), 0, 0, this.getWidth(), this.getHeight(), this);
      } else {
        setBackground(room.getBackgroundColor());
      }

      g.setColor(Color.WHITE);
      g.drawString("" + room.getRoomNumber(), size / 2, size / 2);

      if (room == maze.getCurrentRoom()) {
        maze.getPlayer().drawInCenter(g, this.getBounds());
      }
    }