Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getCellsAroundCell(center, scope_min, scope_max, obstacles)
- {
- var instructions = getInstructionsCount();
- var cells = [];
- for (var x = 0; x <= scope_max; x++)
- for (var y = 0; y <= scope_max; y++)
- if (x+y >= scope_min and x+y <= scope_max)
- pushAll(cells, [/*1*/
- ((getCellFromXY(getCellX(center) + x, getCellY(center) + y) === null)
- ?
- null
- :
- ((obstacles)
- ?
- getCellFromXY(getCellX(center) + x, getCellY(center) + y)
- :
- ((isObstacle(getCellFromXY(getCellX(center) + x, getCellY(center) + y)))
- ?
- null
- :
- getCellFromXY(getCellX(center) + x, getCellY(center) + y)))),
- /*2*/
- ((getCellFromXY(getCellX(center) - x, getCellY(center) + y) === null)
- ?
- null
- :
- ((obstacles)
- ?
- getCellFromXY(getCellX(center) - x, getCellY(center) + y)
- :
- ((isObstacle(getCellFromXY(getCellX(center) - x, getCellY(center) + y)))
- ?
- null
- :
- getCellFromXY(getCellX(center) - x, getCellY(center) + y)))),
- /*3*/
- ((getCellFromXY(getCellX(center) + x, getCellY(center) - y) === null)
- ?
- null
- :
- ((obstacles)
- ?
- getCellFromXY(getCellX(center) + x, getCellY(center) - y)
- :
- ((isObstacle(getCellFromXY(getCellX(center) + x, getCellY(center) - y)))
- ?
- null
- :
- getCellFromXY(getCellX(center) + x, getCellY(center) - y)))),
- /*4*/
- ((getCellFromXY(getCellX(center) - x, getCellY(center) - y) === null)
- ?
- null
- :
- ((obstacles)
- ?
- getCellFromXY(getCellX(center) - x, getCellY(center) - y)
- :
- ((isObstacle(getCellFromXY(getCellX(center) - x, getCellY(center) - y)))
- ?
- null
- :
- getCellFromXY(getCellX(center) - x, getCellY(center) - y))))]);
- while (inArray(cells, null)) removeElement(cells, null);
- debug(getInstructionsCount() - instructions);
- return cells;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement