O'Reilly logo

Learning XNA 3.0 by Aaron Reed

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

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

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