random generate terrain

Blitz3D Forums/Blitz3D Beginners Area/random generate terrain

Braden(Posted 2009) [#1]
how would I use the rnd or rand code to randomly attach a texture to a plane? I have a plane, and I have all the textures loaded in but I can't make it randomly choose which texture to assign... any help?


_PJ_(Posted 2009) [#2]
Well it may help for you to post what you DO have so we know what we're dealing with, but In theory, the textures you have loaded in would need to be 'indexed' in some way so they can be selected at random. Perhaps something similar to the following example:




Braden(Posted 2009) [#3]
oh sorry, here is what I have.... I'm not sure how i would incorperate the above code into the project...




Stevie G(Posted 2009) [#4]
This will work.

plane=CreatePlane()
PositionEntity plane,0,999,0
spring=LoadTexture("spring.jpg")
winter=LoadTexture("winter.bmp")
fall=LoadTexture("fall.jpg")
summer=LoadTexture("summer.jpg")
skyt=LoadTexture("sky.jpg")

Select Rand(0,3)
	Case 0 EntityTexture plane, spring
	Case 1 EntityTexture plane, winter
	Case 2 EntityTexture plane, fall
	Case 3 EntityTexture plane, summer
End Select

;EntityTexture plane,fall ;Rand(spring,winter,fall,summer)


You may want to put
seedrnd millisecs()

at the top of your code to avoid getting the same random sequence.


Braden(Posted 2009) [#5]
Thanks Steve, it worked out great!