Handling Level Updates
What about the level itself? Currently there is no way to render the level, so you should add that now. Add the code from Listing 8.6.
Listing 8.6. Rendering the Level
public void Draw(Device device) { // Render every block for each(Block b in blocks) { // It's possible the block may be null if (b != null) { b.Draw(device); } } } |
Wow, that's probably the easiest render method yet. You simply loop through every block in the level and, assuming it isn't null, call the Draw method on it. Because the work for rendering the blocks is encapsulated in the Block class, it makes the rendering of the entire level extremely simple. You're still currently missing one important method that the other classes had, namely a way to update ...
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.