We specify an Arcing path in terms of a start position and various parameters. It's useful to be able to ask the resulting path where that path ended, especially if we want to create another path starting from that new end point.
git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@185 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
@@ -96,7 +96,7 @@ public class ArcPath extends TimedPath
|
||||
int starty =
|
||||
(int)(_center.y + Math.round(Math.sin(_sangle) * _yradius));
|
||||
|
||||
return new ArcPath(new Point (startx + x, starty + y),
|
||||
return new ArcPath(new Point(startx + x, starty + y),
|
||||
_xradius, _yradius, _sangle, _delta, _duration, _orient);
|
||||
}
|
||||
|
||||
@@ -114,6 +114,16 @@ public class ArcPath extends TimedPath
|
||||
_orientOffset = offset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the position of the end of the path.
|
||||
*/
|
||||
public Point getEndPos ()
|
||||
{
|
||||
return new Point(
|
||||
(int)(_center.x + Math.round(Math.cos(_sangle + _delta) * _xradius)),
|
||||
(int)(_center.y + Math.round(Math.sin(_sangle + _delta) * _yradius)));
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public boolean tick (Pathable pable, long timestamp)
|
||||
{
|
||||
@@ -147,7 +157,7 @@ public class ArcPath extends TimedPath
|
||||
// adjust it appropriately
|
||||
orient = DirectionUtil.rotateCW(orient, 2*_orientOffset);
|
||||
break;
|
||||
|
||||
|
||||
case FINE:
|
||||
orient = DirectionUtil.getFineDirection(theta);
|
||||
// adjust it appropriately
|
||||
@@ -160,14 +170,14 @@ public class ArcPath extends TimedPath
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
// if we completed our path, let the sprite know
|
||||
if (angle == _sangle + _delta) {
|
||||
pable.pathCompleted(timestamp);
|
||||
|
||||
Reference in New Issue
Block a user