O'Reilly logo

3D Game Programming for Teens, Second Edition by Eric Grebler, Maneesh Sethi

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating a Terrain

One of the quickest ways to create a terrain (or the ground) for your games is to use the programming code called CreateTerrain. This code allows you to create and specify a size for the terrain (again, think of this as the ground) of your game. In this example, we’ll add a terrain to an empty program. Take a basic program:

Graphics3D 640,480
SetBuffer BackBuffer()

Const ESC_KEY = 1

; Create camera
camera=CreateCamera()
; Creating a light
light=CreateLight()
; The following code makes the program run
While Not KeyDown(ESC_KEY)
RenderWorld
Flip
Wend
End

If you ran this program now, you would see only a blank, black screen. We are now going to add the code to create a terrain for this program. Add the following code under the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required