Posts Tagged XNA
2D WndrPong! using the Microsoft XNA Game Studio v2.0!
Posted by eric in C# Programming, Gaming, General Programming, Microsoft XNA on December 28, 2007
I decided to take some time this weekend to sit down and learn what I could about the latest release of Microsoft’s XNA Game Studio. I started out with a book I purchased called Microsoft XNA Game Studio Creators Guide, which turned out to be a terrible book. Most of the examples in this book assume that you’re starting with a project the book provides on a Website, which already has hundreds of lines of code, custom shaders and everything built in… without even explaining how the code is working in the background.
After fumbling around with that for an hour or so an only succeeding in creating a small square on the screen, I headed over to Microsoft.com to see if any MSDN articles might exist to help me along in my ‘ground up’ learning of XNA. I was pleasantly surprised when I found a great article titled “Your First Game: Microsoft XNA Game Studio in 2D“. This was EXACTLY what I was looking for as it starts from the ground up, assuming the reader has never done game programming before, let alone 3D game programming.
The example provided my Microsoft in this article is a simple 2D Texture of a cat that bounces around the window. I was so pleased with the ease of coding this, I thought to myself, “Heck, how hard could it be to recreate Pong?”
So I set upon my task.
Several hours and many Coca-Cola bottles later I had not only my first XNA game running in Windows, but after purchasing the XNA Creators Club annual subscription from the XBox Live! marketplace for $99, I had it running on my XBox 360 as well
I decided to take a little extra time and add a debug information screen as well as a small welcome screen
Controls (PC):
Up/Down for Player 1 Paddle (Left): Q/A
Up/Down for Player 2 Paddle (Right): Up Arrow/Down Arrow
Debug Information: F1
Controls (XBox 360):
Up/Down for Player 1 Paddle (Left): Left Thumbstick on Player 1 Remote
Up/Down for Player 2 Paddle (Right): Left Thumbstick on Player 2 Remote
I did run into a couple of ‘gotchas!’ while working with Game Studio. The major one I had trouble with was when you’re developing for the XBox 360 you have to account for overscan on the Television and have your game render within the ‘Safe Area‘. I noticed that when I was playing my Pong! game on my LCD TV at 720p, the edges of the game were cut off and it looked like it was stretched past the borders of my TV. After asking the fine folks in #XNA on IRC about this issue, they were able to help me out. Now I have my Pong! game account for this by setting up an XBox 360 macro which pads the edges of the play area by 50 pixels.
I’m including the Source Code for my version of Pong! which I’ve titled, “2D WndrPong!”. You can work in XNA Game Studio for free using Visual C# 2005 Express Edition along with XNA Game Studio 2.0
To deploy your games to an XBox 360, you must pair your XBox with your PC (using the “XNA Game Studio Device Center” tool) then you must purchase an XNA Creators Club Membership from the XBox 360 Marketplace. I believe the prices are $49.99 for 3 Months, $99.99 for a year. I opted for the entire year since I know it’s going to take me some time to learn
Baby Steps
2D WndrPong! Source Code – Download (36k)


