Floor.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 class to define another default MapObject, 10 * ie it is enterable by People. 11 * 12 * @see People 13 * @see MapObject 14 * @see Grass 15 * @version 456 16 * @author Matt, Sam 17 */ 18 public class Floor extends MapObject 19 { 20 /** 21 * The Image to display 22 */ 23 protected static Image img; 24 /** 25 * Construct a new Floor, can be Entered, and has 26 * type of MapObject.FLOOR 27 * 28 * @see MapObject 29 * @see Grass 30 */ 31 public Floor() 32 { 33 enterable = true; 34 type = MapObject.FLOOR; 35 } 36 /** 37 * Sets the image to be painted. 38 * Needs to be called before a call to paint occurs. 39 * 40 * @param img the array of images used, need to be of length . 41 */ 42 public void setImage(Image[] img) 43 { 44 if(img.length == 1) 45 this.img = img[0]; 46 } 47 /** 48 * Returns a clone of this 49 * 50 * @return a clone of this 51 */ 52 public MapObject getClone() { return new Floor(); } 53 /** 54 * Draws the Floor 55 * 56 * @param g the Graphics 57 */ 58 public void paint(Graphics g) 59 { 60 g.drawImage(img, 0, 0, this); 61 } 62 }