Tuesday, January 15, 2008

Old habits die hard

What can I say? I spent a small amount of time over the weekend getting the core game code for the Ultimate Retro Project's Dots game core finished. I never, however, put the changes in the repository. I am use to finishing off my work before depositing it, which is a habit that I am going to have to work hard at breaking. That is why I posted the latest code to the repository today.

As the Ultimate Retro Project is already open source, it is not going to have a making of document created for the open source release, so what I am going to start doing is explaining what the code I am posting does as I post it. Don't worry. This is not going to be code dumps, but instead will focus on the theory and reasoning behind the code that I wrote. Of course I will also try and point out my kludges and the "temporary code just to get things running but will be replaced when I have time" code that will never get replaced.

Dots, of course, has a lot of existing code, which I will try and explain in future entries. Today's post was simply the code to determine if the game has been won and the code to find the score. It was fairly simple code to write as for dots, you simply need to take a look at every block within the bounds and see if it has been completed. If all the possible blocks have been completed then the game is finished. Getting the player's score is simply a matter of adding up all the blocks that belong to that player. This code is not that efficient, but for the games needs is more than fast enough. If I have time I will rework this code so that it is faster, but it has been a while since I touched the dots code so my goal was simply to get something done. The existing code is dependent on a knowledge of boolean math so I will be writing a boolean math nutshell column shortly then take a look at how I assembled the dots core.

No comments: