Switch to new unified direction constants.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@818 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2001-12-17 03:34:04 +00:00
parent f51a2e0d0c
commit 7d079a2bec
12 changed files with 87 additions and 178 deletions
@@ -1,5 +1,5 @@
//
// $Id: Sprite.java,v 1.31 2001/11/02 01:09:08 shaper Exp $
// $Id: Sprite.java,v 1.32 2001/12/17 03:32:52 mdb Exp $
package com.threerings.media.sprite;
@@ -8,34 +8,15 @@ import java.util.ArrayList;
import java.util.Iterator;
import com.threerings.media.Log;
import com.threerings.util.DirectionCodes;
/**
* The sprite class represents a single moveable object in an animated
* view. A sprite has a position within the view, and a set of images
* used to render it (perhaps multiple frames for animation).
*/
public class Sprite
public class Sprite implements DirectionCodes
{
/** The number of distinct directions. */
public static final int NUM_DIRECTIONS = 8;
/** Direction constants. */
public static final int DIR_NONE = -1;
public static final int DIR_SOUTHWEST = 0;
public static final int DIR_WEST = 1;
public static final int DIR_NORTHWEST = 2;
public static final int DIR_NORTH = 3;
public static final int DIR_NORTHEAST = 4;
public static final int DIR_EAST = 5;
public static final int DIR_SOUTHEAST = 6;
public static final int DIR_SOUTH = 7;
/** String translations for the direction constants. */
public static String[] XLATE_DIRS = {
"Southwest", "West", "Northwest", "North", "Northeast",
"East", "Southeast", "South"
};
/** Default frame rate. */
public static final int DEFAULT_FRAME_RATE = 15;
@@ -160,10 +141,10 @@ public class Sprite
/**
* Sprites have an orientation in one of the eight cardinal
* directions: <code>DIR_NORTH</code>, <code>DIR_NORTHEAST</code>,
* etc. Sprite derived classes can choose to override this member
* function and select a different set of images based on their
* orientation, or they can ignore the orientation information.
* directions: <code>NORTH</code>, <code>NORTHEAST</code>, etc. Sprite
* derived classes can choose to override this member function and
* select a different set of images based on their orientation, or
* they can ignore the orientation information.
*/
public void setOrientation (int orient)
{
@@ -172,8 +153,7 @@ public class Sprite
/**
* Returns the sprite's orientation as one of the eight cardinal
* directions: <code>DIR_NORTH</code>, <code>DIR_NORTHEAST</code>,
* etc.
* directions: <code>NORTH</code>, <code>NORTHEAST</code>, etc.
*/
public int getOrientation ()
{
@@ -530,7 +510,7 @@ public class Sprite
protected int _frameIdx;
/** The orientation of this sprite. */
protected int _orient = DIR_NONE;
protected int _orient = NONE;
/** The location of the sprite in pixel coordinates. */
protected int _x, _y;
@@ -1,5 +1,5 @@
//
// $Id: LineSegmentPath.java,v 1.13 2001/12/16 08:05:46 mdb Exp $
// $Id: LineSegmentPath.java,v 1.14 2001/12/17 03:32:52 mdb Exp $
package com.threerings.media.sprite;
@@ -208,7 +208,7 @@ public class LineSegmentPath implements Path
for (int ii = 0; ii < size; ii++) {
Point p = (Point)points.get(ii);
int dir = (ii == 0) ? Sprite.DIR_NORTH : getDirection(last, p);
int dir = (ii == 0) ? Sprite.NORTH : getDirection(last, p);
addNode(p.x, p.y, dir);
last = p;
}
@@ -243,24 +243,24 @@ public class LineSegmentPath implements Path
protected int getDirection (Point a, Point b)
{
if (a.x == b.x && a.y > b.y) {
return Sprite.DIR_NORTH;
return Sprite.NORTH;
} else if (a.x < b.x && a.y > b.y) {
return Sprite.DIR_NORTHEAST;
return Sprite.NORTHEAST;
} else if (a.x > b.x && a.y == b.y) {
return Sprite.DIR_EAST;
return Sprite.EAST;
} else if (a.x > b.x && a.y < b.y) {
return Sprite.DIR_SOUTHEAST;
return Sprite.SOUTHEAST;
} else if (a.x == b.x && a.y < b.y) {
return Sprite.DIR_SOUTH;
return Sprite.SOUTH;
} else if (a.x > b.x && a.y < b.y) {
return Sprite.DIR_SOUTHWEST;
return Sprite.SOUTHWEST;
} else if (a.x > b.x && a.y == b.y) {
return Sprite.DIR_WEST;
return Sprite.WEST;
} else if (a.x > b.x && a.y > b.y) {
return Sprite.DIR_NORTHWEST;
return Sprite.NORTHWEST;
}
return Sprite.DIR_NONE;
return Sprite.NONE;
}
/** The nodes that make up the path. */