jackson databind import
- and some reowrk to use Position more than (x,y) parameters
This commit is contained in:
@@ -1,9 +1,6 @@
|
||||
package org.artisanlogiciel.games.maze.gui;
|
||||
|
||||
import org.artisanlogiciel.games.maze.LabyModel;
|
||||
import org.artisanlogiciel.games.maze.Maze;
|
||||
import org.artisanlogiciel.games.maze.MazeParams;
|
||||
import org.artisanlogiciel.games.maze.MazeParamsFixed;
|
||||
import org.artisanlogiciel.games.maze.*;
|
||||
import org.artisanlogiciel.games.maze.model.WidthHeightProvider;
|
||||
import org.artisanlogiciel.games.maze.persist.MazePersistRaw;
|
||||
import org.artisanlogiciel.games.maze.solve.SolvingModel;
|
||||
@@ -195,21 +192,20 @@ implements StatusListener
|
||||
}
|
||||
|
||||
void goNorth() {
|
||||
maze.goNorth();
|
||||
maze.goTo(Brick.UP);
|
||||
}
|
||||
|
||||
void goSouth() {
|
||||
maze.goSouth();
|
||||
maze.goTo(Brick.DOWN);
|
||||
}
|
||||
|
||||
void goEast() {
|
||||
maze.goEast();
|
||||
maze.goTo(Brick.RIGHT);
|
||||
}
|
||||
|
||||
void goWest() {
|
||||
maze.goWest();
|
||||
maze.goTo(Brick.LEFT);
|
||||
}
|
||||
|
||||
void setWallSize(int size) {
|
||||
maze.setWallSize(size);
|
||||
}
|
||||
|
||||
@@ -33,12 +33,11 @@ public class MazeComponent
|
||||
LinkedList<DirectionPosition> solvedPath = null;
|
||||
LinkedList<DirectionPosition> drawingPath = null;
|
||||
final Object lockChange = new Object();
|
||||
// current postion of human resolving
|
||||
int sX = 0;
|
||||
int sY = 0;
|
||||
// current position of human resolving
|
||||
Position human = new Position(0,0);
|
||||
|
||||
// goal exit
|
||||
int gX = -1;
|
||||
int gY = -1;
|
||||
Position goal = new Position(-1,-1);
|
||||
|
||||
// use a background
|
||||
Xpm xpm = null;
|
||||
@@ -125,9 +124,9 @@ public class MazeComponent
|
||||
path = LabyModel.getDirection(last.getPosition(), newPosition);
|
||||
last.setDirection(path);
|
||||
if (add) {
|
||||
map.addDirection(last.getPosition().getX(), last.getPosition().getY(), path);
|
||||
map.addDirection(last.getPosition(), path);
|
||||
} else {
|
||||
map.setDirection(last.getPosition().getX(), last.getPosition().getY(), path);
|
||||
map.setDirection(last.getPosition(), path);
|
||||
}
|
||||
last = last.moveToAdjacentDirection();
|
||||
drawingPath.addLast(last);
|
||||
@@ -151,7 +150,7 @@ public class MazeComponent
|
||||
}
|
||||
|
||||
void checkExit() {
|
||||
if ((sX == gX) && (sY == gY)) {
|
||||
if (human.equals(goal)) {
|
||||
statusListener.addStatus("Exit found by human !");
|
||||
}
|
||||
}
|
||||
@@ -163,34 +162,10 @@ public class MazeComponent
|
||||
checkExit();
|
||||
}
|
||||
|
||||
void goNorth() {
|
||||
void goTo(short direction)
|
||||
{
|
||||
resetResolution();
|
||||
if (map.canMoveInDirection(sX, sY, Brick.UP)) {
|
||||
sY = sY - 1;
|
||||
proceed();
|
||||
}
|
||||
}
|
||||
|
||||
void goSouth() {
|
||||
resetResolution();
|
||||
if (map.canMoveInDirection(sX, sY, Brick.DOWN)) {
|
||||
sY = sY + 1;
|
||||
proceed();
|
||||
}
|
||||
}
|
||||
|
||||
void goEast() {
|
||||
resetResolution();
|
||||
if (map.canMoveInDirection(sX, sY, Brick.RIGHT)) {
|
||||
sX = sX + 1;
|
||||
proceed();
|
||||
}
|
||||
}
|
||||
|
||||
void goWest() {
|
||||
resetResolution();
|
||||
if (map.canMoveInDirection(sX, sY, Brick.LEFT)) {
|
||||
sX = sX - 1;
|
||||
if (map.moveInDirection(human, direction)) {
|
||||
proceed();
|
||||
}
|
||||
}
|
||||
@@ -203,8 +178,7 @@ public class MazeComponent
|
||||
public MazeComponent(LabyModel map, WidthHeightProvider frame, StatusListener statusListener) {
|
||||
super();
|
||||
this.map = map;
|
||||
gX = map.getWidth() - 1;
|
||||
gY = map.getHeight() - 1;
|
||||
goal = new Position(map.getWidth() - 1,map.getHeight() - 1);
|
||||
resetCellRenderer(false,frame);
|
||||
this.statusListener = statusListener;
|
||||
addMouseMotionListener(this);
|
||||
@@ -222,8 +196,7 @@ public class MazeComponent
|
||||
solvedPath = null;
|
||||
// could be kept
|
||||
drawingPath = null;
|
||||
sX = 0;
|
||||
sY = 0;
|
||||
human = new Position(0,0);
|
||||
cp.resetMazeWidthHeight(map);
|
||||
setPreferredSize(cp.getDimension());
|
||||
}
|
||||
@@ -274,8 +247,7 @@ public class MazeComponent
|
||||
@Override
|
||||
protected void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
|
||||
short walls = 0;
|
||||
short path = 0;
|
||||
|
||||
@@ -328,14 +300,14 @@ public class MazeComponent
|
||||
cp.drawBackground(g, cell, walls);
|
||||
}
|
||||
|
||||
if ((sX == gX) && (sY == gY)) {
|
||||
if (human.equals(goal)) {
|
||||
g.setColor(colorMap.goal);
|
||||
} else {
|
||||
g.setColor(colorMap.resolved_path);
|
||||
cp.drawDot(g, new Position(gX, gY), min, max);
|
||||
cp.drawDot(g, goal, min, max);
|
||||
g.setColor(colorMap.path);
|
||||
}
|
||||
cp.drawDot(g, new Position(sX, sY), min, max);
|
||||
cp.drawDot(g, human, min, max);
|
||||
|
||||
// draw all walls within clip bounds horiz first then lines
|
||||
g.setColor(colorMap.wall);
|
||||
|
||||
Reference in New Issue
Block a user