CHAPTER 11 EXERCISE SOLUTIONS

Exercise 1 Solution

imageYou can achieve this kind of animation by drawing a different, but similar, image every few hundred seconds in the place of the missile. You can either have a different image to represent each frame of the missile, or you could have one big image containing many frames and use the sourceRectangle parameter of the Draw() method to cut out the appropriate frame. You might like to track each missile's age so that the missiles don't all animate in unison. Source code for this solution is available for download. The name of the file is code sample: Tank Exercise 1.

Exercise 2 Solution

image This kind of feature is best represented as a new GameComponent object. In terms of implementation, powerups are similar to missiles: They spawn randomly, and they collide with the tank. They differ in the way that they affect the tank in that they don't move and should disappear after a short time. Source code for this solution is available for download. The name of the file is code sample: Tank Exercise 2.

Exercise 3 Solution

image Having multiple screens in an XNA game is easy to achieve with GameComponent objects. You just add and remove the appropriate components ...

Get Beginning Windows® Phone 7 Application Development: Building Windows® Phone Applications Using Silverlight® and XNA® 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.