[The Global] War On Terrier
I mentioned in the last series of posts that I'd written a small Silverlight game for an internal competition. Well, I'm finally able to put it online, here it is:
It's very similar to the old Worms games (which I love!), but much simpler. The reason I used puppies? Because my colleague suggested "War On Terrier" as a name, and while "Wombat Combat" was better, it's really tough to draw a cute cartoon wombat.
I think that programmers in general find it difficult to share their code with others because they rarely feel it's good enough, and we're a judgmental lot. I am no exception :) But here's the code anyway:
I know it's not great code, so here come the excuses: Zero up front planning went into it; it was written in 2-3 hour bursts over the course of a few weeks; it was my first Silverlight program.
Now that those are out of the way, let me point out what I found difficult in writing this game:
- XAML! My god, the amount of time I spent trying to figure out why my polyline didn't fit in the grid and how to scale it to fit and scale many polylines together and why the boundaries of the canvas were so big and why the transform origin was wonky and why things move when they shouldn't and why this won't wrap, and, and... Suffice to say, my XAML-fu is very weak.
- The game is turn based, but within a given turn it will also switch to being physics based and also Silverlight animation based. This forced me to write a big state machine for the game which complicated the code alot. Basically, I had to do things like this in many places: "If we're waiting for an animation to complete, then do nothing this frame."
- Learning how to use Silverlight user controls as my game objects, and how to structure the project around that. Do I load the XAML at runtime from a resource? Do I create actual user controls for each "image" in the game?
- XAML - did I mention that?
That having been said, it was alot of fun getting it to work. Here's what really needs to be added to the game:
- Network play. This would be way more fun if playing against other humans.
- Allowing the characters to be moved along the screen.
- More crazy weapons, different types.
- Bonuses, hazards, etc.
- Different scenes.
I hope the code is useful to someone, and that it doesn't lead you too far astray. Feel free to do whatever you want with it; if you have any doubts or questions as to why I did something, post a comment. I'll likely answer: "Because I wasn't thinking straight at the time" :)