O'Reilly logo

Beginning 3D Game Programming by Tom Miller

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

Hooking Up the Level

The rest of the interaction with the player has already been implemented inside the code for the Level object, so for now you are done with this object. However, you do need to add the level into the game engine. Go ahead and declare some variables for it:

// The current level
private Level currentLevel = null;
// What level are we currently playing
private int levelNumber = 1;
// Is the level currently being loaded
private bool isLoadingLevel = false;
// Current camera position
private Vector3 currentCameraPosition;
// The amount of time the 'winning' screen is displayed
private float winningLevelTime = 0.0f;

The first two variables are pretty obvious: you need to know which level number you're currently playing as well ...

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