Commits

Anonymous committed 22a7583

fixes to FOV map and raycast algo

Comments (0)

Files changed (2)

src/main/java/net/fishbulb/jcod/fov/FovAlgorithm.java

         }
 
         @Override public boolean apply(int x, int y) {
-            if (r2 > 0 && ((x - xo) *(x - xo) + (y - yo) * (y - yo)) > r2) return false;
-            if (!map.contains(x,y)) return false;
+            if (r2 > 0 && ((x - xo) *(x - xo) + (y - yo) * (y - yo)) > r2) return true;
+            if (!map.contains(x,y)) return true;
             if (map.isTransparent(x,y)) {
                 map.setFov(x, y, true);
             } else {
         }
     }
 
+    public void castRay(int x0, int y0, int x1, int y1, int r, boolean w) {
+        new RayCast(x0, x0, x1, y1, r, w).cast();
+    }
+
+
+
 }

src/main/java/net/fishbulb/jcod/fov/FovMap.java

     private Cell[] cells;
 
     public FovMap(int width, int height) {
+        this.width = width;
+        this.height = height;
         cells = new Cell[width * height];
         for (int i = 0; i < cells.length; i++) {
             cells[i] = new Cell(false, false);