DiamondDash - Boulderdash Clone in VB 2005 (Revised, yet again)

As Lutz Roeder describes it, a “.NET version of an old East German Boulderdash game”. Using the source that he put together to build from, this version is initially a port to Microsoft Visual Basic 2005 and contains new graphics done by yours truly. In addition to a simple port, I’ve taken advantage of using Partial Classes to organize the code, utilize the new resource manager for images, icons and level loading and enhanced the code utilizing several other VB 2005 features.

The source isn’t overly huge, so to further quote Lutz (with a bit of paraphrasing ;-) ), it “might be a good example for VB and Windows Forms starters. The goal is to collect a given number of diamonds and exit the level without getting hit by stones or ghosts. The status line tells you the level, number of lives, diamonds you collected and how many you need to collect.”


As a side note regarding my previous entry, although Partial Classes are intended for use by designer generated code, this application utilizes Partial Classes extensively to organize the internal classes for the “game” which is organized in a way that it’s a custom control. Under the GameWindow folder you’ll find several individual class files; all of which combine to form the total of the GameWindow control. Instead of (as in Lutz’s pre-2005 example) having all of these internal classes in one huge file, Partial Classes allows for, as I’ve already stated, a cleaner organization allowing myself (or any other developer) an easier method to maintain and extend the functionality of the control.

REVISED: I couldn’t leave well enough alone. After releasing this, I revisited the drawing code since it was bugging me that Lutz’s version had extremely limited scaling and it wasn’t exposed through the client (had to modify a variable). I figured I’d attempt to make it truly scale and see if I could get the performance to a point where it was acceptable. As you can see from the composite image below, Dash.exe is running at about 3% (on my machine between 0-3%) in “idle” mode and the original download version (a .NET 1.x executable mind you) clocking in at around 34% (29-50%). Notice that my version is obviously using a bit more memory because of the technique that I’m using… which essentially is my own version of double buffering in addition to the Windows Forms double buffering. By drawing all of the items to a memory based image, I can scale it to whatever size I wish utilizing System.Drawing. As for actually drawing to the screen, it does still utilize region based invalidation; meaning only areas of the screen that are truly invalidate are actually drawn (instead of just pasting the whole memory based bitmap to the screen every refresh). I think I can accept a bit more memory for the enhanced functionality and reduced CPU utilization. ;-)


REVISED: (yet again) - You know, a game just isn’t a game unless it’s making some sort of noise. Without all of the blips, beeps and other assorted noises, something just seems to be missing. I first attempted to utilize the “built in” audio playback contained within the .NET 2.0 Framework and the enhanced version contained with the My functionality within VB; however, it didn’t appear to give me the results I was looking for… causing some serious sluggishness to occur even using the async playback methods. So to step outside of the base framework, I decided to utilize the DirectSound API’s from DirectX. Since there are Managed Wrappers for DirectX, I figured this would be a safe route to go. If you have problems getting the project to work, I think you’ll need to either install the Managed Wrappers yourself or make sure you have DirectX 9.0c or greater as I think it installs the wrappers automatically (as I haven’t taken any extra effort to install them and they exist on a relatively newly purchased machine.)

(Also, if you do prefer Lutz’s original artwork, just replace the .png file within the resources with that which is included in his original project.)

  • [ download - Revised/Using DirectSound ]
  • [ download - Revised/Enhanced version ]
  • [ download - Older version (for archive/comparison purposes) ]


This post is licensed under CC BY 4.0 by the author.