The world for our game is going to be made up of three different elements. The water in the lakes will be a plane on which we will apply the texture we created earlier. For the hills, we will use a heightmap on which we will apply another texture. The sky won’t actually be an object—instead, we’ll change the color of the camera, which will make everything that is black appear the color that we specify.
To do this, we’ll use the CameraClsColor command. Let’s start by applying that command in bold:
; Create camera
camera=CreateCamera()
CameraClsColor camera, 0,125,255
If you run the program now, you’ll notice that everything on the screen is the light blue color that we specified in the CameraClsColor command. Now we are going to create the water, which, as mentioned earlier, is just a plane with a texture applied to it. Let’s add this code in bold:
; Creating a light
light=CreateLight()
;Creating the water plane
water=CreatePlane()
PositionEntity water, 0,-15,0
watertexture=LoadTexture ("water.jpg")
EntityTexture water, watertexture
ScaleTexture watertexture,15,15
At this point, every part of that code should make sense to you. It’s simply a plane with the water texture that we created earlier applied to it. We scaled the texture to make it look more spread out, and we positioned the plane 15 units below the 0 level on the y plane.
Now we will create the terrain for the game. It will be a heightmap with a texture applied to it, scaled and positioned.
ScaleTexture watertexture,15,15
; Loading the heightmap
terrain=LoadTerrain ( "ground.jpg" )
ScaleEntity terrain,5,50,5
PositionEntity terrain,-500,-20,-500
tex=LoadTexture( "greenery.jpg" )
ScaleTexture tex, 50,50
EntityTexture terrain,tex
EntityType terrain, type_scenery
Run the program now and you should see the sky, mountains, and water, as shown in Figure 14.10.
18.116.36.56