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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.