Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.42 KB | None | 0 0
  1. private void Fill(int indexX, int indexY)
  2.         {
  3.             Queue<Tile> queue = new Queue<Tile>();
  4.          
  5.             //get the tile they clicked on and add to queue
  6.             Tile clickedTile = map[indexX, indexY];            
  7.             queue.Enqueue(clickedTile);
  8.  
  9.             //variables to check against map dimensions
  10.             int x = indexX;
  11.             int y = indexY;
  12.  
  13.             while(queue.Count != 0)
  14.             {
  15.                 Tile temp = new Tile();
  16.                 //gets first item in queue and removes it
  17.                 temp = queue.Dequeue();
  18.  
  19.                 //find this item & update the selected picture coords
  20.                 for(int i = 0; i < map.GetLength(0); i++)
  21.                 {
  22.                     for(int j = 0; j < map.GetLength(1); j++)
  23.                     {
  24.                         if(map[i,j].)
  25.                     }
  26.                 }
  27.  
  28.                 //add all adjacent tiles to the queue
  29.  
  30.                 //to the right
  31.                 x = indexX + 1;
  32.                 if(x < map.GetLength(0) && x >= 0 && y < map.GetLength(1) && y >= 0)
  33.                 {
  34.  
  35.                     queue.Enqueue()
  36.                 }
  37.  
  38.                 //to the left
  39.                 x = indexX - 1;
  40.  
  41.  
  42.                 //down one
  43.                 y = indexY + 1;
  44.                 x = indexX;
  45.  
  46.  
  47.                 //up one
  48.                 y = indexY - 1;
  49.  
  50.             }
  51.  
  52.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement