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

Positioning a First–Person Shooter Gun

In most first-person shooter games, the player’s weapon stays in the middle of the screen throughout the entire game. The easiest way to accomplish this is to move the weapon along with the camera. Let’s create a simple game that has a small cylinder as our weapon. Our goal is to have the cylinder positioned at the bottom of the screen that moves along with the movement of the player. Start by opening the program called demo13-08.bb. Save the file with a new name and make sure that the files sky.jpg and grass1.jpg are copied to the same folder as the program.

The first thing we’ll do is create a weapon for our game. In this case, our weapon will be a simple cylinder that is slightly stretched to give it ...

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