Add reverse that allow to switch interior/exterior of a labyrinth
- invert create a new labyrinth walls are path of previous. - grow then new labrynth is bigger, else shrink.
This commit is contained in:
@@ -45,6 +45,7 @@ implements StatusListener
|
||||
LabyModel model;
|
||||
boolean autoSize;
|
||||
boolean statusEnable = true;
|
||||
boolean mGrow = false;
|
||||
|
||||
MazeParams params = null;
|
||||
JTextField statusField = null;
|
||||
@@ -150,6 +151,14 @@ implements StatusListener
|
||||
solving.resolve(solving.getWidth() - 1, solving.getHeight() - 1, maze);
|
||||
}
|
||||
|
||||
boolean reverse(boolean grow) {
|
||||
boolean done = model.reverse(grow);
|
||||
if ( done ) {
|
||||
refresh();
|
||||
}
|
||||
return done;
|
||||
}
|
||||
|
||||
void goNorth() {
|
||||
maze.goNorth();
|
||||
}
|
||||
@@ -513,6 +522,18 @@ implements StatusListener
|
||||
|
||||
resolveQuitBar.add(resolveButton);
|
||||
|
||||
JButton reverseButton = new JButton(labels.getString("reverse"));
|
||||
reverseButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent evt) {
|
||||
//
|
||||
addStatus("Reversing");
|
||||
mGrow ^= reverse(mGrow);
|
||||
}
|
||||
});
|
||||
|
||||
resolveQuitBar.add(reverseButton);
|
||||
|
||||
|
||||
final JButton quitButton = new JButton(labels.getString("quit"));
|
||||
Action quitAction = new AbstractAction() {
|
||||
public void actionPerformed(ActionEvent evt) {
|
||||
|
||||
Reference in New Issue
Block a user