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 Targets

Right now, the targets in the game would be really easy to hit because they aren’t moving. We’ll change that by adding the code to move the different objects at different speeds. We’ll create different speeds and different directions for each of the types of targets so that it will be difficult to hit them with the bullets. We’ll use a For. . . Next statement to move each of the five copies of each animal. Add the following code in bold:

If KeyDown(V_KEY)=True Then TranslateEntity camera,0,3,0
MoveEntity camera, 0,-0.8,0
; Moving the targets
For a = 1 To 5
MoveEntity ducks(a), 0.1,-.02,0 MoveEntity seahorse(a), 0,-.02,0 MoveEntity donkey(a), 0,-.02,0 MoveEntity flamingo(a), 0.1,-0.2,0 MoveEntity snake(a), -0.2,-0.2,0 MoveEntity ...

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