XNA 4.0 Game Development by Example Beginner's Guide

Book description

"

Create your own exciting games with Microsoft XNA 4.0

  • Dive headfirst into game creation with XNA
  • Four different styles of games comprising a puzzler, a space shooter, a multi-axis shoot 'em up, and a jump-and-run platformer
  • Games that gradually increase in complexity to cover a wide variety of game development techniques
  • Focuses entirely on developing games with the free version of XNA
  • Packed with many suggestions for expanding your finished game that will make you think critically, technically, and creatively
  • Fresh writing filled with many fun examples that introduce you to game programming concepts and implementation with XNA 4.0
  • A practical beginner's guide with a fast-paced but friendly and engaging approach towards game development

In Detail

XNA Game Studio enables hobbyists and independent game developers to easily create video games. It gives you the power to bring your creations to life on Windows, the Xbox 360, the Zune, and the Windows Phone platforms. But before you give life to your creativity with XNA, you need to gain a solid understanding of some game development concepts.

This book covers both the concepts and the implementations necessary to get you started on bringing your own creations to life with XNA. It details the creation of four games, all in different styles, from start to finish using the Microsoft XNA Framework, including a puzzler, space shooter, multi-axis shoot-'em-up, and a jump-and-run platform game. Each game introduces new concepts and techniques to build a solid foundation for your own ideas and creativity.

Beginning with the basics of drawing images to the screen, the book then incrementally introduces sprite animation, particles, sound effects, tile-based maps, and path finding. It then explores combining XNA with Windows Forms to build an interactive map editor, and builds a platform-style game using the editor-generated maps. Finally, the book covers the considerations necessary for deploying your games to the Xbox 360 platform.

By the end of the book, you will have a solid foundation of game development concepts and techniques as well as working sample games to extend and innovate upon. You will have the knowledge necessary to create games that you can complete without an army of fellow game developers at your back.

A step-by-step tutorial to using Microsoft XNA by creating four different styles of video games.

"

