Including the Player

Before you create the player object, do you remember back a few chapters ago when you were first rendering the sky box for the level? Well, the code is probably still there in the OnCreateDevice method of the game engine, but that probably isn't where it should be. You don't need to create the sky box, or the player, or the level until the user selects the character he will be using in the game. You left the event handler for this user interface screen “empty” before, so you should fill it now, using the method in Listing 9.1.

Listing 9.1. Selecting Your Character Event Handler
 private void OnLoopySelected(object sender, EventArgs e) { SelectLoopyScreen screen = sender as SelectLoopyScreen; System.Diagnostics.Debug.Assert(screen ...

Get Beginning 3D Game Programming now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.