Sorceress

Untitled

Sep 14th, 2015
267
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. h = 24
  2. w = 24
  3. range = 256
  4.  
  5. int pathing[h,w];
  6. int doneflag = 0;
  7.  
  8. for(xx=0; xx<w; xx++) {
  9.   for(yy=0; yy<h; yy++) {
  10.     pathing[xx,yy] = range;
  11.   }
  12. }
  13.  
  14. pathing[player.x/8, player.y/8] = 0;
  15.  
  16. while (doneflag == 0) {
  17.  
  18. doneflag = 1;
  19.  
  20. for(xx=0; xx<w; xx++) {
  21.   for(yy=0; yy<h; yy++) {
  22.  
  23.      if(pathing[xx,yy] < range) {
  24.        if(pathing[xx-1,yy] == range && ds_grid_get(global.mainGrid,xx-1,yy) == 0) {pathing[xx-1,yy]=pathing[xx,yy]+1; doneflag=0;}
  25.        if(pathing[xx+1,yy] == range && ds_grid_get(global.mainGrid,xx+1,yy) == 0) {pathing[xx+1,yy]=pathing[xx,yy]+1; doneflag=0;}
  26.        if(pathing[xx,yy-1] == range && ds_grid_get(global.mainGrid,xx,yy-1) == 0) {pathing[xx,yy-1]=pathing[xx,yy]+1; doneflag=0;}
  27.        if(pathing[xx,yy+1] == range && ds_grid_get(global.mainGrid,xx,yy+1) == 0) {pathing[xx,yy+1]=pathing[xx,yy]+1; doneflag=0;}
  28.         }
  29.     }
  30. }
  31.  
  32. for(xx=w-1; xx>=0; xx--) {
  33.   for(yy=h-1; yy>=0; yy--) {
  34.  
  35.      if(pathing[xx,yy] < range) {
  36.        if(pathing[xx-1,yy] == range && ds_grid_get(global.mainGrid,xx-1,yy) == 0) {pathing[xx-1,yy]=pathing[xx,yy]+1; doneflag=0;}
  37.        if(pathing[xx+1,yy] == range && ds_grid_get(global.mainGrid,xx+1,yy) == 0) {pathing[xx+1,yy]=pathing[xx,yy]+1; doneflag=0;}
  38.        if(pathing[xx,yy-1] == range && ds_grid_get(global.mainGrid,xx,yy-1) == 0) {pathing[xx,yy-1]=pathing[xx,yy]+1; doneflag=0;}
  39.        if(pathing[xx,yy+1] == range && ds_grid_get(global.mainGrid,xx,yy+1) == 0) {pathing[xx,yy+1]=pathing[xx,yy]+1; doneflag=0;}
  40.         }
  41.     }
  42. }
  43.  
  44. }
RAW Paste Data