Thursday, November 24, 2011

XNA .NET Bouncy Rectangle Tutorial

Happy Thanksgiving!, great to have a relaxing Thursday morning on the couch, doing nothing but watching last night's NHL highlights while tinkering with some new programming technologies, drinking a cup of strong coffee.

This past summer I spent some time trying to develop some sample game code (blog post: fixed-frequency-uncoupled-game-loop) in C, using libSDL on the Linux platform. I made some progress, but it was difficult, fairly low level, and I kind of lost motivation when work picked up for me this fall.

Recently I downloaded and installed the MS Visual Studio 2010 Express with XNA Game Studio 4.0 to give Windows/XBOX/Windows Phone game programming a shot to hopefully make faster progress. I have done C# before with my adventures in the WorldWind .NET project. Here is my result of my efforts this morning, a moving rectangle sprite:

It was fairly revealing that the easy to follow first tutorial for XNA Windows game development was creating a sprite that moves around a game window, just like my bouncy rectangle game. It took me about half an hour to build the tutorial, what took several days in C with libSDL. The basic project takes care of the game loop for it and it seems to be an uncoupled model between the game logic and drawing of graphics. The game played at a constant speed plus my CPU was only around 7% utilized.

I guess the tradeoff is being locked into Microsoft products, with little hope of ever porting to other platforms. But given I am my own developer, it makes sense to use this platform to actually get some programs made. I like how all the tools are basically free and well integrated together.