Applying a Texture to a Terrain

More often than not, rather than coloring a terrain, you’ll probably want to apply a texture to it. You can apply a texture to a terrain just as you would any other entity. Before you continue, open the file called demo09-03.bb and make sure that the file grass1.jpg is in the same folder as the program. Add the following code to apply a grass texture to our terrain.

; Create the terrain
ground=CreateTerrain(512)
texture=LoadTexture ( "grass1.jpg" )
EntityTexture ground, texture

Go ahead and run the program now and you’ll see that your terrain now has the grass texture applied to it (see Figure 9.5).

Figure 9.5. A grassy texture has been applied to the terrain in demo09-03.bb.


..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.19.224