Q&D fix Drawing generation ( see it with svg export ).
This commit is contained in:
@@ -201,6 +201,7 @@ public class Display extends JFrame
|
||||
void addWallInDrawing(int pX, int pY, Drawing d)
|
||||
{
|
||||
short walls = model.getWalls(pX,pY);
|
||||
short wdrawn = 0;
|
||||
// todo
|
||||
int w = 2;
|
||||
int h = 2;
|
||||
@@ -210,27 +211,54 @@ public class Display extends JFrame
|
||||
int x = ox + (int) (pX * w);
|
||||
int y = oy + (int) (pY * h);
|
||||
DrawingLine dl = new DrawingLine();
|
||||
if ( (pY == 0) && ((walls & Brick.UP) == Brick.UP))
|
||||
// order matters since all points are linked
|
||||
if ( (pY == 0) && LabyModel.isFlagSet(walls,Brick.UP) )
|
||||
{
|
||||
dl.addPoint(new Point(x, y));
|
||||
dl.addPoint(new Point(x + (int) w, y));
|
||||
wdrawn |= Brick.UP;
|
||||
}
|
||||
if ((walls & Brick.DOWN) == Brick.DOWN)
|
||||
if (LabyModel.isFlagSet(walls,Brick.RIGHT))
|
||||
{
|
||||
if ( ! LabyModel.isFlagSet(wdrawn,Brick.UP) )
|
||||
{
|
||||
dl.addPoint(new Point(x + (int) w, y));
|
||||
}
|
||||
dl.addPoint(new Point(x + (int) w, y + (int) h));
|
||||
wdrawn |= Brick.RIGHT;
|
||||
}
|
||||
if (LabyModel.isFlagSet(walls,Brick.DOWN))
|
||||
{
|
||||
if ( ! LabyModel.isFlagSet(wdrawn,Brick.RIGHT) )
|
||||
{
|
||||
if (wdrawn != 0)
|
||||
{
|
||||
d.addLine(dl);
|
||||
dl = new DrawingLine();
|
||||
}
|
||||
dl.addPoint(new Point(x + (int) w, y + (int) h));
|
||||
}
|
||||
dl.addPoint(new Point(x, y + (int) h));
|
||||
dl.addPoint(new Point(x + (int) w, y + (int) h));
|
||||
wdrawn |= Brick.DOWN;
|
||||
}
|
||||
if ((walls & Brick.RIGHT) == Brick.RIGHT)
|
||||
{
|
||||
dl.addPoint(new Point(x + (int) w, y));
|
||||
dl.addPoint(new Point(x + (int) w, y + (int) h));
|
||||
}
|
||||
if ( (pX == 0 ) && ((walls & Brick.LEFT) == Brick.LEFT))
|
||||
if ( (pX == 0 ) && LabyModel.isFlagSet(walls,Brick.LEFT))
|
||||
{
|
||||
if ( ! LabyModel.isFlagSet(wdrawn,Brick.DOWN) )
|
||||
{
|
||||
if (wdrawn != 0)
|
||||
{
|
||||
d.addLine(dl);
|
||||
dl = new DrawingLine();
|
||||
}
|
||||
dl.addPoint(new Point(x, y + (int) h));
|
||||
}
|
||||
dl.addPoint(new Point(x, y));
|
||||
dl.addPoint(new Point(x, y + (int) h));
|
||||
wdrawn |= Brick.LEFT;
|
||||
}
|
||||
if (wdrawn != 0)
|
||||
{
|
||||
d.addLine(dl);
|
||||
}
|
||||
d.addLine(dl);
|
||||
}
|
||||
|
||||
Drawing createDrawing()
|
||||
|
||||
Reference in New Issue
Block a user