jackson databind import
- and some reowrk to use Position more than (x,y) parameters
This commit is contained in:
@@ -59,6 +59,7 @@ lues, they are used as it is for
|
||||
// orders matters see getReverseDirection
|
||||
public static final short[] AllDirections = {LEFT, DOWN, RIGHT, UP};
|
||||
|
||||
|
||||
private int width;
|
||||
private int height;
|
||||
// wall flags Brick.(LEFT,DOWN,RIGHT,UP,ENTRY,GOAL) + status flags for each position (x,y)
|
||||
@@ -136,9 +137,9 @@ lues, they are used as it is for
|
||||
|
||||
/* set direction existing onee are lost */
|
||||
// FIXME FULLY BREAK RESOLVING...
|
||||
public void setDirection(int x, int y, short path) {
|
||||
if ((x >= 0) && (x < width) && (y >= 0) && (y < height)) {
|
||||
t[x][y] = (short) (path | OPEN);
|
||||
public void setDirection(Position cell, short path) {
|
||||
if ( cell.within(0,0,width,height)) {
|
||||
t[cell.getX()][cell.getY()] = (short) (path | OPEN);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,9 +147,9 @@ lues, they are used as it is for
|
||||
* add a new direction, exiting ones are kept
|
||||
*/
|
||||
// FIXME FULLY BREAK RESOLVING...
|
||||
public void addDirection(int x, int y, short path) {
|
||||
if ((x >= 0) && (x < width) && (y >= 0) && (y < height)) {
|
||||
t[x][y] |= (short) (path | OPEN);
|
||||
public void addDirection(Position cell, short path) {
|
||||
if ( cell.within(0,0,width,height)) {
|
||||
t[cell.getX()][cell.getY()] |= (short) (path | OPEN);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -789,9 +790,19 @@ lues, they are used as it is for
|
||||
/**
|
||||
* is there no wall in that direction ?
|
||||
**/
|
||||
public boolean canMoveInDirection(int x, int y, short direction) {
|
||||
public boolean canMoveInDirection(Position where, short direction) {
|
||||
// one way wall will create walll if it not possible to step back to current position from next position
|
||||
return onewaywall ? ( ! hasWallInDirection(x,y, (short) (direction << FLAGLENGTH)) ) : ((getWalls(x, y) & direction ) == 0);
|
||||
return onewaywall ? ( ! hasWallInDirection(where.getX(),where.getY(), (short) (direction << FLAGLENGTH)) ) : ((getWalls(where) & direction ) == 0);
|
||||
}
|
||||
|
||||
|
||||
public boolean moveInDirection(Position position, short direction) {
|
||||
boolean canMove = canMoveInDirection(position, direction);
|
||||
if ( canMove )
|
||||
{
|
||||
position.doTranslate(Brick.getDirectionMove(direction));
|
||||
}
|
||||
return canMove;
|
||||
}
|
||||
|
||||
public boolean reverse(boolean grow)
|
||||
|
||||
Reference in New Issue
Block a user