ailon's DevBlog: Development related stuff in my life

Weekend project: Open Source Silverlight Battleship Game

12/14/2009 2:58:47 PM

Ok, this took something like 2 weekends, but here it is – my Silverlight Battleship game.

Battleship - open source silverlight game

One interesting thing about this project was that I wanted it to support full screen mode and for that to work nicely I needed Viewbox control which is in WPF but not (yet) in official Silverlight distribution. But they have it in Silverlight Toolkit. But the thing is that I only needed Viewbox (which is a small and simple control) from the Toolkit and adding reference to the toolkit’s assembly added a couple of 300+ kb assemblies to my XAP. In result my simple game became a 300kb XAP and this wasn’t the size I was happy with.

Fortunately Silverlight Toolkit is open source (released under MsPL), so I took the sources, found 2 files responsible for the Viewbox, replaced a few constant references to hardcoded values and a couple of extension method calls to inline implementations (to avoid possible chain reference madness) and included that directly into my project. This way my XAP went from chubby (for a simple game) 300kb to a respectable 42k.

Another (non-technical) thing I’ve noticed while doing minor research for this project is that the Battleship we played in (soviet) school is different from the one children in the west (apparently) played. Our fleet consisted of one 4-cell ship, 2 – 3-cell ships, 3 – 2-cell ships and 4 – single-cell ships. The one described in Wikipedia had one 5-cell ship, 1 – 4-cell, 2 – 3 cell and 1 – 2 cell. So I decided to make everyone in the world (hopefully) feel at home and included an option to play with both types of fleets.

So, that’s about all I had to say about this game. Go play it and/or download the source, modify, etc. It’s released under MsPL license. Don’t forget to let me know if you make something cool out of it.

kick it on DotNetKicks.com Shout it

Tags:

Comments

12/14/2009 4:07:28 PM

Michael L Perry

Any plans for a two player option? Or arranging your own fleet? If not, I might just take a weekend or two myself to add them.

Thanks for the great sample.

Michael L Perry United States

12/14/2009 4:10:03 PM

ailon

No, I think this is it on this project for me. At least for the nearest future. Feel free to dig in Smile

ailon Lithuania

1/20/2010 11:10:45 PM

Jus Mate

WOW! I will try this.I agree with Michael, wud be great if you can make for two player in your next project

Jus Mate United States

1/26/2010 6:04:23 AM

Jacob

Yes! I always loved Battleship. Great idea man. Although 2 player would be awesome.

Jacob United States

3/12/2010 2:02:43 AM

Lucien Silberman

Browse to <a href=http://www.askcheats.com>askcheats</a> to find cheats.

Lucien Silberman Turkey

Add comment


(Will show your Gravatar icon)

  Country flag

biuquote
  • Comment
  • Preview
Loading



Copyright © 2003 - 2010 Alan Mendelevich
Powered by BlogEngine.NET 1.5.0.7