Sweepy Cleaner – Windows Phone

I thought I’d finally get around to making a post on my blog and specifically concerning the thing that has taken up the majority of my time over the past week or so. Sweepy Cleaner!

This is a coursework project we had been assigned as part of the the Hull University Computer Science degree. We were given a spec and tasked with making a game plus extras via C# and XNA 4.0.

I decided I wanted to make as polished a game as I could that stuck pretty tightly to the design specification, but still add a decent amount of extras here and there. In the end I’m pleased with the finished product and really enjoyed making the game.

The toughest aspect of the project was the AI path-finding that I wanted to put in the game so that  in “attract mode” it guided itself around the furniture and collected dust of it’s own accord. This sounds simple but in reality it was the trickiest bit of programming I’ve probably done and let’s just say I won’t be bitching about dodgy path-finding in AAA games any time soon. I may actually make a separate post on this and include a dissection of the code I came up with.  I decided to initially look into an A* algorithm but I wasn’t sure how best to apply that to a game where things don’t move along a grid. So I decided to use static waypoint nodes that I manually placed around the level and then added them to a list, sorting them based on distance from each waypoint to the nearest dust to the hoover. I spent a long time trying to perfect it and although still not perfect, (I had to use at least one workaround) it performs convincingly enough with no furniture collisions and I’m very happy with it. I could later adapt it to make a “vs” mode where you have to race the AI hoover to collect the dust.

There’s only 3 levels in the game, I’ll hopefully add more before I get it on the Windows Marketplace.

Fingers crossed that my demo goes ok next Wednesday!

Here’s the artwork I did for the title screen, it does makes me think a 3D version of Sweepy Cleaner could be pretty fun!

C# / XNA: Passing Class instances (objects)

So, not being an expert I was trying to find improved ways of managing external class member access  without resorting to “public static” and ideally wanted an object orientated method, a while ago we were told by Rob Miles how classes or specifically instances of classes (objects) are passed by reference. I understood this however I didn’t really join the dots together for one useful implication it has::

Passing objects as parameters allows the receiving Method and potentially it’s Class, access to the objects members directly. (since its a memory reference to that object, not a copy).

It maybe obvious to some but ultimately,  it means you don’t need to keep feeding objects in as parameters for update methods to show changes, you can just do it once and store it there as a class member. The objects members will all be directly accessible from within that class, even if they are changed elsewhere in your program/game.

I think the thing that didn’t make this obvious to me is the fact that if you pass a class instance member variable instead of the instance itself, this behaviour doesn’t work, you just end up with a copy of the member variable at the point of being passed, but that’s because it’s been passed by value, not reference. Additionally, I found myself repeatedly passing object instances into Update methods, which worked but simply wasn’t needed since a ref could just be passed once and stored for the class. In the context of “Sweepy Cleaner” our Uni course work project, the below highly contrived examples highlight what I mean:

Pass by value Example:

Pass by Reference Example:

The other obvious good thing about passing the class instances instead of specific member variables is that you can of course access all members of that class instead of just the ones you pass. Additionally, it gets around the need to use public static for easy but rather lazy access of class members from outside the class, because only the classes you pass the instance to will be able to access it’s public members, and if you combine with “accessor”/”getter” methods I guess they don’t even need to be public.

(I’ve heard bad things about getter/setters too because it goes against the object orientated nature of C# apparently, but I’m not too bothered about that at this stage).

Anyway, you can of course still pass individual members via the “ref” keyword in the parameter and arguments to achieve the same thing as above but just for a member. I personally think for XNA passing the instance just seems a sound way of doing things. I’m not sure if there are repercussions to doing it like that, but so far it seems sound and hope this may help others who also hadn’t realised its usefulness.

Shear Carnage

So, it all started with an idea based off that gem of a game “Missle Command” (pictured above – and whom most who read this are likely too young to have played) and spiralled uncontrollably into what became a potent concoction of sheep gibbs, explosions and of course laser beams…what else? My one regret is that we didn’t get around to combining that into the direct form of “laser beam firing sheep gibbs that explode”, but I digress.

The Three Thing Game competition is something held by Hull University every 6 months and  is based on teams being given 3 random words and then developing a game about these words within 24 hours (We did have a few days between getting the words to plan and prepare however). Our team “Run Dead Studios” received the words Sheep, Fireworks and High Diving. My good friends and team mates Russ and John have covered all the detail on this marvellously so I won’t cover old ground but do check out their blogs! (You both now owe me a blog plug).

The day was great fun and my first experience of working so closely as a developer on a games (or any software for that matter) project. This itself would have been great enough reward however to actually come second place out of 33 teams and over 100 people, was truly a wonderful thing. We were beaten rather predictable by “The Infamous Two Sirs” who live up to their name I can tell you. They had an excellent game that won hands down in terms of innovation, and though its mechanics are quite hard to explain, rest assured it was good. Next time, I think we’ll go for something more innovative ourselves, now that our confidence has peaked a little. There was certainly an element of playing it safe from us, but like Rob Miles has said on his blog, its much better to make a full game that’s simple,  then a complex one that’s basically just a tech demo.

    

Details wise, we developed it on for the Windows 7 platform using XNA in C#. I’ve got to say I think XNA is a great development library and with the help of Visual Studio and Tortoise/Subversion SVN for source code management, it was pretty much a care free development experience.

I’m incredibly proud of what we achieved, especially considering we are first years and the game is simply great even if I do say so…we certainly had plenty of fun playing it on the day, in fact it was so addictive it may have gotten in the way of us actually trying to get it finished which I think is a good sign.

On behalf of Run Dead Studios, I present Shear Carnage! Coming to a Windows Phone App Marketplace soon, free of course. No Sheep were harmed in the making of this game, however if the sight of cartoon sheep dismemberment is shocking to you, I STRONGLY do not recommend you play this game :D.

Just to add, you can find the video of us presenting the game to the judges (Well, the first presentation anyway) below: