Skip to Main Content
Learning XNA 3.0
book

Learning XNA 3.0

by Aaron Reed
November 2008
Beginner content levelBeginner
510 pages
16h 24m
English
O'Reilly Media, Inc.
Content preview from Learning XNA 3.0

Chapter 4: Applying Some Object-Oriented Design

Quiz Answers

  1. What class does a game component derive from?

    • GameComponent.

  2. If you want to be able to draw on the screen with your game component, what class do you need to derive from?

    • DrawableGameComponent.

  3. Fact or fiction: time spent building a solid object-oriented design should not count as time spent developing software because it is unnecessary and superfluous.

    • Absolutely fiction. Creating a proper design up front will help you avoid countless headaches and maintenance issues down the road. Always, no matter what the project, plan ahead and code around a solid design.

  4. Which U.S. state prohibits snoring by law unless all bedroom windows are closed and securely locked?

Exercise Answer

  1. Add the following exercise and solution:

    Modify the code that you worked on this chapter to create four sprites which move and bounce off all four edges of the screen. To accomplish this, create a new class called BouncingSprite which derives from AutomatedSprite. BouncingSprite should do the same thing that AutomatedSprite does with the exception that it will check during the Update method to determine if the sprite has gone off the edge of the screen. If it has, reverse the direction of the sprite by multiplying the speed variable by −1.

    Also, make two of the bouncing sprites use the skull image and two of them use the plus image (located with the source code for this chapter in the ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning XNA 4.0

Learning XNA 4.0

Aaron Reed
Beginning C# 7 Programming with Visual Studio 2017

Beginning C# 7 Programming with Visual Studio 2017

Benjamin Perkins, Jacob Vibe Hammer, Jon D. Reid

Publisher Resources

ISBN: 9780596154905Supplemental ContentErrata Page