Building.java |
1 import java.awt.*; 2 import javax.swing.*; 3 import java.applet.*; 4 import java.awt.image.*; 5 import java.awt.geom.*; 6 import java.net.*; 7 8 /** 9 * Simple non-enterable MapObject used 10 * to denote a building's roof. 11 * 12 * @see MapObject 13 * @author Matt, Sam 14 * @version sqrt(2) 15 */ 16 public class Building extends MapObject 17 { 18 /** 19 * The Image of this. 20 */ 21 protected static Image img; 22 /** 23 * Construct a new Building 24 */ 25 public Building() 26 { 27 enterable = false; 28 type = MapObject.BUILDING; 29 } 30 /** 31 * Sets the Image to be displayed for this. 32 * Needs to be called before paint is called 33 * 34 * @param img the Image to draw. 35 */ 36 public void setImage(Image[] img) 37 { 38 if(img.length == 1) 39 this.img = img[0]; 40 } 41 /** 42 * Returns a clone of this. 43 * 44 * @return MapObject clone of this 45 * @see MapObject 46 */ 47 public MapObject getClone() { return new Building(); } 48 /** 49 * Draw the MapObject. 50 * 51 * @param g the Graphics. 52 */ 53 public void paint(Graphics g) 54 { 55 g.drawImage(img, 0, 0, this); 56 } 57 }