Archive

Posts Tagged ‘pxp’

XNA Pong Deluxe

March 9th, 2008 1 comment

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.

Categories: Game Development, Learning Tags:

Hello XNA

March 2nd, 2008 No comments

I’m done with the first chapter of Professional XNA Programming (2nd edition) by Benjamin Nitschke. It jumps right in to things without a lot of explanations… It’s not bad, but there are some annoying bits like the screenshots and text not being fully updated for the latest version of XNA Game Studio. There must have been a pretty long publishing lead time.

Anyway, chapter 1 explains the basic structure (Initialize, Update Draw) and content pipeline of games developed with XNA. It also shows how to load 2D textures and take input from the gamepad and keyboard.

Here is a happy fellow that you can move around the screen:

Mmm, hot dogs

Categories: Game Development, Learning Tags: