Source of HarryPotterDoor.java


  1: 
  2: package maze.harry; 
  3: 
  4: import java.awt.*; 
  5: import maze.*;
  6: 
  7: class HarryPotterDoor extends Door {
  8:   
  9:   public HarryPotterDoor(Room room1, Room room2) { 
 10:     super(room1, room2); 
 11:   }
 12:   
 13:   public void draw(Graphics g, int x, int y, int w, int h) {
 14:     g.setColor(HarryPotterWall.WALL_COLOR); 
 15:     g.fillRect(x, y, w, h); 
 16:     if (orientation == Orientation.VERTICAL) { 
 17:       y += 2 * w; h -= 4 * w;
 18:     } else { 
 19:       x += 2 * h; w -= 4 * h; 
 20:     }
 21:     if (open) { 
 22:       g.setColor(HarryPotterRoom.ROOM_COLOR);
 23:       g.fillRect(x, y, w, h); 
 24:     } else { 
 25:       g.setColor(new Color(139, 69, 0));
 26:       g.fillRect(x, y, w, h); 
 27:       g.setColor(Color.black);
 28:       g.drawRect(x, y, w, h); 
 29:     }    
 30:   }
 31:   
 32: }