Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- global testedCells = [];
- function getObstacleArea(obs)
- {
- var area = 1;
- for (var cell in getCellsAroundCell(obs, 1))
- {
- if (isObstacle(cell) && !inArray(testedCells, cell)) {
- push(testedCells, cell);
- area += getObstacleArea(cell);
- }
- }
- return area;
- }
- function getCellsAroundCell(cell, scope)
- {
- var x = getCellX(cell);
- var y = getCellY(cell);
- var cells = [];
- for (var i = -scope; i <= scope; i++)
- for (var j = -scope; j <= scope; j++)
- if (i != 0 and j != 0)
- push(cells, getCellFromXY(x + i, y + j));
- return cells;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement