Myhijim CoreDev CEO
Posts : 66 Join date : 2012-09-07 Location : Sydney, Australia
| | Chapter One Review And Examples(Webplayers Too!) | |
Congrats guys/girls, you have made it this far! Now I thought I would create this post just to have a bit of fun with our newly generated chunk/s. Try editing this code: - Code:
-
for (var x:int=0; x< s; x ) { for (var z:int = 0; z < s; z ) { for (var y:int=0; y< height; y ) {
chunk[x,y,z]=1;
} } }
We can change this code in a variety of ways to make a variety of shapes! Sphere - Code:
-
for (var x:int=0; x< s; x++) { for (var z:int = 0; z < s; z++) { for (var y:int=0; y< height; y++) { if(Mathf.Sqrt((x-s/2)*(x-s/2) + (y-s/2)*(y-s/2) + (z-s/2)*(z-s/2)) <= s/2) { chunk[x,y,z]=1; }
} } } Staircase Thing - Code:
-
for (var x:int=0; x< s; x++) { for (var z:int = 0; z < s; z++) { var height = x; for (var y:int=0; y< height; y++) { chunk[x,y,z]=1; } } } Interesting shape - Code:
-
for (var x:int=0; x< s; x++) { for (var z:int = 0; z < s; z++) { var height = (z)^x; for (var y:int=0; y< height; y++) { chunk[x,y,z]=1; } } } All located here (You Have to Download the Webplayer folder in each, sorry google drive problem :/ ): https://docs.google.com/folder/d/0BxQ0pDdxhEEZc1JLc2k5RjBJMVE/editPost your formulas for weird shapes below
Last edited by Myhijim on Sat Oct 20, 2012 12:56 am; edited 6 times in total (Reason for editing : Grammar) | |
|