Advertisement
aNdy-AL-Cosine

Arrray Flood Fill

Sep 19th, 2018
3,154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Procedure floodfill(x, y)
  2.  
  3.   If a_MAPDATA(x, y) <> blnkchar
  4.     ProcedureReturn 0
  5.   EndIf
  6.  
  7.   If a_MAPDATA(x,y) = blnkchar
  8.     rnd = Random(rancharsel)
  9.     rnd = rnd - 1
  10.     If rnd < 0
  11.       rnd = 0
  12.     EndIf
  13.     a_MAPDATA(x, y) = a_RNDCHARS(rnd)
  14.   EndIf
  15.  
  16.   If x > 0  ; fill left
  17.     floodfill(x - 1, y)
  18.   EndIf
  19.  
  20.   If y > 0 ; fill up
  21.     floodfill(x, y - 1)
  22.   EndIf
  23.  
  24.   If x < mcw ; fill right
  25.     floodfill(x + 1, y)
  26.   EndIf
  27.  
  28.   If y < mch ; fill down
  29.     floodfill(x, y + 1)
  30.   EndIf
  31.  
  32. EndProcedure
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement