Oh the vast sweeping changes, and they're not even close to complete, but
things compile and most things run so this is a good time to checkpoint. Let me recall: - Refactored the whole scene deal. - Revamped the XML parser stuff (now uses Digester). - Rethought the tile management. - Started tile bundle stuff. - Wrote some tests. - Did a bit of Mike-ification. Onward and moreward. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@621 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
//
|
||||
// $Id: UniformTileSet.java,v 1.2 2001/11/08 06:58:57 mdb Exp $
|
||||
// $Id: UniformTileSet.java,v 1.3 2001/11/18 04:09:21 mdb Exp $
|
||||
|
||||
package com.threerings.media.tile;
|
||||
|
||||
import java.awt.Image;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
import com.threerings.media.Log;
|
||||
import com.threerings.media.ImageManager;
|
||||
|
||||
@@ -16,39 +18,41 @@ import com.threerings.media.ImageManager;
|
||||
*/
|
||||
public class UniformTileSet extends TileSet
|
||||
{
|
||||
/**
|
||||
* Constructs a tile set object with the specified tileset
|
||||
* configuration parameters.
|
||||
*
|
||||
* @param imgmgr the image manager via which to load the tileset
|
||||
* image.
|
||||
* @param imgPath the path to supply to the image manager when loading
|
||||
* the tile (which will fetch the image using the resource manager).
|
||||
* @param count the number of tiles in the tile image.
|
||||
* @param width the width of each tile, in pixels.
|
||||
* @param height the height of each tile, in pixels.
|
||||
*/
|
||||
public UniformTileSet (ImageManager imgmgr, String imgPath,
|
||||
int count, int width, int height)
|
||||
{
|
||||
super(imgmgr, imgPath, null, 0);
|
||||
|
||||
// keep these for later
|
||||
_count = count;
|
||||
_width = width;
|
||||
_height = height;
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public int getTileCount ()
|
||||
{
|
||||
return _count;
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
protected Image getTileImage (int tileId)
|
||||
/**
|
||||
* Specifies the number of tiles that will be found in the tileset
|
||||
* image managed by this tileset.
|
||||
*/
|
||||
public void setTileCount (int tileCount)
|
||||
{
|
||||
Image tsimg = getTilesetImage();
|
||||
_count = tileCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies the width of the tiles in this tileset.
|
||||
*/
|
||||
public void setWidth (int width)
|
||||
{
|
||||
_width = width;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies the height of the tiles in this tileset.
|
||||
*/
|
||||
public void setHeight (int height)
|
||||
{
|
||||
_height = height;
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
protected Image extractTileImage (int tileId)
|
||||
{
|
||||
BufferedImage tsimg = getTilesetImage();
|
||||
if (tsimg == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -59,8 +63,15 @@ public class UniformTileSet extends TileSet
|
||||
int col = tileId % tilesPerRow;
|
||||
|
||||
// crop the tile-sized image chunk from the full image
|
||||
return _imgmgr.getImageCropped(
|
||||
tsimg, col * _width, row * _height, _width, _height);
|
||||
return tsimg.getSubimage(_width*col, _height*row, _width, _height);
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
protected void toString (StringBuffer buf)
|
||||
{
|
||||
super.toString(buf);
|
||||
buf.append(", width=").append(_width);
|
||||
buf.append(", height=").append(_height);
|
||||
}
|
||||
|
||||
/** The total number of tiles in this tileset. */
|
||||
|
||||
Reference in New Issue
Block a user