Santa's Pirate Drinking Game
It's December, which means it's officially nearly Christmas. If you wanna do your Christmas shopping online, you should really have done it by now to be sure everything will come on time.
This project was built as an experiment to see what happened if I started coding with no other aim than "Build something Christmassy from Creative Commons art.
I ended up with a web game in which Santa's bar is invaded by a bunch of pirates and Santa has to run around keeping them happy by plying them with Rum so they don't get too rowdy.You can play it here: http://dalliance.net/xmas2011/I started by looking through the creative commons licensed pictures on Flickr, looking for things with a Christmas theme. I found this picture of santa:
I decided to turn that into a sprite and make the sprite run around the screen. So I chopped off his arms and legs, separated them out into different images, and loaded 'em into Flash, building a sprite that could walk around and jump.
He looked lovely, so I loaded him into Blender to see what I could make him do. He didn't have any bones to make it easy to move him around, and since my blender skills are basic at best I thought it would be a good opportunity to try and learn to put those bones in him.I did it fairly poorly, inexpertly, and certainly without using most of the features which Blender supplies. However, it was eventually good enough to allow me to pose the little pirate and have him do more or less whatever I wanted.So I sat him at a table sourced from the same opengameart.org site, gave him a bottle of beer and imported that into the game.Of course it was horrible. The pirate was 3d, the Santa was 2d. I rigged a fake isometric transform into the position of the objects so they at least existed in a pseudo-3D environment. Then I had a bunch of pirates sitting around which Santa could move between. But I was no longer happy with the Santa at all.So I decided to see if I could replace the Santa character and found this great little blender character: http://www.blendswap.com/3D-models/characters/santa-clause/
He was funny, and already had bones to make him easier to move. Even change his facial expressions. I animated him to walk around and throw bottles.
He was too squat for my pirates, it turned out, but just tweaking the _yscale variable in flash dealt with that easily enough.
Collision detection is a pain. Especially in a hurry. Banning Santa from walking into those tables in a pseudo-3D map was a fairly tricky programming challenge. At least it was the first time I did something like that. These days I know you can fake it pretty easily by just moving the sprite to a point at the edge of the bounding circle. So I added that in, and faffed trying to remember the maths for a while until I resorted to getting a pen and paper out to do high-school trig problems. Never think these things aren't useful in life kids. Geometry is everywhere.Of course this wasn't enough in the end, when I started placing pirates in overlapping positions. Santa could creep into one table by walking around the edge of another. Not good. Last-minute repairs just freezes him when he's touching two tables. This seems to work well enough.
With a bit of code to make the pirates happiness change depending on when they had a bottle, drink when they were happy, and throw the bottle away when they emptied it, I finally I had some sort of a game going. Sound effects were, in general, easily done by quickly sampling things with my phone. Record a sound file, drop a bottle on the floor, clap my hands, band the desk. I used Audacity to chop them to size and save them as .wav for Flash to import. Breaking glass though wasn't something I wanted to do so I found a shatter noise someone else had already kindly uploaded: http://soundbible.com/105-Light-Bulb-Breaking.htmlStill seems a bit flat and lifeless though, what it needs was music! Now my band ( http://handsomejacks.co.uk/ ) were planning to play a gig at which we would play a Christmas song. I decided to film that song and project the video from it onto the wall in Santa's virtual bar. Santa was presenting a film to pirates! Pirates decide the success of films by deciding whether to bother copying them around or not. If they like the film, it could be a viral hit. Plot sorted.Then on the night of the gig, someone in the bar upstairs got into a serious fight and ended up (according to rumour) with broken glass pushed into his insides. Horrible. The police were called and the entire venue shut down (despite the downstairs bar where we were being fairly separate) just as we were about to strike the opening chords on the first song of our set.Damn. No chance of using that video then.So I searched Jamanendo for some christmassy music, finding just two albums there which seemed suitible. Both great, one even funny:J.E.L.L.i (here: http://www.jamendo.com/en/album/56441 ) is hilarious and Anthony Viscounte (here: http://www.jamendo.com/en/album/81276 ) is swingy and fun.
Now it was time to build the bar to host this all in. I searched Flickr again for some pictures of bars and found this one:
which seemed to fit the bill. Flat-on texture of a bar which I could take segments from to use as textures to build something in Blender.
Finally, all was in place so I uploaded to GitHub and released the game.https://github.com/revpriest/Jack-s-Xmas-GameI think the experiment was a success. I learned more about Blender than I previously knew, found repositories of creative commons artwork which I didn't know existed, discovered probably my favourite version of "12 days of xmas" ever, and produced a game which is mildly entertaining for long enough to listen to a song.It's called "Jack's Xmas Game" in github coz it was going to be featuring a band video when I first uploaded. That didn't work out but we're playing a gig again this week, and I will attempt to record that one and stick the new video into the game rather than just having a Christmas poster and some music. Look out for a special edition next week sometime.Now you may play the game
