Waypoint move
This commit is contained in:
@@ -148,7 +148,7 @@ public class Panel extends JPanel implements ActionListener
|
|||||||
addMouseWheelListener(new MouseWheel(this));
|
addMouseWheelListener(new MouseWheel(this));
|
||||||
|
|
||||||
addFocusListener(new WindowFocusListener(this));
|
addFocusListener(new WindowFocusListener(this));
|
||||||
t = new Timer(1000 / 10, this);
|
t = new Timer(1000 / 50, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPanelInfoLength()
|
public int getPanelInfoLength()
|
||||||
|
|||||||
@@ -94,7 +94,6 @@ public class Visitor
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
System.out.println(actions.size());
|
|
||||||
|
|
||||||
// moveToTarget(target, objects, visitors, paths);
|
// moveToTarget(target, objects, visitors, paths);
|
||||||
move(target, panel);
|
move(target, panel);
|
||||||
@@ -102,7 +101,7 @@ public class Visitor
|
|||||||
|
|
||||||
public void move(DrawObject tar, Panel panel)
|
public void move(DrawObject tar, Panel panel)
|
||||||
{
|
{
|
||||||
Point2D targetPoint = panel.getWaypoint(target).getPosition();
|
Point2D targetPoint = panel.getWaypoint(target).getAccuratePoint();
|
||||||
|
|
||||||
double newRot = Math.atan2(targetPoint.getY() - position.getY(), targetPoint.getX() - position.getX());
|
double newRot = Math.atan2(targetPoint.getY() - position.getY(), targetPoint.getX() - position.getX());
|
||||||
|
|
||||||
@@ -118,7 +117,6 @@ public class Visitor
|
|||||||
{
|
{
|
||||||
rotation += 0.15;
|
rotation += 0.15;
|
||||||
}
|
}
|
||||||
|
|
||||||
Point2D oldPosition = position;
|
Point2D oldPosition = position;
|
||||||
|
|
||||||
// face direction
|
// face direction
|
||||||
|
|||||||
@@ -13,6 +13,11 @@ public class Waypoint extends DrawObject
|
|||||||
super("waypoint", position);
|
super("waypoint", position);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Point2D getAccuratePoint()
|
||||||
|
{
|
||||||
|
return new Point2D.Double(super.getPosition().getX() + (super.getImageRectangle().getWidth()/2), super.getPosition().getY() + super.getImageRectangle().getHeight());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName()
|
public String getName()
|
||||||
{
|
{
|
||||||
@@ -36,7 +41,6 @@ public class Waypoint extends DrawObject
|
|||||||
|
|
||||||
public void setSelf(int self)
|
public void setSelf(int self)
|
||||||
{
|
{
|
||||||
System.out.println(self);
|
|
||||||
this.self = self;
|
this.self = self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -168,10 +168,17 @@ public class Mouse extends MouseAdapter
|
|||||||
panel.setClickedOption("drag");
|
panel.setClickedOption("drag");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
if (panel.getDragObject() instanceof Waypoint == false)
|
||||||
{
|
{
|
||||||
panel.getDragObject().setPosition(panel.getSelectionPosition());
|
panel.getDragObject().setPosition(panel.getSelectionPosition());
|
||||||
panel.getDragObject().setRectangleColor(Color.BLACK);
|
panel.getDragObject().setRectangleColor(Color.BLACK);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
panel.getDragObject().setRectangleColor(Color.BLACK);
|
||||||
|
}
|
||||||
|
}
|
||||||
panel.setSelectionPosition(panel.getSelectedObject().getPosition());
|
panel.setSelectionPosition(panel.getSelectedObject().getPosition());
|
||||||
}
|
}
|
||||||
panel.repaint();
|
panel.repaint();
|
||||||
|
|||||||
Reference in New Issue
Block a user