Silverlight Game Programming for Total N00bs

Friday, 01 August 2008
  • By
  • Jeff Ammons
  • Tags:
  • Game Development
  • Pong
  • Programming
  • Silverlight
  • Sound Of One Hand Clapping


Silverlight is Microsoft's answer to Adobe's Flash, which has become wildly popular for casual game creation (Flash, not yet Silverlight).

If you are a .Net programmer who would like to try your hand at making a casual game, then you are in luck! Silverlight is your ticket to ride.


OK, what is a “casual game”? Are there “formal games” where you have to wear a tux? Maybe on Linux, but not on Windows! You see, Linux has this mascot… and he's called… oh never mind.

Casual games are a category of games that are geared towards an audience other than “hardcore” gamers. In other words, games made for the mainstream player who has a few minutes to kill rather than hours/days/weeks/months (or in the case of something like World Of Warcraft, years).

Games like Halo, World Of Warcraft, etc. are considered Triple A games. These are games that push the boundaries of technology and are made by huge teams of programmers, artists, designers, caterers, marketers, haberdashers, etc., etc. Literally hundreds of people are involved and the budgets are enormous. If you are reading this blog, I'm guessing you aren't going to be making those games…


To jumpstart your learning process, I have written what has to be one of the simplest games ever. My goal was to make code you could get your head around in just a few minutes and then grow from there.

Introducing: PracticePong.

PracticePong is Pong… SIMPLIFIED. But, wait! Isn't Pong already pretty darned simple? Yes, for an actual game. What I'm making is a Practice Game, that doesn't try to be fun, but rather show you the parts needed to make a game without ANY extra stuff to confuse you.

So in PracticePong you only get one paddle. The Evil Computer gets none.

If the ball hits the left wall, you get a point. If it hits the right wall, the Evil Computer gets a point.

When you move the mouse up and down, the paddle follows.

When you click the mouse button, the ball launches. Even if it is already in play. Remember, this isn't really a game… just a tutorial.

There are horrible, horrible sound effects and graphics. But, the point is, there aren't many of them.


Here is a link to a ZIP file that contains the Visual Studio 2008 project. You will have to install the Silverlight tools before you can load it, however.

There are basically 3 xaml files (page, ball, and paddle) that represent very simple objects that will be on screen.

All the code is in page.xaml.cs and is pretty much a tutorial in and of itself.

There is also a website to host the page where the Silverlight lives.


Thanks to several people who helped get me rolling on the right path.

First is Keith Rome. He spoke at our GGMUG meeting back in June and did a very good tutorial on getting started with Silverlight game programming.

Next is Bill Reiss over at Silverlight Games 101 for his tutorial series.

[NOTE: The link that was above is now a dead link.]

Then there is Andy Beaulieu who made the outstanding Destroy All Invadersgame. I learned a lot from his source.

Hope you enjoy PracticePong and go out there and make some fun games!