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

Rotating a Camera

Just like other objects, you can rotate a camera to change the angle of your view. By using the RotateEntity command, you can specify the axis on which you want the rotation to occur. To test this out, we’re going to place a camera on top of our shape and rotate it so that it is facing downward. Replace the code under ;Create camera with the following:

; Create camera
camera1 = CreateCamera()
PositionEntity camera1,0,5,5
RotateEntity camera1,90,0,0

After you run the program, you’ll notice that you now have a view of the cylinder, as if you were on the ceiling looking down (see Figure 7.3).

Figure 7.3. A view of the cylinder from the top.

Let’s take a closer look at the code to see how we created this.

PositionEntity camera1, ...

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