Professional Windows® Phone 7 Game Development: Creating Games using XNA Game Studio 4

Book description

Create the next generation of gaming titles for Windows Phone 7!

Providing an overview of developing games for Windows Phone 7 while working within XNA Game Studio 4, this comprehensive resource covers such essential topics as device/emulator, development tools, device orientation, tilt and accelerometer sensors, multi-touch, working with Cloud and Web services, and more. Three complete games are included within the book plus hands-on explanations and clear example codes help you gain a deeper understanding of the Windows Phone 7 features so that you can start building a game right away.

  • Serves as a comprehensive reference on Windows Phone 7 game development with XNA Game Studio 4

  • Includes real-world examples and anecdotes, making this book a popular choice for those taking their first steps into the game development industry

  • Demonstrates how to program for device orientation, incorporate Touch Input, add music to a game, work with 3D, and take your game to the marketplace

Put your game face on and start designing games for Windows Phone 7 with Professional Windows Phone 7 Game Development!

Table of contents

  1. Copyright
  2. ABOUT THE AUTHORS
  3. ABOUT THE TECHNICAL EDITOR
  4. CREDITS
  5. ACKNOWLEDGMENTS
  6. PREFACE
  7. INTRODUCTION
    1. WHO THIS BOOK IS FOR
    2. WHAT THIS BOOK COVERS
    3. HOW THIS BOOK IS STRUCTURED
    4. WHAT YOU NEED TO USE THIS BOOK
    5. CONVENTIONS
    6. SOURCE CODE
    7. ERRATA
    8. P2P.WROX.COM
  8. 1. Getting to Know the Windows Phone 7 Device
    1. 1.1. MINIMUM SPECIFICATIONS
      1. 1.1.1. Chassis Design
      2. 1.1.2. Screen Resolution
    2. 1.2. PHONE FEATURES
      1. 1.2.1. Capacitive Touch
      2. 1.2.2. Sensors
        1. 1.2.2.1. Accelerometer
        2. 1.2.2.2. aGPS
        3. 1.2.2.3. Compass
        4. 1.2.2.4. Light Sensor
        5. 1.2.2.5. Proximity Sensor
      3. 1.2.3. Digital Camera
      4. 1.2.4. DirectX 9 Acceleration
      5. 1.2.5. Face Buttons
        1. 1.2.5.1. Back Button
        2. 1.2.5.2. Start Button
        3. 1.2.5.3. Search Button
      6. 1.2.6. QWERTY Keyboard
    3. 1.3. SOFTWARE FEATURES
      1. 1.3.1. Start and Lock Screens
      2. 1.3.2. Hubs
        1. 1.3.2.1. People Hub
        2. 1.3.2.2. Pictures Hub
        3. 1.3.2.3. Music + Video Hub
        4. 1.3.2.4. Games Hub
        5. 1.3.2.5. Marketplace Hub
        6. 1.3.2.6. Office Hub
      3. 1.3.3. Other Applications
    4. 1.4. SUMMARY
  9. 2. Getting Started
    1. 2.1. GETTING THE TOOLS YOU NEED
      1. 2.1.1. Meeting the System Requirements
      2. 2.1.2. Satisfying the Developer Requirements
      3. 2.1.3. What You Get
    2. 2.2. XNA GAME STUDIO 4.0
      1. 2.2.1. Creating Your First Project
      2. 2.2.2. Spotting Differences Between the Windows Phone Game and Other XNA Game Projects
    3. 2.3. SETTING UP A WINDOWS PHONE DEVICE
    4. 2.4. USING THE WINDOWS PHONE EMULATOR
    5. 2.5. USING COMMAND-LINE OPTIONS
    6. 2.6. SUMMARY
  10. 3. Orientation
    1. 3.1. DEVICE ORIENTATION
      1. 3.1.1. Setting Device Orientation
        1. 3.1.1.1. Hardware Scaling
        2. 3.1.1.2. Automatic Rotation
      2. 3.1.2. Detecting Device Orientation
      3. 3.1.3. Running in Full-Screen Mode
        1. 3.1.3.1. Phone Title-Safe Area
    2. 3.2. ACCELEROMETER
      1. 3.2.1. AccelerometerSample
    3. 3.3. SUMMARY
  11. 4. Touch Input
    1. 4.1. RESPONDING TO TOUCH EVENTS
      1. 4.1.1. Overview of Touch Interfaces
      2. 4.1.2. Detecting Touch Input
      3. 4.1.3. Detecting Gestures
        1. 4.1.3.1. Tap
        2. 4.1.3.2. DoubleTap
        3. 4.1.3.3. Hold
        4. 4.1.3.4. HorizontalDrag
        5. 4.1.3.5. VerticalDrag
        6. 4.1.3.6. FreeDrag
        7. 4.1.3.7. DragComplete
        8. 4.1.3.8. Flick
        9. 4.1.3.9. Pinch
        10. 4.1.3.10. PinchComplete
        11. 4.1.3.11. Seeing Results
        12. 4.1.3.12. Custom Gestures
      4. 4.1.4. Designing for Touch Games
        1. 4.1.4.1. Remember Your Platform
        2. 4.1.4.2. Design for the Right Resolution
        3. 4.1.4.3. Be Consistent and Predictable
    2. 4.2. THE SOFT INPUT PANEL (SIP)
    3. 4.3. SUMMARY
  12. 5. Give Me Your Input
    1. 5.1. BUILDING THE INPUT MANAGEMENT SYSTEM
      1. 5.1.1. Input.cs
      2. 5.1.2. GestureDefinition.cs
      3. 5.1.3. GameInput.cs
      4. 5.1.4. TouchIndicator.cs
      5. 5.1.5. TouchIndicatorCollection.cs
    2. 5.2. USING THE INPUT MANAGEMENT SYSTEM
      1. 5.2.1. Actions.cs
      2. 5.2.2. Game1.cs
    3. 5.3. SUMMARY
  13. 6. The State of Things
    1. 6.1. GAME STATE
      1. 6.1.1. Managing Game State
        1. 6.1.1.1. Option 1: Boolean Flags
        2. 6.1.1.2. Option 2: Enumerations
        3. 6.1.1.3. Option 3: Object-Oriented
      2. 6.1.2. Handling Multiple Layers of Screens
    2. 6.2. PHONE HARDWARE EVENTS
      1. 6.2.1. Detecting the Back Button
      2. 6.2.2. Overriding the Back Button
    3. 6.3. GAME, INTERRUPTED
      1. 6.3.1. Notifications and Temporary Interruptions
      2. 6.3.2. Game-Stopping Events
    4. 6.4. SOMEBODY SAVE ME
    5. 6.5. SUMMARY
  14. 7. Let the Music Play
    1. 7.1. HANDLING AUDIO
      1. 7.1.1. Playing Music with MediaPlayer
        1. 7.1.1.1. Do You Mind? I'm Playing Music Here
        2. 7.1.1.2. Background Music
        3. 7.1.1.3. Song Collections
        4. 7.1.1.4. Visualizations
      2. 7.1.2. SoundEffect
        1. 7.1.2.1. SoundEffectInstance
    2. 7.2. XACT 3.0
    3. 7.3. RECORDING AUDIO
      1. 7.3.1. The Microphone Class
      2. 7.3.2. Saving and Retrieving Captured Audio
    4. 7.4. SUMMARY
  15. 8. Putting It All Together: Drive & Dodge
    1. 8.1. CREATING THE GAME
      1. 8.1.1. Screens
        1. 8.1.1.1. Screen.cs
        2. 8.1.1.2. ScreenStateSwitchboard.cs
        3. 8.1.1.3. Title.cs
        4. 8.1.1.4. Sprite.cs
        5. 8.1.1.5. Background.cs
        6. 8.1.1.6. Content
        7. 8.1.1.7. Game1.cs
        8. 8.1.1.8. Text.cs
        9. 8.1.1.9. screenFont.spritefont
        10. 8.1.1.10. Button.cs
      2. 8.1.2. The Input Wrapper
        1. 8.1.2.1. GameInput.cs
        2. 8.1.2.2. GestureDefinition.cs
        3. 8.1.2.3. Input.cs
        4. 8.1.2.4. TouchIndicator.cs
        5. 8.1.2.5. TouchIndicatorCollection.cs
      3. 8.1.3. Adding Sounds and Music
        1. 8.1.3.1. Music.cs
        2. 8.1.3.2. SoundEffects.cs
      4. 8.1.4. More Screens
        1. 8.1.4.1. MainGame.cs
        2. 8.1.4.2. InGameMenu.cs
        3. 8.1.4.3. GameOver.cs
      5. 8.1.5. Coding the Main Game Screen
        1. 8.1.5.1. Road.cs
        2. 8.1.5.2. Car.cs
        3. 8.1.5.3. Hazards.cs
      6. 8.1.6. Finishing the MainGame Screen: Hooking Up the Sprites and the Game Play
        1. 8.1.6.1. MainGame.cs
        2. 8.1.6.2. InGameMenu.cs
        3. 8.1.6.3. GameOver.cs
      7. 8.1.7. Keeping Score
        1. 8.1.7.1. Score.cs
        2. 8.1.7.2. ScoreList.cs
        3. 8.1.7.3. Scores.cs
        4. 8.1.7.4. SerializableDictionary.cs
        5. 8.1.7.5. Screen.cs
        6. 8.1.7.6. MainGame.cs
        7. 8.1.7.7. GameOver.cs
      8. 8.1.8. Proper Care and Feeding of the Back Button
        1. 8.1.8.1. Screen.cs
        2. 8.1.8.2. Title.cs
        3. 8.1.8.3. MainGame.cs
        4. 8.1.8.4. InGameMenu.cs
        5. 8.1.8.5. GameOver.cs
    2. 8.2. CREATING A BASE GAME TEMPLATE
      1. 8.2.1. Stripping Down to the Essentials
        1. 8.2.1.1. Title.cs
        2. 8.2.1.2. ScreenStateSwitchboard.cs
      2. 8.2.2. Creating the Templates
      3. 8.2.3. Using the Templates
    3. 8.3. SUMMARY
  16. 9. Whoa! The World Isn't Flat After All
    1. 9.1. 3D GRAPHICS
      1. 9.1.1. Creating 3D Models for Your Game
        1. 9.1.1.1. Getting the Bits
        2. 9.1.1.2. Getting Started with Blender
        3. 9.1.1.3. Creating Primitive Shapes
        4. 9.1.1.4. Changing Your Point of View
        5. 9.1.1.5. Combining Shapes
        6. 9.1.1.6. Bringing It All Together
        7. 9.1.1.7. Exporting Your Shapes
      2. 9.1.2. Using 3D Models in Your Game
        1. 9.1.2.1. Adding Models to Your Project
        2. 9.1.2.2. Displaying the Models Onscreen
      3. 9.1.3. Texturing a Basic 3D Model in Blender
        1. 9.1.3.1. Configuring Your Workspace
        2. 9.1.3.2. Texturing the Model
      4. 9.1.4. Performing 3D Transformations
        1. 9.1.4.1. It's All Relative
        2. 9.1.4.2. Rotating Your 3D Object
      5. 9.1.5. Creating 3D Animations
        1. 9.1.5.1. Adding Bones to Your Model
        2. 9.1.5.2. Weight Painting
        3. 9.1.5.3. Animating in Blender
        4. 9.1.5.4. Adding the FBX for XNA Script
      6. 9.1.6. The Microsoft Skinning Sample
    2. 9.2. WORKING WITH EFFECTS
      1. 9.2.1. Stock Effects
      2. 9.2.2. Using the Reach Graphics Demo
    3. 9.3. SUMMARY
  17. 10. It's Your Turn!
    1. 10.1. UNDERSTANDING PUSH NOTIFICATIONS
      1. 10.1.1. Raw Notifications
        1. 10.1.1.1. PushItRawSample
        2. 10.1.1.2. PushItRawWindows
      2. 10.1.2. Pop-Up Toasts
        1. 10.1.2.1. PassTheToastSample
        2. 10.1.2.2. PassTheToastWindows
        3. 10.1.2.3. Consuming Toasts as Raw Notifications in Your Game
      3. 10.1.3. Tile Notifications
        1. 10.1.3.1. PushingTileSample
        2. 10.1.3.2. PushingTileWindows
    2. 10.2. GOOD VIBRATIONS
      1. 10.2.1. The Microsoft.Devices Namespace
      2. 10.2.2. Environment
      3. 10.2.3. VibrateController
    3. 10.3. SUMMARY
  18. 11. The World Outside Your Window(s)
    1. 11.1. CONSUMING WEB SERVICES
      1. 11.1.1. Live to Serve You
      2. 11.1.2. Serve Me
        1. 11.1.2.1. Adding a Service Reference
        2. 11.1.2.2. Game1.cs
    2. 11.2. I GET HIGH SCORES WITH A LITTLE HELP FROM MY FRIENDS
      1. 11.2.1. HighScoreService
      2. 11.2.2. ScoreMe
      3. 11.2.3. Anonymous Live ID
      4. 11.2.4. HighScoreClient
      5. 11.2.5. Push Notifications
      6. 11.2.6. HighScoreTester
      7. 11.2.7. Testing the High-Score Service
    3. 11.3. GOT A MATCH?
      1. 11.3.1. MatchMaker
        1. 11.3.1.1. GameRequest.cs
        2. 11.3.1.2. Gamer.cs
        3. 11.3.1.3. IMatchMaker.cs
        4. 11.3.1.4. MatchMakerService.svc.cs
      2. 11.3.2. MatchMe
      3. 11.3.3. MatchMakerTester
        1. 11.3.3.1. Form1
        2. 11.3.3.2. Testing the MatchMaker Service
    4. 11.4. WORKING WITH HTTP REQUESTS
      1. 11.4.1. WeatherWitch
      2. 11.4.2. Pulling an RSS Feed into Your Game
      3. 11.4.3. Time for a REST(ful Web Service)
    5. 11.5. SUMMARY
  19. 12. Putting It All Together: Poker Dice with Friends
    1. 12.1. TAKING CARE OF THE PRELIMINARIES
      1. 12.1.1. Service Flow versus Screen Flow
      2. 12.1.2. Creating the Poker Dice Service
        1. 12.1.2.1. IPokerDice.cs
        2. 12.1.2.2. Game.cs
        3. 12.1.2.3. Gamer.cs
        4. 12.1.2.4. HandRank.cs
        5. 12.1.2.5. PokerDice.svc
      3. 12.1.3. Creating the Poker Dice Tester
        1. 12.1.3.1. PokerDiceTest
        2. 12.1.3.2. Using the PokerDiceTester
    2. 12.2. CREATING "POKER DICE WITH FRIENDS"
      1. 12.2.1. Setting Up the Game Project Template
      2. 12.2.2. Modifying the Templates
        1. 12.2.2.1. Title.cs
      3. 12.2.3. Enhancing the ScreenStateSwitchboard Class
        1. 12.2.3.1. ScreenStateSwitchboard.cs
        2. 12.2.3.2. Adding the PokerDiceService
      4. 12.2.4. Creating the GameInformation and DiceGame Supporting Classes
        1. 12.2.4.1. DiceGame.cs
        2. 12.2.4.2. GameInformation.cs
        3. 12.2.4.3. Button.cs
      5. 12.2.5. Creating the Game Lobby
        1. 12.2.5.1. GameLobby.cs
        2. 12.2.5.2. Message.cs
      6. 12.2.6. Creating the GameInfo Screen
        1. 12.2.6.1. GameInfo.cs
      7. 12.2.7. Adding the Dice Model
        1. 12.2.7.1. Die.cs
      8. 12.2.8. Creating the MainGame Screen
        1. 12.2.8.1. MainGame.cs
      9. 12.2.9. Creating the DiceSelect Screen
        1. 12.2.9.1. DiceSelect.cs
    3. 12.3. ENHANCING YOUR GAME
    4. 12.4. SUMMARY
  20. 13. Dude, Where's My Car?
    1. 13.1. UNDERSTANDING AND ACCESSING THE LOCATION API
    2. 13.2. BEST PRACTICES FOR USING LOCATION SERVICES
      1. 13.2.1. Asking Permission
      2. 13.2.2. Power Consumption
      3. 13.2.3. Level of Accuracy
      4. 13.2.4. Movement Threshold
    3. 13.3. USING LOCATION SERVICES IN YOUR GAMES
      1. 13.3.1. CivicAddress
      2. 13.3.2. CivicAddressResolver
        1. 13.3.2.1. Did You Order Pizza?
        2. 13.3.2.2. Resolving an Address Synchronously
        3. 13.3.2.3. Resolving an Address Asynchronously
      3. 13.3.3. GeoCoordinate
        1. 13.3.3.1. GeoCoordinateWatcher
        2. 13.3.3.2. FindMe
      4. 13.3.4. GeoPosition
    4. 13.4. SUMMARY
  21. 14. Take a Picture; It'll Last Longer!
    1. 14.1. LAUNCHERS AND CHOOSERS
    2. 14.2. NOWPICTURETHIS
      1. 14.2.1. CameraCaptureTask
      2. 14.2.2. The Application Deployment Tool
      3. 14.2.3. Testing NowPictureThis
      4. 14.2.4. PhotoChooserTask
    3. 14.3. CLASSES FOR MESSAGING TASKS
      1. 14.3.1. SmsComposeTask
      2. 14.3.2. EmailComposeTask
      3. 14.3.3. EmailAddressChooserTask
    4. 14.4. MEDIAPLAYERLAUNCHER
      1. 14.4.1. The Controls Property
      2. 14.4.2. The Location Property
      3. 14.4.3. The Media Property
    5. 14.5. SUMMARY
  22. 15. Putting It All Together: Picture Puzzle
    1. 15.1. PICTURE PUZZLE
    2. 15.2. DESIGNING THE SCREEN FLOW
    3. 15.3. CREATING PICTURE PUZZLE
      1. 15.3.1. Creating the Title Screen
        1. 15.3.1.1. Title.cs
      2. 15.3.2. Enhancing the ScreenStateSwitchboard
        1. 15.3.2.1. ScreenStateSwitchboard.cs
      3. 15.3.3. Creating the NewPuzzle Screen
        1. 15.3.3.1. NewPuzzle.cs
      4. 15.3.4. The Pieces of the Puzzle
        1. 15.3.4.1. PuzzlePiece.cs
        2. 15.3.4.2. StencilPiece.cs
        3. 15.3.4.3. Puzzle.cs
        4. 15.3.4.4. How It Works
      5. 15.3.5. Managing State Objects
        1. 15.3.5.1. StateObject.cs
      6. 15.3.6. Creating the SelectPuzzle Screen
        1. 15.3.6.1. SelectPuzzleScreen.cs
      7. 15.3.7. Creating the Playable Game Screen
        1. 15.3.7.1. MainGame.cs
      8. 15.3.8. Making the InGameMenu Screen
        1. 15.3.8.1. InGameMenu.cs
      9. 15.3.9. Creating the PuzzleComplete Screen
        1. 15.3.9.1. Message.cs
    4. 15.4. ENHANCING YOUR GAME
    5. 15.5. SUMMARY
  23. 16. Where Do You Go from Here?
    1. 16.1. TRIAL MODE
      1. 16.1.1. Understanding Trial Mode
      2. 16.1.2. Detecting Trial Mode
        1. 16.1.2.1. ShowMarketplace()
        2. 16.1.2.2. SimulateTrialMode()
        3. 16.1.2.3. IsTrialMode()
        4. 16.1.2.4. Sharing with a Friend
        5. 16.1.2.5. Running the Sample
    2. 16.2. PINNING YOUR GAME TILE TO THE START AREA
    3. 16.3. PUBLISHING
      1. 16.3.1. Requirements
      2. 16.3.2. Submission
      3. 16.3.3. Code Signing
    4. 16.4. WHERE TO GET HELP
      1. 16.4.1. Forums
      2. 16.4.2. Blogs
      3. 16.4.3. Search
    5. 16.5. SUMMARY

Product information

  • Title: Professional Windows® Phone 7 Game Development: Creating Games using XNA Game Studio 4
  • Author(s):
  • Release date: February 2011
  • Publisher(s): Wrox
  • ISBN: 9780470922446