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

Camera Movement

Like just about any other object, the camera that you create can be moved around and rotated to either follow the action or survey your surroundings. In this example, we will work with a file we created earlier in the book called demo06-05.bb—a file that has some protons and electrons floating around a spinning nucleus. We will create a camera that can be moved around and rotated so that you can navigate through the atom. First we’ll add controls that will allow us to turn and move the camera. Add this code before the RenderWorld line near the end of the program:

;Moving the Camera If KeyDown(RIGHT_KEY) TurnEntity camera,0,1,0 If KeyDown(LEFT_KEY) TurnEntity camera,0,-1,0 If KeyDown(UP_KEY) MoveEntity camera,0,0,1 If KeyDown(DOWN_KEY) ...

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