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)
|
void addWallInDrawing(int pX, int pY, Drawing d)
|
||||||
{
|
{
|
||||||
short walls = model.getWalls(pX,pY);
|
short walls = model.getWalls(pX,pY);
|
||||||
|
short wdrawn = 0;
|
||||||
// todo
|
// todo
|
||||||
int w = 2;
|
int w = 2;
|
||||||
int h = 2;
|
int h = 2;
|
||||||
@@ -210,27 +211,54 @@ public class Display extends JFrame
|
|||||||
int x = ox + (int) (pX * w);
|
int x = ox + (int) (pX * w);
|
||||||
int y = oy + (int) (pY * h);
|
int y = oy + (int) (pY * h);
|
||||||
DrawingLine dl = new DrawingLine();
|
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, y));
|
||||||
dl.addPoint(new Point(x + (int) w, y));
|
dl.addPoint(new Point(x + (int) w, y));
|
||||||
|
wdrawn |= Brick.UP;
|
||||||
}
|
}
|
||||||
if ((walls & Brick.DOWN) == Brick.DOWN)
|
if (LabyModel.isFlagSet(walls,Brick.RIGHT))
|
||||||
{
|
{
|
||||||
dl.addPoint(new Point(x, y + (int) h));
|
if ( ! LabyModel.isFlagSet(wdrawn,Brick.UP) )
|
||||||
dl.addPoint(new Point(x + (int) w, y + (int) h));
|
|
||||||
}
|
|
||||||
if ((walls & Brick.RIGHT) == Brick.RIGHT)
|
|
||||||
{
|
{
|
||||||
dl.addPoint(new Point(x + (int) w, y));
|
dl.addPoint(new Point(x + (int) w, y));
|
||||||
|
}
|
||||||
dl.addPoint(new Point(x + (int) w, y + (int) h));
|
dl.addPoint(new Point(x + (int) w, y + (int) h));
|
||||||
|
wdrawn |= Brick.RIGHT;
|
||||||
}
|
}
|
||||||
if ( (pX == 0 ) && ((walls & Brick.LEFT) == Brick.LEFT))
|
if (LabyModel.isFlagSet(walls,Brick.DOWN))
|
||||||
|
{
|
||||||
|
if ( ! LabyModel.isFlagSet(wdrawn,Brick.RIGHT) )
|
||||||
|
{
|
||||||
|
if (wdrawn != 0)
|
||||||
{
|
{
|
||||||
dl.addPoint(new Point(x, y));
|
|
||||||
dl.addPoint(new Point(x, y + (int) h));
|
|
||||||
}
|
|
||||||
d.addLine(dl);
|
d.addLine(dl);
|
||||||
|
dl = new DrawingLine();
|
||||||
|
}
|
||||||
|
dl.addPoint(new Point(x + (int) w, y + (int) h));
|
||||||
|
}
|
||||||
|
dl.addPoint(new Point(x, y + (int) h));
|
||||||
|
wdrawn |= Brick.DOWN;
|
||||||
|
}
|
||||||
|
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));
|
||||||
|
wdrawn |= Brick.LEFT;
|
||||||
|
}
|
||||||
|
if (wdrawn != 0)
|
||||||
|
{
|
||||||
|
d.addLine(dl);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Drawing createDrawing()
|
Drawing createDrawing()
|
||||||
|
|||||||
Reference in New Issue
Block a user