Table of contents

  1. XNA 4.0 Game Development by Example Beginner's Guide
    1. Table of Contents
    2. XNA 4.0 Game Development by Example Beginner's Guide
    3. Credits
    4. About the Author
    5. About the Reviewers
    6. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Time for action – heading
        1. What just happened?
        2. Have a go hero – heading
      6. Reader feedback
      7. Customer support
        1. Errata
        2. Piracy
        3. Questions
    7. 1. Introducing XNA Game Studio
      1. Overview of the games
      2. System requirements
      3. Installing XNA Game Studio
      4. Time for action – installing XNA Game Studio
        1. What just happened?
      5. Building your first game
      6. Time for action – creating a new Windows game project
        1. What just happened?
        2. Anatomy of an XNA game
          1. The declarations area
      7. Time for action – adding variables to the class declaration area
        1. What just happened?
          1. The Game1 class constructor
          2. The Initialize() method
      8. Time for action – customizing the Initialize() method
        1. What just happened?
          1. The LoadContent() method
      9. Time for action – creating the squareTexture
        1. What just happened?
          1. The Update() method
      10. Time for action – coding Update() for SquareChase
        1. What just happened?
          1. The Draw() method
      11. Time for action – draw SquareChase!
        1. What just happened?
      12. Time for action – play SquareChase!
        1. What just happened?
        2. Have a go hero
      13. Summary
    8. 2. Flood Control – Underwater Puzzling
      1. Designing a puzzle game
      2. Time for action – set up the Flood Control project
        1. What just happened?
      3. Introducing the Content Pipeline
      4. Time for action – reading textures into memory
        1. What just happened?
      5. Sprites and sprite sheets
      6. Classes used in Flood Control
      7. The GamePiece class
        1. Identifying a GamePiece
      8. Time for action – build a GamePiece class – declarations
        1. What just happened?
        2. Creating a GamePiece
      9. Time for action – building a GamePiece class: constructors
        1. What just happened?
        2. Updating a GamePiece
      10. Time for action – GamePiece class methods – part 1 – updating
        1. Rotating pieces
      11. Time for action – GamePiece class methods – part 2 – rotation
        1. What just happened?
        2. Pipe connectors
      12. Time for action – GamePiece class methods – part 3 – connection methods
        1. Sprite sheet coordinates
      13. Time for action – GamePiece class methods – part 4 – GetSourceRect
        1. What just happened?
      14. The GameBoard class
      15. Time for action – create the GameBoard.cs class
        1. What just happened?
        2. Creating the game board
      16. Time for action – initialize the game board
        1. What just happened?
        2. Updating GamePieces
      17. Time for action – manipulating the game board
        1. What just happened?
        2. Filling in the gaps
      18. Time for action – filling in the gaps
        1. What just happened?
        2. Generating new pieces
      19. Time for action – generating new pieces
        1. What just happened?
        2. Water filled pipes
      20. Time for action – water in the pipes
        1. What just happened?
        2. Propagating water
      21. Time for action – making the connection
        1. What just happened?
      22. Building the game
        1. Declarations
      23. Time for action – Game1 declarations
        1. What just happened?
        2. Initialization
      24. Time for action – updating the Initialize() method
        1. What just happened?
        2. The Draw() method – the title screen
      25. Time for action – drawing the screen – the title screen
        1. What just happened?
        2. The Draw() method – the play screen
      26. Time for action – drawing the screen – the play screen
        1. What just happened?
        2. Keeping score
      27. Time for action – scores and scoring chains
        1. What just happened?
        2. Input handling
      28. Time for action – handling mouse input
        1. What just happened?
        2. Letting the player play!
      29. Time for action – letting the player play
        1. What just happened?
      30. Play the game
      31. Summary
    9. 3. Flood Control – Smoothing Out the Rough Edges
      1. Animated pieces
        1. Classes for animated pieces
      2. Time for action – rotating pieces
        1. What just happened?
      3. Time for action – falling pieces
        1. What just happened?
      4. Time for action – fading pieces
        1. What just happened?
        2. Managing animated pieces
      5. Time for action – updating GameBoard to support animatedpieces
        1. What just happened?
        2. Fading pieces
      6. Time for action – generating fading pieces
        1. What just happened?
        2. Falling pieces
      7. Time for action – generating falling pieces
        1. What just happened?
        2. Rotating pieces
      8. Time for action – modify Game1 to generate rotating pieces
        1. What just happened?
        2. Calling UpdateAnimatedPieces()
      9. Time for action – updating Game1 to update animated pieces
        1. What just happened?
        2. Drawing animated pieces
      10. Time for action – update Game1 to draw animated pieces
        1. What just happened?
          1. SpriteBatch overloads
      11. SpriteFonts
      12. Time for action – add SpriteFonts to Game1
        1. What just happened?
        2. Score display
      13. Time for action – drawing the score
        1. What just happened?
        2. ScoreZooms
      14. Time for action – creating the ScoreZoom class
        1. What just happened?
      15. Time for action – updating and displaying ScoreZooms
        1. What just happened?
        2. Adding the GameOver game state
      16. Time for action – game over
        1. What just happened?
      17. The flood
      18. Time for action – tracking the flood
        1. What just happened?
        2. Displaying the flood
      19. Time for action – displaying the flood
        1. What just happened?
        2. Difficulty levels
      20. Time for action – adding difficulty levels
        1. What just happened?
        2. Have a go hero
      21. Summary
    10. 4. Asteroid Belt Assault – Lost in Space
      1. Creating the project
      2. Time for action – creating the Asteroid Belt Assault project
        1. What just happened?
      3. Another definition for "sprite"
        1. Building the Sprite class
      4. Time for action – declarations for the Sprite class
        1. What just happened?
      5. Time for action – Sprite constructor
        1. What just happened?
      6. Time for action – basic Sprite properties
        1. What just happened?
      7. Time for action – animation and drawing properties
        1. What just happened?
        2. Collision detection
      8. Time for action – supporting collision detection
        1. What just happened?
        2. Animation and movement
      9. Time for action – adding animation frames
        1. What just happened?
      10. Time for action – updating the Sprite
        1. What just happened?
      11. Time for action – drawing the Sprite
        1. What just happened?
      12. A sprite-based star field
      13. Time for action – creating the StarField class
        1. What just happened?
      14. Time for action – updating and drawing the StarField
        1. What just happened?
      15. Time for action – viewing the StarField in action
        1. What just happened?
      16. Animated sprites – asteroids
      17. Time for action – building the AsteroidManager class
        1. What just happened?
        2. Positioning the asteroids
      18. Time for action – positioning the asteroids
        1. What just happened?
      19. Time for action – checking the asteroid's position
        1. What just happened?
      20. Time for action – updating and drawing asteroids
        1. What just happened?
        2. Colliding asteroids
      21. Time for action – bouncing asteroids – part 1
        1. What just happened?
      22. Time for action – bouncing asteroids – part 2
        1. What just happened?
      23. Player and enemy shots
      24. Time for action – adding the ShotManager class
        1. What just happened?
      25. Time for action – firing shots
        1. What just happened?
      26. Time for action – updating and drawing shots
        1. What just happened?
      27. Adding the player
      28. Time for action – creating the PlayerManager class
        1. What just happened?
        2. Handling user input
      29. Time for action – handling user input
        1. What just happened?
      30. Time for action – updating and drawing the player's ship
        1. What just happened?
      31. Enemy ships
      32. Time for action – creating the Enemy class
        1. What just happened?
      33. Time for action – waypoint management
        1. What just happened?
      34. Time for action – enemy update and draw
        1. What just happened?
        2. The EnemyManager class
      35. Time for action – creating the EnemyManager class
        1. What just happened?
        2. Managing waypoints
      36. Time for action – setting up the EnemyManager class
        1. What just happened?
      37. Time for action – spawning enemies
        1. What just happened?
      38. Time for action – updating and drawing the EnemyManager
        1. What just happened?
      39. Summary
    11. 5. Asteroid Belt Assault – Special Effects
      1. Explosion effects
        1. Expanding on sprites – particles
      2. Time for action – constructing the Particle class
        1. What just happened?
      3. Time for action – updating and drawing particles
        1. What just happened?
        2. Particle explosions
      4. Time for action – the ExplosionManager class
        1. What just happened?
      5. Time for action – creating explosions
        1. What just happened?
      6. Time for action – updating and drawing explosions
        1. What just happened?
      7. The collision manager
      8. Time for action – creating the CollisionManager class
        1. What just happened?
        2. Handling collisions
      9. Time for action – player shot collisions
        1. What just happened?
      10. Time for action – player collisions
        1. What just happened?
      11. Time for action – using the CollisionManager class
        1. What just happened?
      12. Sound effects
        1. Generating and finding sound effects
        2. Sound in XNA
      13. Time for action – building a sound effects manager
        1. What just happened?
      14. Time for action – using the SoundManager class
        1. What just happened?
      15. The game structure
      16. Time for action – structuring the game
        1. What just happened?
      17. Time for action – drawing the game structure
        1. What just happened?
        2. Have a go hero
      18. Summary
    12. 6. Robot Rampage – Multi-Axis Mayhem
      1. Statics, statics, everywhere
      2. Time for action – creating the Robot Rampage project
        1. What just happened?
      3. A world larger than the screen
        1. Defining a camera
      4. Time for action – creating the Camera class
        1. What just happened?
        2. World-aware sprites
      5. Time for action – building a new Sprite class
        1. What just happened?
        2. Visualizing the view
      6. Time for action – viewing the Sprite and Camera classes in action
        1. What just happened?
      7. The game world – tile-based maps
        1. Tiles
        2. The tile map
      8. Time for action – creating the TileMap class
        1. What just happened?
        2. Map squares
      9. Time for action – dealing with map squares
        1. What just happened?
        2. Dealing with tiles
      10. Time for action – handling tiles
        1. What just happened?
        2. Drawing the map
      11. Time for action – drawing the tile map
        1. What just happened?
        2. Generating a random map
      12. Time for action – random wall placement
        1. What just happened?
      13. Adding the player
        1. Building the Player class
      14. Time for action – building the Player class
        1. What just happened?
        2. Moving around the world
      15. Time for action – handling input
        1. What just happened?
        2. Staying in bounds
      16. Time for action – staying in bounds
        1. What just happened?
        2. Running into tiles
      17. Time for action – accounting for walls
        1. What just happened?
      18. Summary
    13. 7. Robot Rampage – Lots and Lots of Bullets
      1. Visual effects
        1. Revisiting particles
      2. Time for action – the Particle class
        1. What just happened?
        2. The EffectsManager class
      3. Time for action – the EffectsManager class
        1. What just happened?
      4. Time for action – building explosions
        1. What just happened?
      5. Time for action – spark effects
        1. What just happened?
      6. Adding weaponry
        1. The WeaponManager class
      7. Time for action – beginning the WeaponManager class
        1. What just happened?
        2. Weapon upgrades
      8. Time for action – new weapons
        1. What just happened?
        2. Shot to map collisions
      9. Time for action – shots colliding with tiles
        1. What just happened?
        2. Power-ups
      10. Time for action – power-ups
        1. What just happened?
        2. We still have a problem...
      11. Path finding
        1. The A* path-finding algorithm
        2. Implementing A*
      12. Time for action – the PathNode class
        1. What just happened?
      13. Time for action – beginning the implementation of A*
        1. What just happened?
      14. Time for action – finding the path
        1. What just happened?
      15. Time for action – adjacent squares
        1. What just happened?
        2. Safely placing power-ups
      16. Time for action – updating the WeaponManager class
        1. What just happened?
      17. Player goals
        1. Computer terminals
      18. Time for action – building a computer terminal
        1. What just happened?
        2. Spawning computer terminals
      19. Time for action – the GoalManager class
        1. What just happened?
      20. Enemy robots
        1. Enemy basics
      21. Time for action – building the Enemy class
        1. What just happened?
        2. Moving enemies
      22. Time for action – enemy AI methods
        1. What just happened?
        2. The enemy manager
      23. Time for action – the enemy manager
        1. What just happened?
        2. Updating the WeaponManager
      24. Time for action – destroying enemies
        1. What just happened?
      25. Game structure
      26. Time for action – the GameManager class
        1. What just happened?
        2. Keeping score
      27. Time for action – awarding points
        1. What just happened?
        2. Updating Game1
      28. Time for action – updating the Game1 class
        1. What just happened?
        2. Have a go hero
      29. Summary
    14. 8. Gemstone Hunter – Put on Your Platform Shoes
      1. Borrowing graphics
      2. Time for action – creating projects
        1. What just happened?
      3. A more advanced tile engine
      4. Time for action – the MapSquare class
        1. What just happened?
        2. Rebuilding the camera
      5. Time for action – the Camera class
        1. What just happened?
        2. Constructing the tile engine
      6. Time for action – the TileMap class – part 1
        1. What just happened?
      7. Time for action – the TileMap class – part 2
        1. What just happened?
        2. Drawing the tile map
      8. Time for action – the TileMap class – part 3
        1. What just happened?
      9. Time for action – adding the tile map to the game project
        1. What just happened?
      10. The map editor project
        1. Creating the map editor project
      11. Time for action – creating the level editor project
        1. What just happened?
        2. Adding a form
      12. Time for action – adding a form
        1. What just happened?
      13. Time for action – adding event handlers
        1. What just happened?
        2. Filling Out Our Form
      14. Time for action – creating the menu bar
        1. What just happened?
      15. Time for action – tile selection controls
        1. What just happened?
      16. Time for action – scroll bars
        1. What just happened?
      17. Time for action – final controls
        1. What just happened?
        2. Updating the Game1 class
      18. Time for action – updating Game1
        1. What just happened?
      19. Time for action – the Game1 Update method
        1. What just happened?
        2. Connecting the form to the game
      20. Time for action – completing the editor – part 1
        1. What just happened?
      21. Time for action – fixing the scrolling delay
        1. What just happened?
        2. Loading and Saving Maps
      22. Time for action – implementing loading and saving
        1. What just happened?
        2. Passability
        3. Map codes
      23. One last issue
      24. Time for action – handling the FormClosed event
        1. What just happened?
        2. Have a go hero
      25. Summary
    15. 9. Gemstone Hunter – Standing on Your Own Two Pixels
      1. Animation strips
      2. Time for action – building the Animation class
        1. What just happened?
      3. Animated game objects
      4. Time for action – building the GameObject class – Part 1
        1. What just happened?
        2. Drawing, animation, and movement
      5. Time for action – building the GameObject class – part 2
        1. What just happened?
        2. Map-based collision detection
      6. Time for action – building the GameObject class – part 3
        1. What just happened?
      7. The Player
      8. Time for action – creating the Player class
        1. What just happened?
        2. Running...
      9. Time for action – overriding the Update() method – part 1
        1. What just happened?
        2. ...and jumping
      10. Time for action – overriding the Update() method – part 2
        1. What just happened?
        2. Staying on the screen
      11. Time for action – repositioning the camera
        1. What just happened?
      12. Loading levels
        1. The LevelManager class
      13. Time for action – building the LevelManager class
        1. What just happened?
      14. Gemstones
      15. Time for action – building the Gemstone class
        1. What just happened?
        2. Scoring
      16. Time for action – implementing score tracking
        1. What just happened?
      17. Enemies
      18. Time for action – summoning up the zombies
        1. What just happened?
        2. Player-enemy interaction
      19. Time for action – interacting with zombies
        1. What just happened?
      20. Level transitions
      21. Time for action – supporting map transitions
        1. What just happened?
      22. Processing other codes
      23. Time for action – handling codes
        1. What just happened?
      24. Game structure
      25. Time for action – implementing game states
        1. What just happened?
        2. Have a go hero
      26. Summary
    16. Index

Product information

  • Title: XNA 4.0 Game Development by Example Beginner's Guide
  • Author(s): Kurt Jaegers
  • Release date: September 2010
  • Publisher(s): Packt Publishing
  • ISBN: 9781849690669