stoneharry

Untitled

Dec 25th, 2013
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.07 KB | None | 0 0
  1.                 // Random grass
  2.                 grid[0][i][j] = GlobalStaticVars.WORLD_VALUE.fromInt(GlobalStaticVars.RandIntRange(rndGen, 2, 4));
  3.                 // Random trees
  4.                 if (GlobalStaticVars.RandIntRange(rndGen, 1, 10000) < tree_density)
  5.                 {
  6.                     // Do not draw trees on world borders
  7.                     if (i == 0 || j == 0 || i == sizeX - 1 || j == sizeY - 1)
  8.                         continue;
  9.                     grid[1][i][j] = GlobalStaticVars.WORLD_VALUE.TREE_1;
  10.                     for (int a = 0; a < GlobalStaticVars.RandIntRange(rndGen, 1, 10); ++a)
  11.                     {
  12.                         for (int b = 0; b < GlobalStaticVars.RandIntRange(rndGen, 1, 10); ++b)
  13.                         {
  14.                             // Do not draw trees on world borders and boundary check
  15.                             if (a+i < 1 || b+j < 1 || a+i > sizeX - 2 || b+j > sizeY - 2)
  16.                                 continue;                          
  17.                             grid[1][a+i][b+j] = GlobalStaticVars.WORLD_VALUE.TREE_1;
  18.                             // Try drawing tree's a bit more in the other direction
  19.                             if (GlobalStaticVars.RandIntRange(rndGen, 1, 2) == 2)
  20.                             {
  21.                                 if (a-i < 1 || b-j < 1)
  22.                                     continue;
  23.                                 grid[1][a-i][b-j] = GlobalStaticVars.WORLD_VALUE.TREE_1;
  24.                             }
  25.                         }
  26.                     }
  27.                 }
Advertisement
Add Comment
Please, Sign In to add comment