Files
narya/src/java/com/threerings/puzzle/drop/util/DropBoardUtil.java
T
Michael Bayne 54eaddb27d Holy crap Batman! It's the beginnings of refactoring the basic puzzle
stuff into Narya.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2876 542714f4-19e9-0310-aa3c-eee0fc999fb1
2003-11-26 01:42:34 +00:00

47 lines
1.3 KiB
Java

//
// $Id: DropBoardUtil.java,v 1.1 2003/11/26 01:42:34 mdb Exp $
package com.threerings.puzzle.drop.util;
import com.threerings.util.DirectionCodes;
import com.threerings.puzzle.drop.data.DropBoard;
public class DropBoardUtil
implements DirectionCodes
{
/**
* Returns the orientation resulting from rotating the block in the
* given direction the specified number of times.
*
* @param orient the current orientation.
* @param dir the direction to rotate in; one of <code>CW</code> or
* <code>CCW</code>.
* @param count the number of rotations to perform.
*
* @return the rotated orientation.
*/
public static int getRotatedOrientation (int orient, int dir, int count)
{
for (int ii = 0; ii < (count % 4); ii++) {
orient = getRotatedOrientation(orient, dir);
}
return orient;
}
/**
* Returns the orientation resulting from rotating the block in
* the given direction.
*
* @param orient the current orientation.
* @param dir the direction to rotate in; one of <code>CW</code> or
* <code>CCW</code>.
*
* @return the rotated orientation.
*/
public static int getRotatedOrientation (int orient, int dir)
{
return (orient + ((dir == CW) ? 2 : 6)) % DIRECTION_COUNT;
}
}