You are previewing XNA® Game Studio 4.0 for Xbox 360® Developers.
O'Reilly logo
XNA® Game Studio 4.0 for Xbox 360® Developers

Book Description

Discover how to create exciting and challenging games for the Xbox 360 using XNA Game Studio 4.0 and the Visual C# programming language. XNA Game Studio 4.0 for Xbox 360 Developers provides experienced game developers with a comprehensive overview of the XNA Framework, providing all the tools, source code, and information you need to develop Windows and Xbox 360 games. You'll find an introduction to programming in XNA, the XNA Framework, and all the new features included in XNA 4.0 to get you started. The bulk of the book focuses on the XNA Framework, in particular the features of the Xbox 360, including the controller, playing audio, and creating graphics. The final part of the book covers the major features of Xbox Live, including creating and rendering an avatar, 3D programming, loading and rendering a mesh using a basic shader, and networking via system link and online. You'll tie together all the skills you've learned in a final game project that demonstrates the networking capabilities of XNA and acts as a rudimentary, sprite-based networked game engine for your own projects. Source code and artwork from the book as well as Visual C# 2010 projects for Windows and Xbox 360 are available as accompanying downloads.

Table of Contents

  1. Copyright
    1. Dedication
  2. Acknowledgments
  3. About the Authors
  4. Introduction
    1. XNA Game Studio 4.0
    2. Licensing and Memberships
    3. What Will You Learn?
    4. Prerequisites
    5. Required Software
    6. Downloading the Sources
    7. Contents
    8. Conventions Used in This Book
    9. Companion Web Site Downloads
  5. I. Introduction and Primer
    1. 1. Introduction to XNA Game Studio 4.0
      1. A Little History of XNA
      2. What XNA Is
      3. What XNA Isn’t
      4. How Does XNA Code Compare?
        1. XNA Code
        2. DirectX Code
        3. Engine Code
      5. Mobile Devices
      6. Xbox 360
      7. The XNA Framework
        1. The XNA Framework Library
        2. The XNA Application Framework
        3. XNA Game Studio
        4. XNA Build and the Content Pipeline
        5. The Content Framework Pipeline
      8. XNA Creators Club
      9. Summary
    2. 2. Peeking Under the Hood
      1. Reverse Engineering an Example
        1. Understanding Using Statements
        2. Examining the Game Class
          1. Game Class: Public Properties
          2. Game Class: Public Events
          3. Game Class: Protected Methods
          4. Game Class: Public Methods
          5. Where Is the Game Object Created?
        3. The Frame Update Demo Program
          1. Adjusting the Update() Rate
          2. Using High-Definition 720p Mode
      2. Summary
  6. II. XNA Framework Library
    1. 3. XNA Framework Overview
      1. Perusing the XNA Framework
      2. Microsoft.XNA.Framework
        1. Classes
          1. BoundingFrustum
          2. Curve
          3. CurveKey
          4. CurveKeyCollection
          5. DrawableGameComponent
          6. FrameworkDispatcher
          7. Game
          8. GameComponent
          9. GameComponentCollection
          10. GameComponentCollectionEventArgs
          11. GameServiceContainer
          12. GameTime
          13. GameWindow
          14. GraphicsDeviceInformation
          15. GraphicsDeviceManager
          16. LaunchParameters
          17. MathHelper
          18. PreparingDeviceSettingsEventArgs
          19. TitleContainer
        2. Microsoft.XNA.Framework Structures
          1. BoundingBox
          2. BoundingSphere
          3. Color
          4. Matrix
          5. Plane
          6. Point
          7. Quaternion
          8. Ray
          9. Rectangle
          10. Vector2
          11. Vector3
          12. Vector4
        3. Microsoft.XNA.Framework Enumerations
          1. ContainmentType
          2. CurveContinuity
          3. CurveLoopType
          4. CurveTangent
            1. DisplayOrientation
          5. PlaneIntersectionType
          6. PlayerIndex
      3. Summary
    2. 4. Audio
      1. Microsoft.Xna.Framework.Audio Reference
        1. Classes
          1. AudioEmitter
          2. AudioEngine
          3. AudioListener
          4. Cue
          5. DynamicSoundEffectInstance
          6. InstancePlayLimitException
          7. Microphone
          8. NoAudioHardwareException
          9. NoMicrophoneConnectedException
          10. SoundBank
          11. SoundEffect
          12. SoundEffectInstance
          13. WaveBank
        2. Structures
          1. AudioCategory
          2. RendererDetail
        3. Enumerations
          1. AudioChannels
          2. AudioStopOptions
          3. MicrophoneState
          4. SoundState
      2. Simple Audio Playback
        1. Adding Audio Content to the Project
        2. Loading the Audio Clip
        3. Playing the Audio Clip
        4. Audio Clip Length
        5. SoundEffectInstance
      3. Cross-Platform Audio Creation Tool (XACT)
        1. Creating a New Audio Project
        2. Building the Audio Project
        3. Playing Sounds from an XACT Project
      4. Summary
    3. 5. Content
      1. Microsoft.Xna.Framework.Content Reference
        1. Classes
          1. ContentLoadException
          2. ContentManager
          3. ContentReader
          4. ContentSerializerAttribute
          5. ContentSerializerCollectionItemNameAttribute
          6. ContentSerializerIgnoreAttribute
          7. ContentSerializerRuntimeTypeAttribute
          8. ContentSerializerTypeVersionAttribute
          9. ContentTypeReader
          10. ContentTypeReaderManager
          11. ResourceContentManager
      2. Loading Known Asset Types
      3. Loading Custom Assets and Data with a Content Pipeline Extension
        1. Creating a Text File Content Importer
          1. Importer (Extension Project)
          2. Processor (Extension Project)
          3. Writer (Extension Project)
          4. Reader (GameLibrary Project)
        2. Building Text Files as Content
      4. Summary
    4. 6. GamerServices
      1. Microsoft.Xna.Framework.GamerServices Reference
        1. Classes
          1. Achievement
          2. AchievementCollection
          3. AvatarAnimation
          4. AvatarDescription
          5. AvatarRenderer
          6. FriendCollection
          7. FriendGamer
          8. GameDefaults
          9. Gamer
          10. GamerCollection
          11. GamerPresence
          12. GamerPrivilegeException
          13. GamerPrivileges
          14. GamerProfile
          15. GamerServicesComponent
          16. GamerServicesDispatcher
          17. GamerServicesNotAvailableException
          18. GameUpdateRequiredException
          19. Guide
          20. GuideAlreadyVisibleException
          21. InviteAcceptedEventArgs
          22. LeaderboardEntry
          23. LeaderboardReader
          24. LeaderboardWriter
          25. NetworkException
          26. NetworkNotAvailableException
          27. PropertyDictionary
          28. SignedInEventArgs
          29. SignedInGamer
          30. SignedInGamerCollection
          31. SignedOutEventArgs
        2. Interfaces
          1. IAvatarAnimation
        3. Structures
          1. AvatarExpression
          2. GamerCollection.GamerCollectionEnumerator
          3. LeaderboardIdentity
        4. Enumerations
          1. AvatarAnimationPreset
          2. AvatarBodyType
          3. AvatarBone
          4. AvatarEye
          5. AvatarEyebrow
          6. AvatarMouth
          7. AvatarRendererState
          8. ControllerSensitivity
          9. GameDifficulty
          10. GamerPresenceMode
          11. GamerPrivilegeSetting
          12. GamerZone
          13. LeaderboardKey
          14. LeaderboardOutcome
          15. MessageBoxIcon
          16. NotificationPosition
          17. RacingCameraAngle
      2. GamerProfile Demo Program
      3. Summary
    5. 7. Graphics
      1. Microsoft.Xna.Framework.Graphics Reference
        1. Classes
          1. AlphaTestEffect
          2. BasicEffect
          3. BlendState
          4. DepthStencilState
          5. DeviceLostException
          6. DeviceNotResetException
          7. DirectionalLight
          8. DisplayMode
          9. DisplayModeCollection
          10. DualTextureEffect
          11. DynamicIndexBuffer
          12. DynamicVertexBuffer
          13. Effect
          14. EffectAnnotation
          15. EffectAnnotationCollection
          16. EffectMaterial
          17. EffectParameter
          18. EffectParameterCollection
          19. EffectPass
          20. EffectPassCollection
          21. EffectTechnique
          22. EffectTechniqueCollection
          23. EnvironmentMapEffect
          24. GraphicsAdapter
          25. GraphicsDevice
          26. GraphicsResource
          27. IndexBuffer
          28. Model
          29. ModelBone
          30. ModelBoneCollection
          31. ModelEffectCollection
          32. ModelMesh
          33. ModelMeshCollection
          34. ModelMeshPart
          35. ModelMeshPartCollection
          36. NoSuitableGraphicsDeviceException
          37. OcclusionQuery
          38. PresentationParameters
          39. RasterizerState
          40. RenderTarget2D
          41. RenderTargetCube
          42. ResourceCreatedEventArgs
          43. ResourceDestroyedEventArgs
          44. SamplerState
          45. SamplerStateCollection
          46. SkinnedEffect
          47. SpriteBatch
          48. SpriteFont
          49. Texture
          50. Texture2D
          51. Texture3D
          52. TextureCollection
          53. TextureCube
          54. VertexBuffer
          55. VertexDeclaration
        2. Interfaces
          1. IEffectFog
          2. IEffectLights
          3. IEffectMatrices
          4. IGraphicsDeviceService
          5. IVertexType
        3. Structures
          1. ModelBoneCollection.Enumerator
          2. ModelEffectCollection.Enumerator
          3. ModelMeshCollection.Enumerator
          4. ModelMeshPartCollection.Enumerator
          5. RenderTargetBinding
          6. VertexBufferBinding
          7. VertexElement
          8. VertexPositionColor
          9. VertexPositionColorTexture
          10. VertexPositionNormalTexture
          11. VertexPositionTexture
          12. Viewport
        4. Enumerations
          1. Blend
          2. BlendFunction
          3. BufferUsage
          4. ClearOptions
          5. ColorWriteChannels
          6. CompareFunction
          7. CubeMapFace
          8. CullMode
          9. DepthFormat
          10. EffectParameterClass
          11. EffectParameterType
          12. FillMode
          13. GraphicsDeviceStatus
          14. GraphicsProfile
          15. IndexElementSize
          16. PresentInterval
          17. PrimitiveType
          18. RenderTargetUsage
          19. SetDataOptions
          20. SpriteEffects
          21. SpriteSortMode
          22. StencilOperation
          23. SurfaceFormat
          24. TextureAddressMode
          25. TextureFilter
          26. VertexElementFormat
          27. VertexElementUsage
      2. Summary
    6. 8. Input
      1. Microsoft.Xna.Framework.Input Reference
        1. Classes
          1. GamePad
          2. Keyboard
          3. Mouse
        2. Structures
          1. GamePadButtons
          2. GamePadCapabilities
          3. GamePadDPad
          4. GamePadState
          5. GamePadThumbSticks
          6. GamePadTriggers
          7. KeyboardState
          8. MouseState
        3. Enumerations
          1. Buttons
          2. ButtonState
          3. GamePadDeadZone
          4. GamePadType
          5. Keys
          6. KeyState
      2. Input Demo Program
        1. Keyboard Input
        2. Mouse Input
        3. Controller Input
        4. Input Demo Source
      3. Summary
    7. 9. Media
      1. Microsoft.Xna.Framework.Media Reference
        1. Classes
          1. Album
          2. AlbumCollection
          3. Artist
          4. ArtistCollection
          5. Genre
          6. GenreCollection
          7. MediaLibrary
          8. MediaPlayer
          9. MediaQueue
          10. MediaSource
          11. Picture
          12. PictureAlbum
          13. PictureAlbumCollection
          14. PictureCollection
          15. Playlist
          16. PlaylistCollection
          17. Song
          18. SongCollection
          19. Video
          20. VideoPlayer
          21. VisualizationData
        2. Enumerations
          1. MediaSourceType
          2. MediaState
          3. VideoSoundtrackType
      2. Media Demo Program
      3. Summary
    8. 10. Net
      1. Microsoft.Xna.Framework.Net Reference
        1. Classes
          1. AvailableNetworkSession
          2. AvailableNetworkSessionCollection
          3. GameEndedEventArgs
          4. GamerJoinedEventArgs
          5. GamerLeftEventArgs
          6. GameStartedEventArgs
          7. HostChangedEventArgs
          8. LocalNetworkGamer
          9. NetworkGamer
          10. NetworkMachine
          11. NetworkSession
          12. NetworkSessionEndedEventArgs
          13. NetworkSessionJoinException
          14. NetworkSessionProperties
          15. PacketReader
          16. PacketWriter
          17. QualityOfService
          18. WriteLeaderboardsEventArgs
        2. Enumerations
          1. NetworkSessionEndReason
          2. NetworkSessionJoinError
          3. NetworkSessionState
          4. NetworkSessionType
          5. SendDataOptions
      2. Summary
    9. 11. Storage
      1. Microsoft.Xna.Framework.Storage Reference
        1. File Input/Output Access
        2. Classes
          1. StorageContainer
          2. StorageDevice
          3. StorageDeviceNotConnectedException
      2. Storage Demo Program
        1. Saving Data
        2. Storage Demo Program
      3. Summary
  7. III. Xbox Live
    1. 12. Avatars
      1. Gamer Profile Avatars
        1. Retrieving a Gamer Avatar
        2. Creating a Random Avatar
        3. Rendering a Gamer Avatar
        4. Avatar Demo Project
        5. Custom Avatar Animations
      2. Summary
    2. 13. Guide
      1. Using the Guide
        1. Displaying a Message Box
        2. Using the Virtual Keyboard
      2. Summary
    3. 14. Multiplayer Networking
      1. Network Sessions
        1. Multiple Accounts
          1. Xbox Live
          2. Windows Live
        2. Creating a Game Session
        3. Joining a Game Session
        4. Sending Data (Outgoing Packets)
        5. Receiving Data (Incoming Packets)
        6. Disconnecting from a Session
        7. Network Session Demo Source Code
      2. Summary
    4. 15. Meshes
      1. Working with Meshes
        1. Mesh File Formats
        2. Loading a Mesh
        3. Rendering a Mesh
          1. Projection Matrix
          2. View Matrix
          3. World Matrix
          4. Drawing a Model
        4. Mesh Demo
      2. Summary
    5. 16. Sprites
      1. Sprite Programming
        1. Transparency
        2. Gravity Collision Demo Program
      2. Drawing Animated Sprites
        1. The Sprite Class
        2. The Animation Demo Program
      3. Summary
    6. 17. Multiplayer Game Engine
      1. Building a Simple XNA Engine
        1. Integrating the Engine
          1. Font Support
          2. Engine Source Code
      2. Building the Tank Battle Game
        1. Artwork
        2. Gameplay Classes
          1. Ground Class
          2. Tank Class
          3. Shell Class
        3. Game Source Code
        4. Improving the Game
      3. Summary
  8. Resources for Further Study
    1. Web Resources for Further Study
      1. Book Support Web Sites
      2. Game-Development Sites
      3. News, Reviews, and Downloads
      4. Industry
      5. Humor
    2. Print Resources for Further Study
      1. Books by This Author
        1. Advanced 2D Game Development
        2. Beginning Game Programming, 3rd Edition
        3. Beginning Java Game Programming, 2nd Edition
        4. DarkBASIC Pro Game Programming, 2nd Edition
        5. Game Programming All in One, 3rd Edition
        6. Multi-Threaded Game Engine Design
        7. Visual Basic Game Programming for Teens, 3rd Edition
        8. Visual C# Game Programming for Teens
      2. Additional Books
        1. AI Techniques for Game Programming
        2. Artificial Intelligence for Games, 2nd Edition
        3. Best of Game Programming Gems
        4. Microsoft C# Programming for the Absolute Beginner
        5. Character Animation with Direct3D
        6. Character Development and Storytelling for Games
        7. Data Structures and Algorithms for Game Developers
        8. Emergence in Games
        9. Game Coding Complete, 3rd Edition
        10. Game Engine Architecture
        11. Going to War: Creating Computer War Games
        12. Introduction to 3D Game Programming with DirectX 9.0c: A Shader Approach
        13. Mathematics for 3D Game Programming and Computer Graphics, 2nd Edition
        14. Mathematics for Game Developers
        15. Programming an RTS Game with Direct3D
        16. Real-Time Rendering, 3rd Edition