draw path

This commit is contained in:
philippe lhardy
2017-12-02 16:45:22 +01:00
parent 7deeb203ff
commit 77a06c0061
3 changed files with 73 additions and 10 deletions

View File

@@ -649,8 +649,10 @@ public class Display extends JFrame
@Override
public void mouseDragged(MouseEvent e) {
// should find the cell ...
DirectionPosition last = null;
int pX = (int) ((double) (e.getX() - cp.getOffsetX()) / cp.getWidth());
int pY = (int) ((double) (e.getY() - cp.getOffsetY()) / cp.getHeight());
short path = 0;
Position newPosition = new Position(pX,pY);
if (drawingPath == null )
{
@@ -658,17 +660,21 @@ public class Display extends JFrame
}
else
{
DirectionPosition last = drawingPath.getLast();
// setShowAll(true);
last = drawingPath.getLast();
if ( last.getPosition().equals(newPosition))
{
// no move.
return;
}
// short path=computeMove(last,newPosition);
path=LabyModel.getDirection(last.getPosition(),newPosition);
last.setDirection(path);
map.setDirection(last.getPosition().getX(),last.getPosition().getY(),path);
}
last = new DirectionPosition((short) 0,newPosition);
System.out.println("Mouse dragged Cell " + newPosition);
drawingPath.addLast(new DirectionPosition((short) 0,newPosition));
map.noWalls(pX,pY);
drawingPath.addLast(last);
// map.noWalls(pX,pY);
changed(null,null,map);
}
@@ -679,7 +685,7 @@ public class Display extends JFrame
public void setShowAll(boolean showall )
{
showAll = showAll;
this.showAll = showAll;
}
void checkExit()