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 enterable MapObject.
10   * 
11   * @see Floor
12   * @see MapObject
13   */
14  public class Grass extends MapObject
15  {
16      /**
17       * The image to display
18       */
19      protected static Image img;
20      /**
21       * Default Constructor to define type and
22       * enterable.
23       */
24      public Grass()
25      {
26          enterable = true;
27          type = MapObject.GRASS;
28      }
29      /**
30       * Sets the image to display.
31       * Needs be called before paint.
32       * 
33       * @param img the array of images to use, needs be length 1.
34       */
35      public void setImage(Image[] img)
36      {
37          if(img.length == 1)
38              this.img = img[0];
39      }
40  
41      /**
42       * Returns a clone of this.
43       * 
44       * @return a clone of this.
45       */
46      public MapObject getClone() { return new Grass(); }
47      /**
48       * Draws the Grass.
49       * 
50       * @param g the Graphics.
51       */
52      public void paint(Graphics g)
53      {
54          g.drawImage(img, 0, 0, this);
55      }
56  }