Handle spot information in such a way that we can easily tell if a spot

has been provided for an object tile or not.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2260 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2003-02-12 05:33:47 +00:00
parent 03573d2a1e
commit 4db9d58cb4
2 changed files with 6 additions and 85 deletions
@@ -1,80 +0,0 @@
//
// $Id: TileLayer.java,v 1.1 2001/11/18 04:09:21 mdb Exp $
package com.threerings.media.tile;
/**
* The tile layer class is a convenience class provided to simplify the
* management of a two-dimensional array of tiles. It takes care of
* dereferencing the tile array efficiently with methods that the Java
* compiler should inline, and prevents the caller from having to do the
* indexing multiplication by hand every time.
*/
public final class TileLayer
{
/**
* Constructs a tile layer instance with the supplied tiles, width and
* height. The tiles should exist in row-major format (the first row
* of tiles followed by the second and so on).
*
* @exception IllegalArgumentException thrown if the size of the tiles
* array does not match the specified width and height.
*/
public TileLayer (Tile[] tiles, int width, int height)
{
// sanity check
if (tiles.length != width*height) {
String errmsg = "tiles.length != width*height";
throw new IllegalArgumentException(errmsg);
}
_tiles = tiles;
_width = width;
_height = height;
}
/**
* Returns the width of the layer in tiles.
*/
public int getWidth ()
{
return _width;
}
/**
* Returns the height of the layer in tiles.
*/
public int getHeight ()
{
return _height;
}
/**
* Fetches the tile at the specified row and column. Bounds checking
* is not done. Note that the parameters are column first, followed by
* row (x, y order rather than row, column order).
*/
public Tile getTile (int column, int row)
{
return _tiles[row*_width+column];
}
/**
* Sets the tile at the specified row and column. Bounds checking is
* not done. Note that the parameters are column first, followed by
* row (x, y order rather than row, column order).
*/
public void setTile (int column, int row, Tile tile)
{
_tiles[row*_width+column] = tile;
}
/** Our tiles array. */
private Tile[] _tiles;
/** The number of tiles in a row. */
private int _width;
/** The number of rows. */
private int _height;
}
@@ -1,5 +1,5 @@
//
// $Id: TrimmedObjectTileSet.java,v 1.7 2003/02/06 06:23:05 mdb Exp $
// $Id: TrimmedObjectTileSet.java,v 1.8 2003/02/12 05:33:47 mdb Exp $
package com.threerings.media.tile;
@@ -50,11 +50,12 @@ public class TrimmedObjectTileSet extends TileSet
/**
* Returns the orientation of the spot associated with the specified
* tile index.
* tile index, or <code>-1</code> if the object has no associated
* spot.
*/
public int getSpotOrient (int tileIdx)
{
return (_bits == null) ? 0 : _bits[tileIdx].sorient;
return (_bits == null) ? -1 : _bits[tileIdx].sorient;
}
// documentation inherited
@@ -72,7 +73,7 @@ public class TrimmedObjectTileSet extends TileSet
if (_bits != null) {
Bits bits = _bits[tileIndex];
tile.setPriority(bits.priority);
if (bits.xspot != 0 || bits.yspot != 0 || bits.sorient != 0) {
if (bits.sorient != -1) {
tile.setSpot(bits.xspot, bits.yspot, bits.sorient);
}
}
@@ -181,7 +182,7 @@ public class TrimmedObjectTileSet extends TileSet
public short yspot;
/** The orientation of the "spot" associated with this object. */
public byte sorient;
public byte sorient = -1;
/** Generates a string representation of this instance. */
public String toString ()