O'Reilly logo

Learning XNA 4.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

Game Scoring

As you’ll recall from our earlier discussion of this topic, the first thing you need to do is determine what event(s) will trigger a change in score. For this game, you’ll be updating the score whenever the user successfully avoids a three-blade, four-blade, skull ball, or plus sprite. You actually have already added the logic to determine when one of those sprites has been successfully avoided; it lies in the code that deletes the sprites when they disappear off the edge of the screen. If a sprite makes it across the screen and needs to be deleted, that means the user has avoided that sprite, and if it was a three-blade, four-blade, skull ball, or plus sprite, you need to give some points to the user.

Tip

Any time you’re developing a game, scoring rules and calculations are things you’ll need to think about. You’ll most likely formulate an idea, implement it, and then tweak it while testing your game to see whether it feels right and plays the way you want it to. For the purposes of this book, the scoring calculations and rules are laid out for you to learn. However, as you begin to feel more comfortable with the concepts in this book and this chapter specifically, feel free to change the rules and tweak the game to whatever feels right to you as both the developer and a player.

In the SpriteManager class, add three new class-level variables representing the three types of sprites you’ll be sending at the player, as well as public properties for each variable:

int automatedSpritePointValue ...

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