mhframework.tilemap
Class MHIsometricMap

java.lang.Object
  extended by mhframework.tilemap.MHTileMap
      extended by mhframework.tilemap.MHIsometricMap
All Implemented Interfaces:
MHRenderable
Direct Known Subclasses:
MHDiamondMap, MHHexMap, MHStaggeredMap

public abstract class MHIsometricMap
extends MHTileMap

Abstract base class for deriving isometric tile maps.


Field Summary
protected  boolean cursorFlasher
           
protected  boolean cursorOn
           
protected  MHIsoMouseMap mouseMap
           
 
Fields inherited from class mhframework.tilemap.MHTileMap
anchorSpace, cursorAddress, cursorAnchor, cursorPoint, DIR_EAST, DIR_NORTH, DIR_NORTHEAST, DIR_NORTHWEST, DIR_SOUTH, DIR_SOUTHEAST, DIR_SOUTHWEST, DIR_WEST, MAX_DIRECTIONS, screenAnchor, screenSpace, worldSpace
 
Constructor Summary
MHIsometricMap(java.lang.String filename, MHObjectFactory vendor)
          Constructor.
 
Method Summary
 void advance()
          Tells an object to update its data.
protected  void drawCursor(java.awt.Graphics g)
           
 int getTileHeight()
          Returns the vertical height of the standard base tile image in this tile map.
 boolean isCursorOn()
          Returns the cursorOn.
 MHMapCellAddress mapMouse(java.awt.Point mousePoint)
          Converts a screen (mouse) coordinate into a map coordinate.
abstract  java.awt.Point plotTile(int row, int column)
          Calculates the pixel position at which the input actor will be rendered.
 void render(java.awt.Graphics2D g)
          Renders the map onto the sent Graphics object using an optimized algorithm.
 void render(java.awt.Graphics2D g, boolean optimized)
          Draws the map onto the sent Graphics object.
 void render(java.awt.Graphics2D g, boolean[] flags)
          Renders the selected layers of the map onto the sent Graphics object using an optimized algorithm.
 void setCursorOn(boolean cursorOn)
          Sets the cursorOn.
protected abstract  MHMapCellAddress tileWalk(int row, int column, int direction)
          Calculates the next map position to which an actor would walk if it were in position (row, column) and travelled in the direction specified by direction.
protected  MHMapCellAddress tileWalk(MHMapCellAddress origin, int direction)
          Calculates the next map position to which an actor would walk if it were in the position specified by origin and travelled in the direction specified by direction.
 
Methods inherited from class mhframework.tilemap.MHTileMap
calculateAnchorSpace, calculateWorldSpace, clipCursorAddress, clipScreenAnchor, getCursorAddress, getCursorPoint, getMapData, getScreenAnchor, getScreenSpace, getTileWidth, isAnchorCoordinate, isScreenCoordinate, isWorldCoordinate, mouseMoved, screenToWorld, scrollMap, setCursorPoint, setScreenAnchor, setScreenAnchor, setScreenSpace, setTileWidth, worldToScreen
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mouseMap

protected MHIsoMouseMap mouseMap

cursorOn

protected boolean cursorOn

cursorFlasher

protected boolean cursorFlasher
Constructor Detail

MHIsometricMap

public MHIsometricMap(java.lang.String filename,
                      MHObjectFactory vendor)
Constructor.

Parameters:
data - A reference to the application's data model.
filename - The name of the map file to be loaded into this tile map.
vendor - A reference to an existing MHObjectVendor for instantiating interactive actor objects.
Method Detail

tileWalk

protected abstract MHMapCellAddress tileWalk(int row,
                                             int column,
                                             int direction)
Calculates the next map position to which an actor would walk if it were in position (row, column) and travelled in the direction specified by direction.

Parameters:
row - The actor's current row position.
column - The actor's current column position.
direction - The direction in which to walk.
Returns:
A point indicating the actor's new column and row position after walking from its original position.

tileWalk

protected MHMapCellAddress tileWalk(MHMapCellAddress origin,
                                    int direction)
Calculates the next map position to which an actor would walk if it were in the position specified by origin and travelled in the direction specified by direction.

Parameters:
origin - The actor's current map cell position.
direction - The direction in which to walk.
Returns:
A point indicating the actor's new column and row position after walking from its original position.

plotTile

public abstract java.awt.Point plotTile(int row,
                                        int column)
Calculates the pixel position at which the input actor will be rendered.

Overrides:
plotTile in class MHTileMap
Parameters:
row - The row of the map containing the actor (tile) to be plotted.
column - The column of the map containing the actor (tile) to be plotted.
Returns:
The pixel position at which the actor will be rendered.

getTileHeight

public int getTileHeight()
Returns the vertical height of the standard base tile image in this tile map.

Overrides:
getTileHeight in class MHTileMap
Returns:
The height of the standard base tile in this map.

mapMouse

public MHMapCellAddress mapMouse(java.awt.Point mousePoint)
Converts a screen (mouse) coordinate into a map coordinate. Uses the five-step mouse mapping algorithm presented in the book Isometric Game Programming with DirectX 7.0 by Ernest Pazera.

Overrides:
mapMouse in class MHTileMap
Parameters:
mousePoint - A point representing a mouse coordinate.
Returns:
The address of the map cell containing the input mouse coordinate.

render

public void render(java.awt.Graphics2D g,
                   boolean optimized)
Draws the map onto the sent Graphics object.

Parameters:
g - The graphics object on which we are rendering the map.
optimized - A flag indicating whether to use the optimized rendering algorithm.

render

public void render(java.awt.Graphics2D g)
Renders the map onto the sent Graphics object using an optimized algorithm.

Specified by:
render in interface MHRenderable
Overrides:
render in class MHTileMap
Parameters:
g - The graphics object on which we are rendering the map.

render

public void render(java.awt.Graphics2D g,
                   boolean[] flags)
Renders the selected layers of the map onto the sent Graphics object using an optimized algorithm.

Parameters:
g - The graphics object on which we are rendering the map.
flags - An array of flags indicating which layers are to be rendered.

drawCursor

protected void drawCursor(java.awt.Graphics g)

advance

public void advance()
Description copied from interface: MHRenderable
Tells an object to update its data.

Specified by:
advance in interface MHRenderable
Overrides:
advance in class MHTileMap

isCursorOn

public boolean isCursorOn()
Returns the cursorOn.

Returns:
boolean

setCursorOn

public void setCursorOn(boolean cursorOn)
Sets the cursorOn.

Parameters:
cursorOn - The cursorOn to set