rlgamekit.map.data
Class LayeredMap

java.lang.Object
  extended by rlgamekit.map.data.LayeredMap

public class LayeredMap
extends java.lang.Object

A rectangular map structure consisting of several layers.


Field Summary
 int layoutType
          0 = isometric 1 = rectangular 2 = isometric, horizontal-run
 
Constructor Summary
LayeredMap(int layerCount, int width, int height)
          Constructs a new layered map with the given size and layer count.
 
Method Summary
 int get(int layer, int x, int y)
          Get the tile/graphics object index for a coordinate
 int getHeight()
           
 int getLayerCount()
           
 java.lang.String getScript(int x, int y)
           
 int getSpawnX()
          Player spawn X coordinate
 int getSpawnY()
          Player spawn Y coordinate
 java.lang.String getTileSetFileName(int layer)
           
 int getWidth()
           
 int getXoff(int layer, int x, int y)
          Tile/graphics objects can be positioned at a certain offset from the map square's center.
 int getYoff(int layer, int x, int y)
          Tile/graphics objects can be positioned at a certain offset from the map square's center.
 void insert(LayeredMap source, int sx, int sy, int width, int height, int dx, int dy)
          Insert an area from a map into this map at a given location.
 void read(java.io.BufferedReader reader)
          Read map data from a text file.
 void set(int layer, int x, int y, int value)
          Set the tile/graphics object index for a coordinate
 void setOutside(int layer, int value)
          Set the value for places outside this map.
 void setScript(int x, int y, java.lang.String script)
           
 void setSpawnX(int x)
          Player spawn X coordinate
 void setSpawnY(int y)
          Player spawn Y coordinate
 void setTileSetFileName(int layer, java.lang.String tileSetFileName)
           
 void setXYoff(int layer, int x, int y, int xoff, int yoff)
          Tile/graphics objects can be positioned at a certain offset from the map square's center.
 void write(java.io.Writer writer)
          Write map data into a text file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

layoutType

public int layoutType
0 = isometric 1 = rectangular 2 = isometric, horizontal-run

Constructor Detail

LayeredMap

public LayeredMap(int layerCount,
                  int width,
                  int height)
Constructs a new layered map with the given size and layer count.

Parameters:
layerCount - The number of layers to construct
width - The x axis extension of the map
height - The y axis extension of the map
Method Detail

getLayerCount

public int getLayerCount()
Returns:
The number of layers in this map

getSpawnX

public int getSpawnX()
Player spawn X coordinate


getSpawnY

public int getSpawnY()
Player spawn Y coordinate


setSpawnX

public void setSpawnX(int x)
Player spawn X coordinate


setSpawnY

public void setSpawnY(int y)
Player spawn Y coordinate


getWidth

public int getWidth()
Returns:
The width (x axis extension) of this map

getHeight

public int getHeight()
Returns:
The height (y axis extension) of this map

getTileSetFileName

public java.lang.String getTileSetFileName(int layer)

setTileSetFileName

public void setTileSetFileName(int layer,
                               java.lang.String tileSetFileName)

get

public int get(int layer,
               int x,
               int y)
Get the tile/graphics object index for a coordinate

Parameters:
layer - The layer, 0 is lowermost layer
x - The X coordinate
y - The Y coordinate

set

public void set(int layer,
                int x,
                int y,
                int value)
Set the tile/graphics object index for a coordinate

Parameters:
layer - The layer, 0 is lowermost layer
x - The X coordinate
y - The Y coordinate
value - The tile/graphics object index to set

setOutside

public void setOutside(int layer,
                       int value)
Set the value for places outside this map.

Parameters:
layer - the map layer to set
value - the outside value to set

getXoff

public int getXoff(int layer,
                   int x,
                   int y)
Tile/graphics objects can be positioned at a certain offset from the map square's center.

Returns:
the offset along the X axis

getYoff

public int getYoff(int layer,
                   int x,
                   int y)
Tile/graphics objects can be positioned at a certain offset from the map square's center.

Returns:
the offset along the Y axis

setXYoff

public void setXYoff(int layer,
                     int x,
                     int y,
                     int xoff,
                     int yoff)
Tile/graphics objects can be positioned at a certain offset from the map square's center.

Parameters:
layer - The layer number of the affected square
x - The X coordinate of the square
y - The Y coordinate of the square
xoff - The offset along the X axis
yoff - the offset along the Y axis

getScript

public java.lang.String getScript(int x,
                                  int y)

setScript

public void setScript(int x,
                      int y,
                      java.lang.String script)

insert

public void insert(LayeredMap source,
                   int sx,
                   int sy,
                   int width,
                   int height,
                   int dx,
                   int dy)
Insert an area from a map into this map at a given location.

Parameters:
source - the map to read from
sx - source x coordinate
sy - source y coordinate
width - width of the area to insert
height - height of the area to insert
dx - destination x coordinate
dy - destination y coordinate

write

public void write(java.io.Writer writer)
           throws java.io.IOException
Write map data into a text file.

Throws:
java.io.IOException

read

public void read(java.io.BufferedReader reader)
          throws java.io.IOException
Read map data from a text file.

Throws:
java.io.IOException