mdh.hephaestus2
Class Tile

java.lang.Object
  |
  +--mdh.hephaestus2.Tile
All Implemented Interfaces:
Serializable

public final class Tile
extends Object
implements Serializable

A simple animated tile.

Author:
Copyright © 2001 by Mark Hughes <kamikaze@kuoi.asui.uidaho.edu>
See Also:
Serialized Form

Constructor Summary
Tile(String basefile, int nfacings, int nframes)
          Creates a new animated tile.
 
Method Summary
 String getBasefile()
          Returns the base filename of the tile.
 int getFrame()
          Returns the current frame being displayed.
 int getHeight()
          Returns the height of the tile in pixels.
 String getIconFilename()
          Returns the filename of the north- (1 facing) or east-(2 or 4 facings) pointing image, for use as an icon.
 BufferedImage getImage(int fa, int fr)
          Returns the image for a given facing and frame.
 int getNFacings()
          Returns the number of facings defined.
 int getNFrames()
          Returns the number of frames defined.
 int getWidth()
          Returns the width of the tile in pixels.
 void setFrame(int f)
          Sets the current frame of the tile, which can be used to individualize many copies of the same tile.
 String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Tile

public Tile(String basefile,
            int nfacings,
            int nframes)
Creates a new animated tile.

Parameters:
basefile - Base filename of the tile. This should be the path relative to the Hephaestus directory, and the filename of the image without the trailing _0n.gif, etc. For example, "images/player/mark" refers to the image files "images/player/mark_0n.gif", "images/player/mark_1n.gif", etc.
nfacings - Number of facings defined for the tile. If nfacings=1, only the north facing image is used, like "images/ground/grass_0n.gif". If nfacings=2, only the east and west facing images are used, like "images/creature/goon_0e.gif", etc. If nfacings=4, all four facing images are used, like "images/player/mark_0n.gif", etc.
nframes - Number of animation frames defined for the tile. Frames are numbered 0..nframes-1, so for a tile which has files ending in "_0n.gif", "_1n.gif", you would have nframes=2 (and nfacings=1).
Method Detail

getBasefile

public String getBasefile()
Returns the base filename of the tile.


getFrame

public int getFrame()
Returns the current frame being displayed.


getHeight

public int getHeight()
Returns the height of the tile in pixels.


getImage

public BufferedImage getImage(int fa,
                              int fr)
Returns the image for a given facing and frame. No validity checking is done, so make sure you compare the arguments to getNFacings() and getNFrames() if you have any doubts.


getNFacings

public int getNFacings()
Returns the number of facings defined.


getNFrames

public int getNFrames()
Returns the number of frames defined.


getIconFilename

public String getIconFilename()
Returns the filename of the north- (1 facing) or east-(2 or 4 facings) pointing image, for use as an icon.


getWidth

public int getWidth()
Returns the width of the tile in pixels.


setFrame

public void setFrame(int f)
Sets the current frame of the tile, which can be used to individualize many copies of the same tile. A row of flags flapping in unison is creepy, while a row of flags each flapping at a different point in their sequence is nifty. By alternating rows of different frames, you can make "waves" in water or fields of grain, etc.


toString

public String toString()
Overrides:
toString in class Object