Home > Game Development, Learning > XNA Pong Deluxe

XNA Pong Deluxe

March 9th, 2008

The chapter 2 project is a Pong clone using simple 2D shapes. It supports one or two players with either the keyboard or a couple of gamepads.

Ben jumps right in with the Agile methodology of development, unit testing, and lots of wacky rectangles. My first look at the unit testing code frightened me a bit until I absorbed a few other examples.

The idea is that you should develop and test small pieces of the game before assembling them into something that can be played. Doing so avoids a situation where you get your game into a playable but buggy state where maybe the rendering code is the problem, maybe the collision detection is the problem, etc… Test reuse means that issues in subsequent iterations of the code can be quickly identified.

There’s some interesting discussion about designing a resolution-independent game. Since an XNA game could run on a PC or an Xbox 360 plugged into a TV, you can’t make assumptions about the screen. So instead of saying “place the player one paddle 20 pixels to the right of the left edge” you say “place the player one paddle an amount of pixels to the right of the left edge that is equal to five percent of the total horizontal resolution”. Similarly, the graphics and variables like the ball’s velocity (in pixels per second) are also scaled as necessary.

Unfortunately, if you follow the code in the book you won’t have a working program by the time you get to the end of the first unit test. The downloadable code associated with the book here (as of today) is also out of date, not ready for use as an XNA 2.0 project. If you want the actual correct XNA 2.0 version of the Pong code you have to visit the author’s personal site here. Lame.

I’ll have more later today.

techknight Game Development, Learning

  1. March 27th, 2008 at 17:15 | #1

    Interesting, please keep going!

  1. No trackbacks yet.