Keeping Score

You have levels and end-game logic now, but what's the fun when your score is always zero? In this section, you'll flesh out scoring for the game. You're already displaying the score at the end of the game, but you'll want to let players see their scores as they play. To do that, add a class-level SpriteFont variable to your Game1 class, with which you'll draw the score:

SpriteFont spriteFont;

And yes, that's right...the next thing that you'll need to do is add a new spritefont to your project. Right-click the Content\Fonts folder in Solution Explorer and select Add → New Item.... Select the Sprite Font template on the right and name the file Tahoma.spritefont, as shown in Figure 15-3.

Adding a score font

Figure 15-3. Adding a score font

Get Learning XNA 3.0 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.