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

Destroying Gallery Items

The goal of the game is to destroy the gallery items by hitting them with the bullets that you fire from your gun. To accomplish this, we need to check to see whether a bullet has collided with a gallery item and, if so, hide the gallery item that has been hit.

For q = 0 To maxbull
      MoveEntity bullet(q), 0,0.8,3
      If CountCollisions (bullet(q))
         crash=CollisionEntity (bullet(q),1)
         HideEntity crash
      EndIf
Next

Run the program now and start firing away. You should notice that whenever a gallery item is hit, it disappears.

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