소스 검색

Merge branch 'master' of https://github.com/ProjectgroepA8/BroBot

jancoow 11 년 전
부모
커밋
b01929832a
2개의 변경된 파일170개의 추가작업 그리고 5개의 파일을 삭제
  1. 165 0
      gui/Routeplanner.java
  2. 5 5
      gui/panels/RouteSplitpaneCurrentLocation.java

+ 165 - 0
gui/Routeplanner.java

@@ -1,3 +1,5 @@
+package gui;
+
 public class Routeplanner
 {
     private int rotation;
@@ -355,4 +357,167 @@ public class Routeplanner
         teller = 0;
         return route;
     }
+    public char[] berekenRouteBoebot(int eindx, int eindy, int beginx, int beginy, int rotatie)
+    {
+        char[] route = new char[40];
+        int teller = 0;
+        int links = 0;
+        rotation = rotatie;
+        lengte = 0;
+        if(eindx <= maxx && eindy <= maxy && eindx >= 0 && eindy >= 0)
+        {
+            ex = eindx;
+            ey = eindy;
+        }else{
+            return route;
+        }
+        if(beginx <= maxx && beginy <= maxy && beginx >= 0 && beginy >= 0)
+        {
+            x = beginx;
+            y = beginy;
+        }else{
+            return route;
+        }
+        while(ex != x)
+        {
+            if(x < ex)
+            {
+                if(rotation == 90)
+                {
+                    vooruit();
+                    route[teller] = 'v';
+                    teller ++;
+                }
+                if(rotation == 0)
+                {
+                    turnright();
+                    vooruit();
+                    route[teller] = 'r';
+                    teller ++;
+                }
+                if(rotation == 270)
+                {
+                    keren();
+                    vooruit();
+                    route[teller] = 'k';
+                    teller ++;
+                }
+                if(rotation == 180)
+                {
+                    turnleft();
+                    vooruit();
+                    route[teller] = 'l';
+                    teller ++;
+                }
+            }
+            else
+            {
+                if(x > ex)
+                {
+                    if(rotation == 270)
+                    {
+                        vooruit();
+                        route[teller] = 'v';
+                        teller ++;
+                    }
+                    if(rotation == 0)
+                    {
+                        turnleft();
+                        vooruit();
+                        route[teller] = 'l';
+                        teller ++;
+                    }
+                    if(rotation == 90)
+                    {
+                        keren();
+                        vooruit();
+                        route[teller] = 'k';
+                        teller ++;
+                    }
+                    if(rotation == 180)
+                    {
+                        turnright();
+                        vooruit();
+                        route[teller] = 'r';
+                        teller ++;
+                    }
+                }
+            }
+        }
+        while(ey != y)
+        {
+            if(y < ey)
+            {
+                if(rotation == 0)
+                {
+                    vooruit();
+                    route[teller] = 'v';
+                    teller ++;
+                }
+                if(rotation == 270)
+                {
+                    turnright();
+                    vooruit();
+                    route[teller] = 'r';
+                    teller ++;
+                }
+                if(rotation == 180)
+                {
+                    keren();
+                    vooruit();
+                    route[teller] = 'k';
+                    teller ++;
+                }
+                if(rotation == 90)
+                {
+                    turnleft();
+                    vooruit();
+                    route[teller] = 'l';
+                    teller ++;
+                }
+            }
+            else
+            {
+                if(y > ey)
+                {
+                    if(rotation == 180)
+                    {
+                        vooruit();
+                        route[teller] = 'v';
+                        teller ++;
+                    }
+                    if(rotation == 90)
+                    {
+                        turnright();
+                        vooruit();
+                        route[teller] = 'r';
+                        teller ++;
+                    }
+                    if(rotation == 0)
+                    {
+                        keren();
+                        vooruit();
+                        route[teller] = 'k';
+                        teller ++;
+                    }
+                    if(rotation == 270)
+                    {
+                        turnleft();
+                        vooruit();
+                        route[teller] = 'l';
+                        teller ++;
+                    }
+                }
+            }
+        }
+        lengte = teller;
+        teller = 0;
+        while(teller < lengte)
+        {
+            System.out.println(route[teller]);
+            teller ++;
+        }
+        System.out.println("Planning is met succes gemaakt" + geefCoordinaten());
+        return route;
+    }
 }

+ 5 - 5
gui/panels/RouteSplitpaneCurrentLocation.java

@@ -35,7 +35,7 @@ public class RouteSplitpaneCurrentLocation extends JPanel
        content = new JPanel(new GridLayout(1,1));
        menubar = new JPanel();
        map = new ArrayList<ArrayList<Kruispunt>>();
-       //boeboet
+       //boebot
        this.ox = 2;
        this.oy = 2;
        this.orotation = 90;
@@ -88,15 +88,15 @@ public class RouteSplitpaneCurrentLocation extends JPanel
            {
                map.get(row).add(new Kruispunt());
                Kruispunt kruispunt = map.get(row).get(col);
-               if(row == (y - ey) && col == ex)
+               if(row == (y - ey -1) && col == ex)
                {
                    kruispunt.setFinish();
                }
-               if(row == (y - oy) && col == ox)
+               if(row == (y - oy - 1) && col == ox)
                {
                    kruispunt.setBoebot(orotation);
                }
-               if(row == (y - xy) && col == xx)
+               if(row == (y - xy -1) && col == xx)
                {
                    kruispunt.setGat();
                }
@@ -106,7 +106,7 @@ public class RouteSplitpaneCurrentLocation extends JPanel
    }
    public void setGridsize(int x, int y){
 	   this.x = x;
-	   this.y = y;
+	   this.y = y + 1;
 	   refresh();
    }
    public void setBoebot(int x,  int y, int o){