Advertisement
Guest User

Untitled

a guest
May 21st, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. function getAccessibleCells(v,cell){
  2.  
  3. var neighbours = [] ;
  4. var new_neighbours = [cell] ;
  5. var temp_neighbours = [] ;
  6.  
  7. for(var i=0;i<=v;i++){
  8. for (var neighbour in new_neighbours){
  9. var vx = getCellX(neighbour) ;
  10. var vy = getCellY(neighbour) ;
  11.  
  12. if((neighbours_cache[neighbour]&8) == 0){
  13. var sub_cell = getCellFromXY(vx-1, vy) ;
  14. if (sub_cell != null){
  15. push(temp_neighbours, sub_cell) ;
  16. }
  17. }
  18.  
  19. if((neighbours_cache[neighbour]&4) == 0){
  20. var sub_cell = getCellFromXY(vx, vy-1) ;
  21. if (sub_cell != null){
  22. push(temp_neighbours, sub_cell) ;
  23. }
  24. }
  25.  
  26. if((neighbours_cache[neighbour]&2) == 0){
  27. var sub_cell = getCellFromXY(vx+1, vy) ;
  28. if (sub_cell != null){
  29. push(temp_neighbours, sub_cell) ;
  30. }
  31. }
  32.  
  33. if((neighbours_cache[neighbour]&1) == 0){
  34. var sub_cell = getCellFromXY(vx, vy+1) ;
  35. if (sub_cell != null){
  36. push(temp_neighbours, sub_cell) ;
  37. }
  38. }
  39. }
  40. pushAll(neighbours, new_neighbours) ;
  41. new_neighbours = temp_neighbours ;
  42. temp_neighbours = [] ;
  43. }
  44.  
  45. return neighbours ;
  46.  
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement