Modified animation manager to provide a timestamp with every tick.

Modified sprite and path code to make use of these timestamps to determine
a sprite's progress along the path. Abstracted the path stuff so that
paths other than line segment paths can be cleanly implemented.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@337 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2001-09-13 19:10:26 +00:00
parent 2fc86f89b3
commit 780e39d4e9
11 changed files with 410 additions and 321 deletions
@@ -1,5 +1,5 @@
//
// $Id: IsoSceneView.java,v 1.53 2001/08/29 19:50:46 shaper Exp $
// $Id: IsoSceneView.java,v 1.54 2001/09/13 19:10:26 mdb Exp $
package com.threerings.miso.scene;
@@ -618,7 +618,8 @@ public class IsoSceneView implements EditableSceneView
// to second tile, and penultimate to ultimate tile.
// construct path with starting screen position
Path path = new Path(sprite.getX(), sprite.getY());
LineSegmentPath path =
new LineSegmentPath(sprite.getX(), sprite.getY());
// add all nodes on the calculated path
Point nspos = new Point();
@@ -1,9 +1,9 @@
//
// $Id: Location.java,v 1.5 2001/08/14 23:35:22 mdb Exp $
// $Id: Location.java,v 1.6 2001/09/13 19:10:26 mdb Exp $
package com.threerings.miso.scene;
import com.threerings.media.sprite.Path;
import com.threerings.media.sprite.Sprite;
/**
* The <code>Location</code> class represents a unique well-defined
@@ -45,7 +45,7 @@ public class Location
{
this.x = x;
this.y = y;
this.orient = Path.DIR_SOUTHWEST;
this.orient = Sprite.DIR_SOUTHWEST;
}
/**
@@ -1,12 +1,12 @@
//
// $Id: IsoUtil.java,v 1.5 2001/08/15 22:16:43 shaper Exp $
// $Id: IsoUtil.java,v 1.6 2001/09/13 19:10:26 mdb Exp $
package com.threerings.miso.scene.util;
import java.awt.Point;
import java.awt.Polygon;
import com.threerings.media.sprite.Path;
import com.threerings.media.sprite.Sprite;
import com.threerings.media.util.MathUtil;
import com.threerings.miso.Log;
@@ -28,7 +28,7 @@ public class IsoUtil
* @param bx the x-position of point B.
* @param by the y-position of point B.
*
* @return the direction specified as one of the <code>Path</code>
* @return the direction specified as one of the <code>Sprite</code>
* class's direction constants.
*/
public static int getDirection (
@@ -50,7 +50,7 @@ public class IsoUtil
// compare tile coordinates to determine direction
int dir = getIsoDirection(tax, tay, tbx, tby);
if (dir != Path.DIR_NONE) return dir;
if (dir != Sprite.DIR_NONE) return dir;
// destination point is in the same tile as the
// origination point, so consider fine coordinates
@@ -66,7 +66,7 @@ public class IsoUtil
dir = getIsoDirection(fax, fay, fbx, fby);
// arbitrarily return southwest if fine coords were also equivalent
return (dir == -1) ? Path.DIR_SOUTHWEST : dir;
return (dir == -1) ? Sprite.DIR_SOUTHWEST : dir;
}
/**
@@ -81,23 +81,23 @@ public class IsoUtil
* @param bx the x-position of point B.
* @param by the y-position of point B.
*
* @return the direction specified as one of the <code>Path</code>
* class's direction constants, or <code>Path.DIR_NONE</code>
* @return the direction specified as one of the <code>Sprite</code>
* class's direction constants, or <code>Sprite.DIR_NONE</code>
* if point B is equivalent to point A.
*/
public static int getIsoDirection (int ax, int ay, int bx, int by)
{
if (bx > ax) {
if (by == ay) return Path.DIR_SOUTH;
return (by < ay) ? Path.DIR_SOUTHEAST : Path.DIR_SOUTHWEST;
if (by == ay) return Sprite.DIR_SOUTH;
return (by < ay) ? Sprite.DIR_SOUTHEAST : Sprite.DIR_SOUTHWEST;
} else if (bx == ax) {
if (by == ay) return Path.DIR_NONE;
return (by < ay) ? Path.DIR_EAST : Path.DIR_WEST;
if (by == ay) return Sprite.DIR_NONE;
return (by < ay) ? Sprite.DIR_EAST : Sprite.DIR_WEST;
} else { // bx < ax
if (by == ay) return Path.DIR_NORTH;
return (by < ay) ? Path.DIR_NORTHEAST : Path.DIR_NORTHWEST;
if (by == ay) return Sprite.DIR_NORTH;
return (by < ay) ? Sprite.DIR_NORTHEAST : Sprite.DIR_NORTHWEST;
}
}
@@ -1,12 +1,12 @@
//
// $Id: TileUtil.java,v 1.4 2001/09/05 00:44:37 shaper Exp $
// $Id: TileUtil.java,v 1.5 2001/09/13 19:10:26 mdb Exp $
package com.threerings.miso.tile;
import java.awt.Image;
import com.threerings.media.sprite.MultiFrameImage;
import com.threerings.media.sprite.Path;
import com.threerings.media.sprite.Sprite;
import com.threerings.media.tile.*;
import com.threerings.miso.scene.AmbulatorySprite;
@@ -20,7 +20,7 @@ public class TileUtil
* Returns an array of multi-frame images corresponding to the
* frames of animation used to render the ambulatory sprite in
* each of the directions it may face. The tileset id referenced
* must contain <code>Path.NUM_DIRECTIONS</code> rows of tiles,
* must contain <code>Sprite.NUM_DIRECTIONS</code> rows of tiles,
* with each row containing <code>NUM_DIR_FRAMES</code> tiles.
*
* @param tilemgr the tile manager to retrieve tiles from.
@@ -31,9 +31,9 @@ public class TileUtil
public static MultiFrameImage[] getAmbulatorySpriteFrames (
TileManager tilemgr, int tsid)
{
MultiFrameImage[] anims = new MultiFrameImage[Path.NUM_DIRECTIONS];
MultiFrameImage[] anims = new MultiFrameImage[Sprite.NUM_DIRECTIONS];
for (int ii = 0; ii < Path.NUM_DIRECTIONS; ii++) {
for (int ii = 0; ii < Sprite.NUM_DIRECTIONS; ii++) {
Tile[] tiles = new Tile[NUM_DIR_FRAMES];
for (int jj = 0; jj < NUM_DIR_FRAMES; jj++) {
int idx = (ii * NUM_DIR_FRAMES) + jj;