Add additional type of orientation to ArcPath - NONE - which keeps us from reorienting sprites following the path.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3780 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Mike Thomas
2005-12-08 21:59:12 +00:00
parent db5de88da2
commit 12c9f86735
+32 -24
View File
@@ -45,6 +45,11 @@ public class ArcPath extends TimedPath
* follow this path. */
public static final int FINE = 1;
/** An orientation indicating that the pathable should not be oriented
* as it moves along the path.
*/
public static final int NONE = 2;
/**
* Creates an arc path that will animate a pathable from the specified
* starting position along an ellipse defined by the supplied
@@ -130,36 +135,39 @@ public class ArcPath extends TimedPath
// determine where we should be along the path
computePosition(_center, _xradius, _yradius, angle, _tpos);
// compute the pathable's new orientation
double theta = angle + ((_delta > 0) ? Math.PI/2 : -Math.PI/2);
int orient;
switch (_orient) {
default:
case NORMAL:
orient = DirectionUtil.getDirection(theta);
// adjust it appropriately
orient = DirectionUtil.rotateCW(orient, 2*_orientOffset);
break;
case FINE:
orient = DirectionUtil.getFineDirection(theta);
// adjust it appropriately
orient = DirectionUtil.rotateCW(orient, _orientOffset);
break;
}
// Skip this if we are not reorienting as we follow the path.
if (_orient != NONE) {
// compute the pathable's new orientation
double theta = angle + ((_delta > 0) ? Math.PI/2 : -Math.PI/2);
int orient;
switch (_orient) {
default:
case NORMAL:
orient = DirectionUtil.getDirection(theta);
// adjust it appropriately
orient = DirectionUtil.rotateCW(orient, 2*_orientOffset);
break;
case FINE:
orient = DirectionUtil.getFineDirection(theta);
// adjust it appropriately
orient = DirectionUtil.rotateCW(orient, _orientOffset);
break;
}
// update the pathable's orientation if it changed
if (pable.getOrientation() != orient) {
pable.setOrientation(orient);
modified = true;
}
}
// update the pathable's location if it moved
if (pable.getX() != _tpos.x || pable.getY() != _tpos.y) {
pable.setLocation(_tpos.x, _tpos.y);
modified = true;
}
// update the pathable's orientation if it changed
if (pable.getOrientation() != orient) {
pable.setOrientation(orient);
modified = true;
}
// if we completed our path, let the sprite know
if (angle == _sangle + _delta) {
pable.pathCompleted(timestamp);