jackson databind import
- and some reowrk to use Position more than (x,y) parameters
This commit is contained in:
@@ -19,6 +19,34 @@ bcd is within 'H' or ' '
|
||||
public class Brick
|
||||
{
|
||||
|
||||
// order matters index is same as bits order
|
||||
public static final Position[] AllMoves = {
|
||||
new Position(0,0).doReverseTranslate(Position.stepX),
|
||||
new Position(Position.stepY),
|
||||
new Position(Position.stepX),
|
||||
new Position(0,0).doReverseTranslate(Position.stepY),
|
||||
// last is no move
|
||||
new Position(0,0)
|
||||
};
|
||||
|
||||
// flag is in Brick settings
|
||||
static int getDirectionIndex(short flag)
|
||||
{
|
||||
// short a = (short) (flag >> FLAGLENGTH);
|
||||
for (int index = 0; index < AllMoves.length - 1; index ++) {
|
||||
if (isFlagSet((short) (1 << index), flag)) {
|
||||
return index;
|
||||
}
|
||||
}
|
||||
// return last index which is no move.
|
||||
return AllMoves.length - 1;
|
||||
}
|
||||
|
||||
public static Position getDirectionMove(short direction) {
|
||||
return AllMoves[getDirectionIndex(direction)];
|
||||
}
|
||||
|
||||
|
||||
public final static short LEFT = 1;
|
||||
public final static short DOWN = 2;
|
||||
public final static short RIGHT = 4;
|
||||
|
||||
Reference in New Issue
Block a user