From f5711898497ae9b79a0cb21cada5622ba8b2597d Mon Sep 17 00:00:00 2001 From: Yorick Date: Wed, 8 Apr 2015 14:46:08 +0200 Subject: [PATCH] kaas --- Applicatie/Panel.java | 16 ++++++++++++++-- Applicatie/Visitor.java | 27 +++++++++++++++------------ 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/Applicatie/Panel.java b/Applicatie/Panel.java index fef8188..6e4ed83 100644 --- a/Applicatie/Panel.java +++ b/Applicatie/Panel.java @@ -73,7 +73,7 @@ public class Panel extends JPanel implements ActionListener Point lastMousePosition = new Point(0, 0); Point2D selectionPosition = new Point(0, 0); Images images = new Images(); - javax.swing.Timer t; + Timer t; SimpleDateFormat formatter; GregorianCalendar date; @@ -211,6 +211,18 @@ public class Panel extends JPanel implements ActionListener { waypoints.add(w); } + + public Waypoint getWaypoint(int i) + { + for(Waypoint w : waypoints) + { + if(w.getSelf() == i) + { + return w; + } + } + return null; + } public ArrayList getWaypoints() { @@ -231,7 +243,7 @@ public class Panel extends JPanel implements ActionListener visitors.add(new Visitor("visitor",point, agenda, objects)); } else { - JOptionPane.showMessageDialog(this, "You don't have a entrance"); + JOptionPane.showMessageDialog(this, "You don't have an entrance"); } } diff --git a/Applicatie/Visitor.java b/Applicatie/Visitor.java index 91378e4..9a7f09f 100644 --- a/Applicatie/Visitor.java +++ b/Applicatie/Visitor.java @@ -28,6 +28,7 @@ public class Visitor Agenda agenda; ArrayList objects; int target; + int finalTarget; public Visitor(String filename, Point2D position, Agenda agenda, ArrayList objects) { @@ -42,6 +43,7 @@ public class Visitor fillActions(); System.out.println(actions.size()); target = 0; + finalTarget = 0; } public void draw(Graphics2D g2) @@ -88,6 +90,11 @@ public class Visitor moveToTarget(target, objects, visitors, paths); } + public void move(DrawObject tar) + { + + } + public void moveToTarget(DrawObject target, ArrayList objects, ArrayList visitors, ArrayList paths) { Point2D tar = target.getPosition(); @@ -217,18 +224,14 @@ public class Visitor int dify = (int) (target2.getY() - position.getY()); int distance = (int) Math.sqrt((difx * difx) + (dify * dify)); - System.out.println(rotation); - System.out.println(newRot); - System.out.println("--------------"); -// if (rotation > newRot && distance > 10) -// { -// rotation -= 0.15; -// } -// else if (rotation < newRot && distance > 10) -// { -// rotation += 0.15; -// } - rotation = newRot; + if (rotation > newRot && distance > 10) + { + rotation -= 0.15; + } + else if (rotation < newRot && distance > 10) + { + rotation += 0.15; + } Point2D oldPosition = position;