robburke.NET
© 2010 Robert Burke
All Rights Reserved.

One of the reasons I’m pleased with the Silverlight version of Legend of the Greasepole is that it represents a reasonably-scaled multimedia application, and therefore a good way to learn about the Silverlight 2 runtime’s performance.

The Silverlight 2 Beta game engine runs rings around the game engine I tried to create using the Silverlight 2 Alpha. Yes, samples existed during the Alpha days that let you build a simple Silverlight game engine, but I didn’t see any applications that were successfully pushing push over 100 bitmap-animated sprites around the screen. I certainly was unsuccessful.
Although, as evidenced by the current build of Greasepole, the Silverlight 2 Beta situation is dramatically imrpoved, the lack of hardware acceleration is still very noticable when running at higher resolutions. This performance impact is relevant to an Image-oriented application like Legend of the Greasepole.

Can the game’s framerate be improved at high resolutions?

Late last year, I tried to make a version of the game run on the Silverlight 2 Alpha.
While the perf in the game’s menus was passable, the actual gameplay caused the Silverlight plugin to grind to a halt and crash (as 150+ sprites, rendered as Images with opacity blending, were presented simultaneously).

When updating my Silverlight game engine to the Silverlight 2 Beta, changes included:

  • using ZOrder instead of manually re-ordering Images in the Canvas’s Children collection between frames
  • moving bitmaps and sounds from loose, pre-downloaded files to Resources in Assemblies
  • an overall reduction in the number of RenderTransforms in the scene
  • avoiding setting of Width and Height as per Silverlight Performance Tips (in the MSDN docs)

At game time, performance is superb when running in a window of around the game’s native resolution of 640×480. But when the player toggles fullscreen mode (achieved in code by scaling the Canvas on which the 150+ Images are being drawn), it kinda sorta almost looks good. It definitely achieves less than the game’s desired 24 frames per second.

So… Is the Engine Fill-Rate Limited?

Since the game performs so well at reduced resolutions, I’m currently theorizing that the engine is fill-rate limited in Silverlight at high resolutions. That makes sense, because the Silverlight 2 Beta plug-ins for IE7 and Firefox2 aren’t hardware accelerated.

Still, the changes that took place in the plug-in and the engine that were enabled by the switch between Silverlight 2 Alpha and Beta have made dramatic improvements to the game’s performance. They were enough to bring the game to life.

I can’t resist linking to a superb article in the WPF Performance blog on finding memory leaks in WPF-based applications.

Particularly interesting is the section pertaining to Event Handler-based leaks. Here’s the brief summary, from the article:

In general, if you do this:

Foo.SomeEvent += new EventHandler(Bar.SomeMethod)

Then when you done using Bar, but you are still using Foo then Bar will still remain alive as well. Not what you might have expected.

Detatching the Event Handler from Foo.SomeEvent is not always practical. The proposed alternate is the “Weak Delegates” solution – a construct which isn’t natively supported by the CLR. A detailed discussion of how to simulate weak delegates is at Greg Schechter’s blog.

I got burned yesterday by not catching the need for the proverbial Weak Delegate, and I’ve been burned before by not using this technique when attaching event handlers in WPF (and particularly XNA and Managed DirectX) apps.

I’d classify both articles as “advanced,” and the solution as laborious, but if you want to write stable and long-running apps on the CLR (and who doesn’t? :) ), this issue is going to jump up and bite you in the proverbials at some point.

Congratulations to Sci ’11 for their one-hour, 47-minute conquering of this year’s greasepole!

Can we all just take a moment to reflect on the academic year called “Sci ’11″?  Man, I feel old all of a sudden.

Just for giggles, here’s the current list of achievements for Legend of the Greasepole.  I wonder how the crowd around this year’s greasepole would have done.

