The Rewrite of GFX Solitaire

14 10 2010

The rewrite project started when I began the work on a Hearts game that uses the Solitaire code. I began working on the design for the new game, and realized soon enough that I’m gonna have to write the new game from zero, because I couldn’t find any re-usable code from the previous game!

Let’s be honest, GFX Solitaire was written so fast, that I didn’t notice how messy the code was! I was just rushing it out, and trying to finish it before my exams. My goal was to write my first game in XNA as fast as I could. The result was a messy code, with almost no classes whatsoever! The whole game was written in a single class file, and it was written in a way that could only be used for Solitaire and no other card game. And, the obvious problem was that the code didn’t allow for much future improvements to the game, leading to huge difficulties when trying to update some parts of it.

So I had 2 options: Either start the new game from scratch with an OOP design, or re-write Solitaire with a new Object Oriented code, and reuse it to write the new game. The latter option was the best in my opinion, because I wanted to keep the Solitaire in my development queue, and be able to release new versions and update it when necessary, and more importantly, I wanted to keep the game in my professional portfolio as a fully developed game with a clear design, and reusable elements.

So, I started the re-writing of Solitaire about 10 days ago. My goal this time was to write the game in OOP style. I wanted the code to be organized and usable. And now it’s almost complete. I had some problems trying to get a clear view of the classes needed for this particular game with a focus on re-usability for future card games which obviously share the same elements (card, deck, hand, etc…). One more thing I was thinking of was clear separation of functions between the game elements (classes), and it was tough to decide how to do that, because OOP in games is actually a bit different from other kinds of software: in games there’s a game loop, which obviously needs to access each and every sprite drawn on the screen. Also, games are not event driven applications, so you’ll need to write and handle your own events, which could get a bit tricky as it turned when designing the mouse interface.

Anyway, I reached a decision to stop looking for a perfect design, and work instead towards writing a working OOP design which could be used for other card games. And I was able to get some really impressive results, considering that this is my first time tackling this challenge! I was impressed with the code, which actually led to improvements of the original Solitaire with additional animations, and more control over the cards on the table.

So, I’m happy to announce a new version of GFX Solitaire, based on the new code with some more features and tweaks. The new version is now in final beta, and will be released when I finish ironing things and squashing some bugs. This time I will release it to major freeware sites in order to get more spread and more feedback. I hope people will like what I did.

After releasing GFX Solitaire, I’m planning to start the work on GFX Hearts, as it brings some more design and coding challenges (with my first AI implementation ever), and it should be quickly out of the way now that I can use some elements from Solitaire. So, if you’re interested in the project stay tuned for the final release, and some more posts on game design challenges.