one step beyond laby edition
allow to draw pathes before generation still not working
This commit is contained in:
@@ -109,7 +109,8 @@ public class Display extends JFrame
|
|||||||
if (params != null)
|
if (params != null)
|
||||||
{
|
{
|
||||||
params = controler.getSettings().getParams();
|
params = controler.getSettings().getParams();
|
||||||
model = new LabyModel(params, new java.util.Random());
|
// keep current model...
|
||||||
|
// model = new LabyModel(params, new java.util.Random());
|
||||||
maze.resetWallsProvider(model);
|
maze.resetWallsProvider(model);
|
||||||
model.setMazeListener(maze);
|
model.setMazeListener(maze);
|
||||||
|
|
||||||
@@ -669,7 +670,7 @@ public class Display extends JFrame
|
|||||||
}
|
}
|
||||||
path=LabyModel.getDirection(last.getPosition(),newPosition);
|
path=LabyModel.getDirection(last.getPosition(),newPosition);
|
||||||
last.setDirection(path);
|
last.setDirection(path);
|
||||||
map.setDirection(last.getPosition().getX(),last.getPosition().getY(),path);
|
map.addDirection(last.getPosition().getX(),last.getPosition().getY(),path);
|
||||||
}
|
}
|
||||||
last = new DirectionPosition((short) 0,newPosition);
|
last = new DirectionPosition((short) 0,newPosition);
|
||||||
System.out.println("Mouse dragged Cell " + newPosition);
|
System.out.println("Mouse dragged Cell " + newPosition);
|
||||||
@@ -973,6 +974,52 @@ public class Display extends JFrame
|
|||||||
Display display = new Display(model, W,H,params);
|
Display display = new Display(model, W,H,params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void save(MazeParamsFixed params,LabyModel model)
|
||||||
|
{
|
||||||
|
File outfile = new File(params.getSaveDir(), params.getName() + ".raw");
|
||||||
|
if (!outfile.exists())
|
||||||
|
{
|
||||||
|
System.out.println("Saving to " + outfile + " ...");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
FileOutputStream out = new FileOutputStream(outfile);
|
||||||
|
model.streamOut("raw", out);
|
||||||
|
out.flush();
|
||||||
|
out.close();
|
||||||
|
System.out.println("... Done.");
|
||||||
|
}
|
||||||
|
catch (IOException io)
|
||||||
|
{
|
||||||
|
io.printStackTrace(System.err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
System.out.println("" + outfile + " already exists");
|
||||||
|
}
|
||||||
|
outfile = new File(params.getSaveDir(), params.getName() + ".stl");
|
||||||
|
if (!outfile.exists())
|
||||||
|
{
|
||||||
|
System.out.println("Saving to " + outfile + " ...");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
FileOutputStream out = new FileOutputStream(outfile);
|
||||||
|
Wall3d.streamWallsOut(params.getName(), (WallsProvider) model, out);
|
||||||
|
out.flush();
|
||||||
|
out.close();
|
||||||
|
System.out.println("... Done.");
|
||||||
|
}
|
||||||
|
catch (IOException io)
|
||||||
|
{
|
||||||
|
io.printStackTrace(System.err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
System.out.println("" + outfile + " already exists");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
public static void main(String pArgs[])
|
public static void main(String pArgs[])
|
||||||
{
|
{
|
||||||
LabyModel model = null;
|
LabyModel model = null;
|
||||||
@@ -1002,53 +1049,16 @@ public class Display extends JFrame
|
|||||||
|
|
||||||
setupDisplay(model,W,H,params);
|
setupDisplay(model,W,H,params);
|
||||||
|
|
||||||
|
/*
|
||||||
model.generateWithEntry(0, 0);
|
model.generateWithEntry(0, 0);
|
||||||
|
|
||||||
model.addEntryOrExit(-1, 0);
|
model.addEntryOrExit(-1, 0);
|
||||||
model.addEntryOrExit(params.getWidth(), params.getHeight() - 1);
|
model.addEntryOrExit(params.getWidth(), params.getHeight() - 1);
|
||||||
|
|
||||||
System.out.println("Generation completed");
|
System.out.println("Generation completed");
|
||||||
File outfile = new File(params.getSaveDir(), params.getName() + ".raw");
|
*/
|
||||||
if (!outfile.exists())
|
/*
|
||||||
{
|
*/
|
||||||
System.out.println("Saving to " + outfile + " ...");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
FileOutputStream out = new FileOutputStream(outfile);
|
|
||||||
model.streamOut("raw", out);
|
|
||||||
out.flush();
|
|
||||||
out.close();
|
|
||||||
System.out.println("... Done.");
|
|
||||||
}
|
|
||||||
catch (IOException io)
|
|
||||||
{
|
|
||||||
io.printStackTrace(System.err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
System.out.println("" + outfile + " already exists");
|
|
||||||
}
|
|
||||||
outfile = new File(params.getSaveDir(), params.getName() + ".stl");
|
|
||||||
if (!outfile.exists())
|
|
||||||
{
|
|
||||||
System.out.println("Saving to " + outfile + " ...");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
FileOutputStream out = new FileOutputStream(outfile);
|
|
||||||
Wall3d.streamWallsOut(params.getName(), (WallsProvider) model, out);
|
|
||||||
out.flush();
|
|
||||||
out.close();
|
|
||||||
System.out.println("... Done.");
|
|
||||||
}
|
|
||||||
catch (IOException io)
|
|
||||||
{
|
|
||||||
io.printStackTrace(System.err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
System.out.println("" + outfile + " already exists");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ public class LabyModel implements WallsProvider
|
|||||||
// FIXME FULLY BREAK RESOLVING...
|
// FIXME FULLY BREAK RESOLVING...
|
||||||
public void noWalls(int x, int y)
|
public void noWalls(int x, int y)
|
||||||
{
|
{
|
||||||
if ((x > 0) && (x < width) && (y > 0) && (y < height))
|
if ((x >= 0) && (x < width) && (y >= 0) && (y < height))
|
||||||
{
|
{
|
||||||
// t[x][y] |= DIRECTION | VERTICAL | POSITIVE | HORIZONTAL | NEGATIVE | LEFT | RIGHT | UP | DOWN;
|
// t[x][y] |= DIRECTION | VERTICAL | POSITIVE | HORIZONTAL | NEGATIVE | LEFT | RIGHT | UP | DOWN;
|
||||||
t[x][y] |= DIRECTION | VERTICAL | POSITIVE | HORIZONTAL | NEGATIVE;
|
t[x][y] |= DIRECTION | VERTICAL | POSITIVE | HORIZONTAL | NEGATIVE;
|
||||||
@@ -131,9 +131,9 @@ public class LabyModel implements WallsProvider
|
|||||||
// FIXME FULLY BREAK RESOLVING...
|
// FIXME FULLY BREAK RESOLVING...
|
||||||
public void setDirection(int x, int y, short path)
|
public void setDirection(int x, int y, short path)
|
||||||
{
|
{
|
||||||
if ((x > 0) && (x < width) && (y > 0) && (y < height))
|
if ((x >= 0) && (x < width) && (y >= 0) && (y < height))
|
||||||
{
|
{
|
||||||
t[x][y]= path;
|
t[x][y]= (short) (path | OPEN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,9 +141,9 @@ public class LabyModel implements WallsProvider
|
|||||||
// FIXME FULLY BREAK RESOLVING...
|
// FIXME FULLY BREAK RESOLVING...
|
||||||
public void addDirection(int x, int y, short path)
|
public void addDirection(int x, int y, short path)
|
||||||
{
|
{
|
||||||
if ((x > 0) && (x < width) && (y > 0) && (y < height))
|
if ((x >= 0) && (x < width) && (y >= 0) && (y < height))
|
||||||
{
|
{
|
||||||
t[x][y]|= path;
|
t[x][y]|= (short) (path | OPEN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user