Pole in Ten (Years!) - (100) -  Stall the frosh for at least 10 minutes
Show Some Discipline - (10) – Proudly display the Discipline bar on your Engineering jacket.
Desperate Times, Desperate Measures - (10) – Wind up your arm fully, completely before you toss a road apple.
It’s The Jam, It’s All Good For You - (20) – Offer ‘za or a drink to the Engineering Society President.
You’re a Hoser - (20) – Cool down the frosh with water from the firehose.
Golden Soda - (50) – Offer a drink to hard-working Al ‘Pop Boy’ Burchell.
Like Homecoming, But With Lanolin - (50) – Quench the crowd’s thirst ’til they slam their leather jackets.
Dizzying Heights - (50) – Send a frosh flying all the way from tam to pit-water.
Iron Ring Ceremony – (100) – Unleash the power of the mighty Iron Ring.
Double Fisting - (150) – Wear two Iron Rings at the same time!
Exam Avoidance – (50) – Stall the frosh for five minutes without lobbing a physics ‘smart bomb’.
Fully Loaded Fun Fur - (70) – Stuff your pockets with 99 apples, 99 slices of ‘za, or 99 Clark mugs.
Secret Achievement - (??) – Keep stalling the frosh to discover this achievement!
Secret Achievement - (??) – Keep stalling the frosh to discover this achievement!
Secret Achievement - (??) – Keep stalling the frosh to discover this achievement!
Secret Achievement - (??) – Keep stalling the frosh to discover this achievement!

Just 2 days before her surname will no longer be correct in the credits of the game, here’s my sister Elizabeth, who designed the Frosh character, playing Legend of the Greasepole on the XBox360!

Elizabeth Burke playing Legend of the Greasepole on the XBox360

Legend of the Greasepole's TetherFroshI’ve posted Windows and XBox360 versions of Legend of the Greasepole 2007 to the Queen’s EngSoc website!

The new version is built with XNA and includes the following new features:

  • Controller support for either the mouse or the XBox360 Controller attached to the PC
  • 3D sound 
  • Modestly enhanced graphics (although we realized it was ultimately a choice between a total revamp or maintaining the “retro” look, and we opted for the nostalgic solution)
  • An installer that can detect and install all prerequisites, and integrate with Windows Vista’s Game Explorer
  • A new version that runs on the XBox360! (!!)
  • “Achievements” which can be unlocked by stalling the Frosh in creative ways.

The Windows version requires a graphics card capable of supporting Pixel Shader version 2.0.  Almost any computer bought within the last couple of years should do.  If your card doesn’t have this support, I’ve also left the Classic Version of Legend of the Greasepole available for download, with a new installer that runs more quickly and also can detect and install the needed prerequisite for Classic Edition (the DirectX runtime).

The XBox360 version is built with XNA and, as such, you currently require a subscription to the XNA Creators Club in order to play it.  If you want to get it up and running on your XBox360, please let me know!

Introducing Legend of the Greasepole Achievements!

For the uninitiated, retail XBox360 games each are gifted with 1,000 “achievement points,” which the game’s designers can divvy up and dish out to players when they accomplish tasks within the game.

Legend of the Greasepole is peppered with “easter eggs” and innovative ways to stall the Frosh that the curious can discover by messing about.  Previously, cleverness would get the crowd roaring and accelerate your earning an Iron Ring.  Adding a more formal Achievement system seemed like an ideal way to further reward a player’s experimentation and creativity, which in fairness is really what The Pole Game (and the actual greasepole, for that matter) is meant to be about.

Our design goal was to create an fun experience rather than a brutally challenging one, including as many references to the memorable traditions of Queen’s Engineering and the Greasepole event as we could possibly cram in.  Hopefully the Achievements will help you find some of them!

XNA doesn’t let you tap into the “official” achievement system, so I had to roll my own.  With thanks to Craig Calvert and McKay Savage, we’ve come up with a first set of achievements and allocated 900 of the 1,000 points. 

If you unlock all the current achievements, we definitely want to hear from you.  (Four of them are secret, the rest are visible from within the game’s main menu.)  If you have ideas for how we should allocate the remaining achievement points, we’d love to hear those too.

Please let me know how you get on with the game, and if you experience any technical difficulties, also please don’t hesitate to let me know, and I’ll do what I can to resolve them.

I have to tip my cap again to the dozens and dozens of Queen’s students who were involved in the game’s production from 1997 through 1999.  It was an enormous amount of fun making this game, and a wash of memories of the very best kind porting it to XNA for re-release.

Previous Articles »