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