Moved tile edge length into IsoSceneView since it's specific to
rendering the tiles from an isometric perspective. Added comments and minor clean-up. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@88 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: Tile.java,v 1.5 2001/07/18 22:45:35 shaper Exp $
|
// $Id: Tile.java,v 1.6 2001/07/20 08:17:10 shaper Exp $
|
||||||
|
|
||||||
package com.threerings.miso.tile;
|
package com.threerings.miso.tile;
|
||||||
|
|
||||||
@@ -24,21 +24,6 @@ public class Tile
|
|||||||
public static final int HALF_HEIGHT = HEIGHT / 2;
|
public static final int HALF_HEIGHT = HEIGHT / 2;
|
||||||
public static final int HALF_WIDTH = WIDTH / 2;
|
public static final int HALF_WIDTH = WIDTH / 2;
|
||||||
|
|
||||||
public static final float EDGE_LENGTH = (float)
|
|
||||||
Math.sqrt((HALF_WIDTH * HALF_WIDTH) + (HALF_HEIGHT * HALF_HEIGHT));
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct a new tile with the specified identifiers. Intended
|
|
||||||
* only for use by the TileManager. Do not use this method.
|
|
||||||
*
|
|
||||||
* @see com.threerings.miso.TileManager#getTile
|
|
||||||
*/
|
|
||||||
public Tile (short tsid, short tid)
|
|
||||||
{
|
|
||||||
this.tsid = tsid;
|
|
||||||
this.tid = tid;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new tile with the specified identifiers. Intended
|
* Construct a new tile with the specified identifiers. Intended
|
||||||
* only for use by the TileManager. Do not use this method.
|
* only for use by the TileManager. Do not use this method.
|
||||||
@@ -51,6 +36,9 @@ public class Tile
|
|||||||
this.tid = (short) tid;
|
this.tid = (short) tid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a string representation of the tile information.
|
||||||
|
*/
|
||||||
public String toString ()
|
public String toString ()
|
||||||
{
|
{
|
||||||
StringBuffer buf = new StringBuffer();
|
StringBuffer buf = new StringBuffer();
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: TileSet.java,v 1.8 2001/07/18 22:45:35 shaper Exp $
|
// $Id: TileSet.java,v 1.9 2001/07/20 08:17:10 shaper Exp $
|
||||||
|
|
||||||
package com.threerings.miso.tile;
|
package com.threerings.miso.tile;
|
||||||
|
|
||||||
@@ -15,20 +15,22 @@ import java.awt.image.*;
|
|||||||
* provides a clean interface for the TileManager to retrieve
|
* provides a clean interface for the TileManager to retrieve
|
||||||
* individual tile images from a particular tile in the tileset.
|
* individual tile images from a particular tile in the tileset.
|
||||||
*
|
*
|
||||||
* The width of each tile in every tileset is a constant Tile.WIDTH in
|
* <p> The width of each tile in every tileset is a constant
|
||||||
* pixels. The tile count in each row can vary. The height of the
|
* Tile.WIDTH in pixels. The tile count in each row can vary. The
|
||||||
* tiles in each row can also vary. This information is obtained from
|
* height of the tiles in each row can also vary. This information is
|
||||||
* the config object.
|
* obtained from the config object.
|
||||||
*
|
*
|
||||||
* Tiles are retrieved from the tile set by the TileManager, and are
|
* <p> Tiles are retrieved from the tile set by the TileManager, and
|
||||||
* referenced by their tile id (essentially the tile number, assuming
|
* are referenced by their tile id (essentially the tile number,
|
||||||
* the tile at the top-left of the image is tile id 0 and tiles are
|
* assuming the tile at the top-left of the image is tile id 0 and
|
||||||
* numbered left to right, top to bottom, in ascending order.
|
* tiles are numbered left to right, top to bottom, in ascending
|
||||||
*
|
* order.
|
||||||
* @see com.threerings.miso.TileManager
|
|
||||||
*/
|
*/
|
||||||
public class TileSet
|
public class TileSet
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Construct a new TileSet object with the given parameters.
|
||||||
|
*/
|
||||||
public TileSet (String name, int tsid, String imgFile,
|
public TileSet (String name, int tsid, String imgFile,
|
||||||
int[] rowHeight, int[] tileCount)
|
int[] rowHeight, int[] tileCount)
|
||||||
{
|
{
|
||||||
@@ -43,16 +45,25 @@ public class TileSet
|
|||||||
_numTiles += _tileCount[ii];
|
_numTiles += _tileCount[ii];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the tileset identifier.
|
||||||
|
*/
|
||||||
public int getId ()
|
public int getId ()
|
||||||
{
|
{
|
||||||
return _tsid;
|
return _tsid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the tileset name.
|
||||||
|
*/
|
||||||
public String getName ()
|
public String getName ()
|
||||||
{
|
{
|
||||||
return _name;
|
return _name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the number of tiles in the tileset.
|
||||||
|
*/
|
||||||
public int getNumTiles ()
|
public int getNumTiles ()
|
||||||
{
|
{
|
||||||
return _numTiles;
|
return _numTiles;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: IsoSceneView.java,v 1.12 2001/07/20 07:09:56 shaper Exp $
|
// $Id: IsoSceneView.java,v 1.13 2001/07/20 08:17:10 shaper Exp $
|
||||||
|
|
||||||
package com.threerings.miso.scene;
|
package com.threerings.miso.scene;
|
||||||
|
|
||||||
@@ -215,13 +215,13 @@ public class IsoSceneView implements SceneView
|
|||||||
int xdist = (int)
|
int xdist = (int)
|
||||||
MathUtil.distance(_lineX[0].x, _lineX[0].y,
|
MathUtil.distance(_lineX[0].x, _lineX[0].y,
|
||||||
_lineY[1].x, _lineY[1].y);
|
_lineY[1].x, _lineY[1].y);
|
||||||
tpos.x = (int)(xdist / Tile.EDGE_LENGTH);
|
tpos.x = (int)(xdist / TILE_EDGE_LENGTH);
|
||||||
|
|
||||||
// determine distance of mouse pos along the y-axis
|
// determine distance of mouse pos along the y-axis
|
||||||
int ydist = (int)
|
int ydist = (int)
|
||||||
MathUtil.distance(_lineY[0].x, _lineY[0].y,
|
MathUtil.distance(_lineY[0].x, _lineY[0].y,
|
||||||
_lineY[1].x, _lineY[1].y);
|
_lineY[1].x, _lineY[1].y);
|
||||||
tpos.y = (int)(ydist / Tile.EDGE_LENGTH);
|
tpos.y = (int)(ydist / TILE_EDGE_LENGTH);
|
||||||
|
|
||||||
// Log.info("[mX="+mX+", bX="+bX+", mY="+mY+", bY="+bY+"]");
|
// Log.info("[mX="+mX+", bX="+bX+", mY="+mY+", bY="+bY+"]");
|
||||||
// Log.info("x-axis=" + MathUtil.lineToString(_lineX[0], _lineX[1]));
|
// Log.info("x-axis=" + MathUtil.lineToString(_lineX[0], _lineX[1]));
|
||||||
@@ -258,6 +258,11 @@ public class IsoSceneView implements SceneView
|
|||||||
protected static final int DEF_CENTER_X = DEF_BOUNDS_WIDTH / 2;
|
protected static final int DEF_CENTER_X = DEF_BOUNDS_WIDTH / 2;
|
||||||
protected static final int DEF_CENTER_Y = -(9 * Tile.HEIGHT);
|
protected static final int DEF_CENTER_Y = -(9 * Tile.HEIGHT);
|
||||||
|
|
||||||
|
// length of a tile edge as rendered from an isometric perspective
|
||||||
|
public static final float TILE_EDGE_LENGTH = (float)
|
||||||
|
Math.sqrt((Tile.HALF_WIDTH * Tile.HALF_WIDTH) +
|
||||||
|
(Tile.HALF_HEIGHT * Tile.HALF_HEIGHT));
|
||||||
|
|
||||||
protected Point _lineX[], _lineY[];
|
protected Point _lineX[], _lineY[];
|
||||||
|
|
||||||
protected Rectangle _bounds;
|
protected Rectangle _bounds;
|
||||||
|
|||||||
Reference in New Issue
Block a user