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

Moving Objects

Now that you know how to create objects, we’re going to have some fun and start moving them around the screen. We’ll start off by taking a simple object (a sphere with the brick texture map applied to it) and create controls so that by using our keyboard we can move it around the screen. First, open the file called moving a demo06-01.bb from the CD, or enter the following code. Save the file to a new folder and copy the file called brick.jpg to that folder.

;demo06-01.bb - Moving a sphere ; ––––––––– Graphics3D 640,480 SetBuffer BackBuffer() ;Key constants Const A_KEY = 30 Const Z_KEY = 44 Const LEFT_KEY = 203 Const RIGHT_KEY = 205 Const UP_KEY = 200 Const DOWN_KEY = 208 Const ESC_KEY = 1 ; Create camera camera=CreateCamera() ; ...

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