Advertisement
pierrotdu18

Untitled

Aug 10th, 2014
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. global testedCells = [];
  2.  
  3. function getObstacleArea(obs)
  4. {
  5.     var area = 1;
  6.     for (var cell in getCellsAroundCell(obs, 1))
  7.     {
  8.         if (isObstacle(cell) && !inArray(testedCells, cell)) {
  9.             push(testedCells, cell);
  10.             area += getObstacleArea(cell);
  11.         }
  12.     }
  13.     return area;
  14. }
  15.  
  16. function getCellsAroundCell(cell, scope)
  17. {
  18.     var x = getCellX(cell);
  19.     var y = getCellY(cell);
  20.     var cells = [];
  21.     for (var i = -scope; i <= scope; i++)
  22.         for (var j = -scope; j <= scope; j++)
  23.             if (i != 0 and j != 0)
  24.                 push(cells, getCellFromXY(x + i, y + j));
  25.     return cells;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement