Creating games using XNA

I wrote my last game, Fusion, using cocos2d-javascript. While I liked the library, I wanted to branch out before committing to any framework. As a veteran developer, but new game developer, I knew the trap of falling in love with the first viable framework and ignoring all others. So for my next game, I wanted to really change things up and explore other languages, platforms and frameworks.

I decided to work with XNA to create small Windows games. I have created two simple XNA games, and am preparing for the third. The first two were for testing and to help me learn XNA, and are simple clones of Pong and Tetris.

The Pong clone is a simple two person pong game. I used this to help set up a small framework that I would reuse for the Tetris clone. Pong is unpolished, but working, and taught me a few important lessons about XNA:

  • XNA has very poor input handling. I had to write an input object that parsed the keyboard and mouse state on each frame to check for changes. Not only does XNA provide little information on the input, it has no native support for event handlers. In cocos2d-javascript, the support for onclick or onmouseover events was amazing. I had to recreate large portions of this for XNA.
  • cocos2d's usage of scenes, layers and objects is a solid setup. I mimicked this setup while designing my framework and am very pleased with the results. I know this goes against my desire to learn something new, but when XNA provided me only a blank canvas with no support, I had to recreate the setup that I knew would work.

After I finished Pong, I took the lessons learned and created a small framework called Torch and began to work on Tetris. Tetris is my most complete game to date, containing full menus, options and sounds. Unlike Fusion or Pong, it has everything that a game should have, albeit in a small package. I even made an installer using NSIS so that the game can be distributed properly.

While working on Tetris, I learned more about XNA and C#, such as:

  • XNA is fickle with fonts. It only supports TrueType and has no anti-aliasing. I saw that there is a framework called Nuclex that could fix this issue, but I was unable to get it to work. Instead, large text is pre-rendered and applied as an image, and small text is not as noticeably aliased.
  • XNA has no in built support for application settings. I'm not sure why .NET supports this on Windows Forms applications, but Microsoft stripped it out for XNA. I had to find external libraries to provide persistent settings such as keybindings and high scores.
  • C# event handlers are pretty amazing. I created event handlers to handle keyboard / mouse input and they worked very nicely. They still could be improved, but it is much better than I thought I would be working with. I used to think JavaScript's biggest strength was event handlers, but C#'s aren't that far behind.
  • Strong typing is useful, but can be tedious. I found myself frequently typecasting the scenes and layers to call custom functions on the derived class. It added a lot of fluff to my code that makes it hard to read in places.

As I begin my next game, I am further refining Torch to handle issues I found during the making of Tetris. In particular, I need more work on the fonts, sounds and input. After this third game, I have no plans to continue with either XNA or Torch, but I might do so anyway. I have looked into MonoGame and Nuclex, but I also might use Allegro or some other non .NET library. At this stage, I just want to gain familiarity with a variety of frameworks and languages so I can learn what works and what doesn't.

The next game is the most ambituous by far. Unlike the previous three, this game features saving and will take a few hours to complete. I hope to work with George Emond on it again, since his artwork on Fusion was amazing. But I will hold back on details for now, since it is still in the development phase.

In the meantime - here is the installer for Tetris and Pong.