robburke.NET
© 2010 Robert Burke
All Rights Reserved.

Legend of the Greasepole Title Screen

Legend of the Greasepole has been ported to Silverlight 4 and reincarnated on http://greasepole.net.

Greasepole is the long-suffering game about multimedia tribute to the inexplicable Engineering traditions at Queen’s University in Canada. Over 50 students contributed to the project back in the day.

There’s a significant AI component to Greasepole – the autonomous “frosh” characters have models for learning and communicating with one another.

A couple of years ago I ported it from C++ to C# and XNA. I abstracted out a series of services (graphics, sound, input, timer, persistence) so that it might ultimately be ported again to a platform like, say, Silverlight or something. Why? I don’t know, maybe I’m a little obsessed with the illusion of preservation.

The Silverlight 2 version was a bit shaky. Silverlight 4′s hardware acceleration and bitmap caching make it pretty solid. It is also awesome to hear from friends that it apparently works on the Mac.

Analyze These… Shenanigans

I also added a little analytics. Although it should probably be said that the Greasepole event largely defies analysis, the game itself does not, and so this is the first time I can let someone poke their head in and see how the froshies are doing all around the world.

Back in the day, the worldwide best time was in excess of a mere 53 minutes. But I had to learn that by way of Sean Murray (class of ’05; wonder where he is now) sending me a screenshot. Now the interwebs will tell us immediately. (Admittedly, it’s not a fair fight against Sean, because the frosh are now permanently in “keener” mode, and the Options screen has been replaced by a dozen trendy Achievements for you to “unlock”).

So get going stalling those frosh, and my question for you is – what statistics would you like to see?

“Number of pints Al ‘Pop Boy’ Burchell has quaffed?”

“Number of hippos fed”?

“Height of human pyramid vs time”?

I am going to enjoy cooking up visualizations for some of those.

(Coding notes: A few new VS2010 things helped with this update: Web.config transformation (rocks), improvements to Web Publish functionality, XAML designer, Entity Framework experience… and more.)

Play Legend of the Greasepole Online Edition.

Roger from SilverlightAddict.com asked me for more information about how I manage the sound effects in the Silverlight version of Legend of the Greasepole.

I have a Canvas element in my scene called MusicCanvasRoot.  It contains a number of MediaElement children equal to the maximum number of simultaneous sounds that the game will play. This helper method allows my sound routines to find an unused MediaElement, and returns null if the maximum number of sounds is currently playing:

private static List<MediaElement> MediaElements = null;

private static int MaxSimultaneousSounds = 14;

private static MediaElement GetFreeMediaElement()

{

if (MediaElements == null)

{

MediaElements = new List<MediaElement>();

for (int i = 0; i < MaxSimultaneousSounds; i++)

{

MediaElement me = new MediaElement();

MediaElements.Add(me);

Page.Instance.MusicCanvasRoot.Children.Add(me);

}

}

foreach (MediaElement me in MediaElements)

{

if (me.Tag == null) return me;

}

return null;

}

When a sound is playing in a MediaElement, I set the Tag on the MediaElement to indicate whether or not the sound is looping.  Here’s the internal method that handles requests that come in to play a sound:

private void DoPlay(int volume, int pan, bool looping)

{

MediaElement mediaElement = GetFreeMediaElement();

if (mediaElement == null) return;

mediaElement.MediaEnded += me_MediaEnded;

mediaElement.Volume = Page.Instance.IsMuted ? 0d : 1d;

if (looping) mediaElement.Tag = “PLAYLOOP”; else mediaElement.Tag = “PLAYONCE”;

// …

// Assign a Uri to mediaElement.Source

//

// My sounds are stored as MP3 files stored as Resources in an

// Assembly that is downloaded after the app starts.

// …

// TODO: Set Volume and Pan in Silverlight.

// This allows me to implement IsPlaying for a particular sound effect

MyMediaElements.Add(mediaElement);

mediaElement.Position = TimeSpan.Zero;

mediaElement.Play();

}

And here’s the Event Handler for the MediaEnded event, which managing stopping sounds, or looping them when they complete:

void me_MediaEnded(object sender, RoutedEventArgs e)

{

MediaElement me = sender as MediaElement;

if (((string)me.Tag) == “PLAYLOOP”)

{

me.Position = TimeSpan.Zero;

me.Play();

return;

}

else

{

ReleaseMediaElement(me);

}

}

private void ReleaseMediaElement(MediaElement me)

{

me.MediaEnded -= me_MediaEnded;

me.Stop();

me.Tag = null; // free it up for use by another sound effect.

MyMediaElements.Remove(me);

}

The string-based Tags are a throwback to Silverlight 2 Beta 1, where the Tag exhibited some strange behavior that seems to be resolved in Beta 2.

Hope that helps. Let me know if you have any questions or want a full drop of the sound code.

By my reckoning, it’ll be next Saturday when Queen’s University frosh week will culminate this year for a new batch of fresh-faced Engineering students.  Surrounded by upper-years dyed purple with gentian violet, they’ll struggle to form a pyramid and climb a lanolin-covered pole to liberate a Scottish tam that’s been nailed to its top, and officially be declared a Year.

Ancient Greasepole photo

Back in ’99 I was part of a team that wrote Legend of the Greasepole, a game inspired by this most bizarre (and awesome, and memorable) of the Queen’s Engineering rituals.  Over 50 Queen’s students ended up involved, and in an era before ubiquitous digital recording equipment, we somehow managed to create a game that gave people a chance to re-live the unexplainable.

Anyway, if I may let a cat out of a bag, I am close to re-releasing the game in XNA.  I’ve ported it from C++ to C# (a task that involved exploring Visual Studio’s underbelly rather intimately), and added a couple of new features along the way.

Why would I do such a thing?  Fellow Sci ’99 Brendan Carroll (who happens to be part of the game’s voice talent) quipped on my Facebook stream “So when should we expect The Legend of the Greasepole to be released for the XBox 360?”  And I got to thinking, dude, that sounds like an awesome idea.  You know, if Clark Hall Pub is ever re-opened, maybe they could play it on the big screen like we did for the launch party back in ’98… but with wireless XBox controllers instead of a wired mouse!

So, since XNA is so accommodating, I figured I’d re-release the game fuelled by XNA for both the PC and the XBox 360.  And you thought I was faffing about travelling the globe or something.

I’m looking for a few beta testers who are running different flavours of Windows to give the game a whirl, give some feedback, and make sure it works on your systems.  I’m using some shader techniques that make me keen to test for compatibility as well as framerate.  I have put together an installer that seems to reliably install all the prerequisites, and even integrate into Vista’s Game Explorer if possible, so the process should be easy for anyone who wants to give it a try.

If you’re keen, drop me a line… oh, and by the way…

how high is the pole, frosh?!

The Legend of the Greasepole...

(postscript for the uninitiated: the InstallShield installer for the old 1999 version of Legend doesn’t seem to be working very well on Vista.  It spins its wheels for a very long time.  Give it a few days and I’ll post a new installer for the old version as well.)