Ok, this took something like 2 weekends, but here it is – my Silverlight Battleship 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.