QnD fix for drawing

( seen when joining cells touching only by one point )
This commit is contained in:
philippe lhardy
2017-12-05 21:52:12 +01:00
parent c5d8503dbb
commit b360320570
3 changed files with 72 additions and 27 deletions

View File

@@ -40,6 +40,38 @@ public class DirectionPosition
}
return "?";
}
// create a new DirectionPosition from this using one possible direction.
DirectionPosition moveToAdjacentDirection()
{
short pointingdirection = 0;
Position p = null;
if (LabyModel.isFlagSet(direction,LabyModel.RIGHT))
{
p = new Position(position.getX() + 1, position.getY());
pointingdirection |= LabyModel.LEFT;
}
else if (LabyModel.isFlagSet(direction,LabyModel.LEFT))
{
p = new Position(position.getX() -1 ,position.getY());
pointingdirection |= LabyModel.RIGHT;
}
else if (LabyModel.isFlagSet(direction,LabyModel.UP))
{
p = new Position(position.getX(),position.getY() -1);
pointingdirection |= LabyModel.DOWN;
}
else if (LabyModel.isFlagSet(direction,LabyModel.DOWN))
{
p = new Position(position.getX(),position.getY() + 1);
pointingdirection |= LabyModel.UP;
}
else
{
p = position;
}
return new DirectionPosition((short) pointingdirection, p);
}
}