Geek-o-Philiac

Friday, September 01, 2006

And Then There Was Pong

After getting "familiar" with the XNA input methods, I banged up a quick little version of Pong to play around. The process went something like this:

First, I imported all the graphics into the project and told XNA to copy them to the appropriate location. I used some Parodica graphics I had lyring around - Alex and Bekah were the paddles and Schmee was the ball.

Second, I put together a quick little texture cache class so that I didn't have to manage everything on my own and so I wouldn't have to create a new variable for every texture. I then discovered that the XNA Starter Kit Spacewar came with a slightly better version. I imagine both won't be all that useful once the Content Pipeline is integrated, but that remains to be seen.

Third, I made a quick Entity class to handle my (very) basic sprites. It was a hacked together class that is absolutely not meant for serious use, but programming Pong isn't a serious task.

Fourth, I wrote the code to handle the input. This was the ugliest stuff I've ever written. Not only am I unfond of the polling system found in XNA, but I'm further unfond of how these results are returned. Instead of being able to easily find out whether a key was down or not, I had to search through an array of pressed keys to find if the button I was interested in was located in the array. Very shabby stuff. I expect the next thing I'm going to do is write my own event management for input.

Fifth, I wrote some quick collision detection. Very typical stuff using bounding boxes. Nothing new here. XNA made the process simple enough via providing a BoundingBox class, but it's really not a lot of work to write one anyway.

I then called the project finished. The only remaining step was to add some sort of score display. Unfortunately, I didn't find any font support in the XNA 2D library, which is a pretty glaring omission that I'm not looking forward to implementing myself. It's not hard, but it's terribly uninteresting.

I'm pretty pleased thus far. Pong took me almost no time to develop, and most of that non-time was spent learning how to handle input. XNA isn't perfect, but it's also only in Beta. Based around comments in the XNA Team Blog, I expect that they will be adding a great deal of functionality. I'm interested to see how this library matures.

I was hoping to provide some code with this update, but I could not insert it without my formatting being mangled. If anyone could tell me how to work around that, I'd be appreciative.

0 Comments:

Post a Comment

<< Home