Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getAccessibleCells(v,cell){
- var neighbours = [] ;
- var new_neighbours = [cell] ;
- var temp_neighbours = [] ;
- for(var i=0;i<=v;i++){
- for (var neighbour in new_neighbours){
- var vx = getCellX(neighbour) ;
- var vy = getCellY(neighbour) ;
- if((neighbours_cache[neighbour]&8) == 0){
- var sub_cell = getCellFromXY(vx-1, vy) ;
- if (sub_cell != null){
- push(temp_neighbours, sub_cell) ;
- }
- }
- if((neighbours_cache[neighbour]&4) == 0){
- var sub_cell = getCellFromXY(vx, vy-1) ;
- if (sub_cell != null){
- push(temp_neighbours, sub_cell) ;
- }
- }
- if((neighbours_cache[neighbour]&2) == 0){
- var sub_cell = getCellFromXY(vx+1, vy) ;
- if (sub_cell != null){
- push(temp_neighbours, sub_cell) ;
- }
- }
- if((neighbours_cache[neighbour]&1) == 0){
- var sub_cell = getCellFromXY(vx, vy+1) ;
- if (sub_cell != null){
- push(temp_neighbours, sub_cell) ;
- }
- }
- }
- pushAll(neighbours, new_neighbours) ;
- new_neighbours = temp_neighbours ;
- temp_neighbours = [] ;
- }
- return neighbours ;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement