Advertisement
Guest User

Untitled

a guest
Dec 28th, 2012
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. genColumn(int x, int z)
  2. {
  3. int highestBlockY = (int)noise2d(x, z);
  4.  
  5. bool is_surface = true;
  6.  
  7. for(int y = max_height - 1; y >= 0; y--)
  8. {
  9. Block b;
  10.  
  11. if(is_surface)
  12. {
  13. b = Block.Grass;
  14. b.HasHeightMap = true;
  15.  
  16. // generate heightmap
  17. for(int ix = 0; ix < 5; ix++)
  18. {
  19. for(int iz = 0; iz < 5; iz++)
  20. {
  21. float heightHere = noise2d(x + ix / 4, z + iz / 4) - y;
  22.  
  23. if(ix == 0 || iz == 0 || ix == 4 || iz == 4)
  24. heightHere = (float)Math.Round(heightHere);
  25.  
  26. // clip heights
  27. if(heightHere > 1)
  28. heightHere = 1;
  29.  
  30. if(heightHere < 0)
  31. heightHere = 0;
  32.  
  33. b.HeightMap[ix][iz] = heightHere;
  34. }
  35. }
  36.  
  37. is_surface = false;
  38. }
  39. else
  40. {
  41. b = Block.Dirt;
  42. }
  43.  
  44. setBlock(x, y, z, b);
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement