Technorati Tags:

I have converted the first Silverlight game I had a go with to 1.1 Alpha Refresh

You can play it here: http://www.backofabeermat.co.uk/pong/testpage.html and download the source from here:  http://www.backofabeermat.co.uk/pong/pong.zip

The areas I was interested in exploring when creating this app were:

  • Interaction with the Silverlight control and the Html document - in both directions.  So in the game you can set the speed and turn sound on and off through Html Input elements and Silverlight updates the Html Elements if you use keyboard shortcuts.
  • Keyboard and mouse control - used to pause, set speed, and control your bat
  • Using Protected Storage - the app keeps your scores in protected storage between sessions and displays them using Html.  The reset link on these starts an animation in the Silverlight control - this was more of me playing with the interaction between Html and Silverlight.
  • Creating a "Game Loop" - this is done by adding an empty animation and restarting it on completion.  This will give you an event to work with for each frame (In this case the default 25fps)
  • Drag and Drop - for the bat and also for the "reset dialog" that is show when you reset the stats.

Few other things:

  • I used the new ExtensionMethods in .Net 3.5 to give any easy way of setting and getting the X and Y positions of Framework elements.  These are not exposed as simple propeties on shapes because they are DependencyProperties and require the use of GetValue and SetValue so my extension methods simply wrap these up to make things easier.
  • The collision detection is basic - sometimes the ball gets trapped in the bat - but I think I'll call that a feature!
  • I don't preload any assets so you will see a short delay as sounds get loaded first time.

Any way have fun - let me know if you have any questions...