honor run option with a default maze of 30x30
default_args in project Display.main() if argument is empty ignore it if file read fails, exit add a WHEREWHAT file extract MazeParamEditor to share it, prepare for having a GUI instead of console
This commit is contained in:
12
WHEREWHAT
Normal file
12
WHEREWHAT
Normal file
@@ -0,0 +1,12 @@
|
||||
|
||||
java/
|
||||
|
||||
java sources
|
||||
|
||||
java/org/artisanlogiciel/games
|
||||
|
||||
java sources for package org.artisanlogiciel.games respect of java directory naming convention of files
|
||||
|
||||
java/org/artisanlogiciel/games/Main.java
|
||||
|
||||
Main Java entry point for this program
|
||||
@@ -83,56 +83,6 @@ public class Display extends JFrame
|
||||
maze.setWallSize(size);
|
||||
}
|
||||
|
||||
private static class MazeParamEditor implements MazeParams
|
||||
{
|
||||
int width;
|
||||
int height;
|
||||
int maxdepth;
|
||||
File labdir;
|
||||
String name;
|
||||
|
||||
public MazeParamEditor(File saveDir)
|
||||
{
|
||||
name = null;
|
||||
labdir = saveDir;
|
||||
}
|
||||
|
||||
public void read(Scanner console)
|
||||
{
|
||||
width = console.nextInt();
|
||||
height = console.nextInt();
|
||||
maxdepth = console.nextInt();
|
||||
}
|
||||
|
||||
public int getWidth()
|
||||
{
|
||||
return width;
|
||||
}
|
||||
|
||||
public int getHeight()
|
||||
{
|
||||
return height;
|
||||
}
|
||||
|
||||
public int getMaxDepth()
|
||||
{
|
||||
return maxdepth;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
if (name == null)
|
||||
{
|
||||
name = "lab" + width + "x" + height;
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
public File getSaveDir()
|
||||
{
|
||||
return labdir;
|
||||
}
|
||||
}
|
||||
|
||||
private class MazeControler extends JPanel
|
||||
{
|
||||
@@ -520,7 +470,7 @@ public class Display extends JFrame
|
||||
int W = 600;
|
||||
int H = 400;
|
||||
|
||||
if (pArgs.length > 0)
|
||||
if ( (pArgs.length > 0) && (pArgs[0].length() > 0))
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -529,6 +479,7 @@ public class Display extends JFrame
|
||||
catch (IOException io)
|
||||
{
|
||||
io.printStackTrace(System.err);
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
int w = W / model.getWidth();
|
||||
|
||||
@@ -14,7 +14,7 @@ import java.io.DataInputStream;
|
||||
/**
|
||||
* Model of labyrinth storing only paths not walls. wall are regenerated later
|
||||
* on based on adjacent paths. each position (x,y) stores what move can be done
|
||||
* from here to go do deeper path. a node is tagged OPEN and contained in
|
||||
* from here to go to deeper path. a node is tagged OPEN and contained in
|
||||
* openList if all moves from its position have not been resolved a node is
|
||||
* tagged CLOSED when fully processed
|
||||
**/
|
||||
|
||||
@@ -1,10 +1,18 @@
|
||||
package org.artisanlogiciel.games;
|
||||
|
||||
import java.util.Scanner;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class Main
|
||||
{
|
||||
public MazeParamEditor editor()
|
||||
{
|
||||
MazeParamEditor editor = new MazeParamEditor(null);
|
||||
System.out.println("enter width height and maxdepth");
|
||||
Scanner console = new Scanner(System.in);
|
||||
editor.read(console);
|
||||
return editor;
|
||||
}
|
||||
|
||||
public WallsProvider generate(int width, int height, int maxdepth, MazeResolutionListener listener)
|
||||
{
|
||||
@@ -41,13 +49,9 @@ public class Main
|
||||
|
||||
public static void main(String pArgs[])
|
||||
{
|
||||
System.out.println("enter width height and maxdepth");
|
||||
Scanner console = new Scanner(System.in);
|
||||
int width = console.nextInt();
|
||||
int height = console.nextInt();
|
||||
int maxdepth = console.nextInt();
|
||||
Main m = new Main();
|
||||
LabyMap map = m.generate2(width, height, maxdepth);
|
||||
MazeParamEditor editor = m.editor();
|
||||
LabyMap map = m.generate2(editor.width, editor.height, editor.maxdepth);
|
||||
System.out.println(map.toShortString());
|
||||
System.out.println(map.toString());
|
||||
System.out.println(Brick.getDirLine());
|
||||
|
||||
59
java/org/artisanlogiciel/games/MazeParamEditor.java
Normal file
59
java/org/artisanlogiciel/games/MazeParamEditor.java
Normal file
@@ -0,0 +1,59 @@
|
||||
package org.artisanlogiciel.games;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
MazeParamEditor to edit Maze Parameters ( current impl in console / Scanner )
|
||||
**/
|
||||
class MazeParamEditor implements MazeParams
|
||||
{
|
||||
int width;
|
||||
int height;
|
||||
int maxdepth;
|
||||
File labdir;
|
||||
String name;
|
||||
|
||||
public MazeParamEditor(File saveDir)
|
||||
{
|
||||
name = null;
|
||||
labdir = saveDir;
|
||||
}
|
||||
|
||||
public void read(Scanner console)
|
||||
{
|
||||
width = console.nextInt();
|
||||
height = console.nextInt();
|
||||
maxdepth = console.nextInt();
|
||||
}
|
||||
|
||||
public int getWidth()
|
||||
{
|
||||
return width;
|
||||
}
|
||||
|
||||
public int getHeight()
|
||||
{
|
||||
return height;
|
||||
}
|
||||
|
||||
public int getMaxDepth()
|
||||
{
|
||||
return maxdepth;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
if (name == null)
|
||||
{
|
||||
name = "lab" + width + "x" + height;
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
public File getSaveDir()
|
||||
{
|
||||
return labdir;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package org.artisanlogiciel.games;
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* MazeParams was autogenerated by ./generate_newclass.sh
|
||||
* MazeParams contains parameters for a Maze generation
|
||||
**/
|
||||
public interface MazeParams
|
||||
{
|
||||
|
||||
@@ -4,3 +4,4 @@ project_basedir=$(pwd)
|
||||
project_mainpackage=org.artisanlogiciel.games
|
||||
project_mainclass=$project_mainpackage.Display
|
||||
project_version=0.0.1
|
||||
default_args='lab/lab30x30.raw'
|
||||
|
||||
Reference in New Issue
Block a user