Page view counter

Silverlight Tips of the Day - Blog by Mike Snow

Game Programming with Silverlight

Silverlight Tip of the Day #3: Silverlight Game Support, Limitations and Workarounds

While exploring techniques for game programming with Silverlight I came across some hurdles and discovered some workarounds. I plan to use this blog to track these issues for the purposing of hopefully saving you time from having to do similar research. In addition, I have added a Game Resources section where I will be putting links to other game tutorials for Silverlight.

If you discover any more, please send them my way and I will post them! Thank you.

Game Resources

What Silverlight Supports

  • JPG and PNG file formats.
  • Transparency through PNG files.
  • Keyboard and mouse input
  • Sound
  • Game UI layout through Grid elements.
  • Timers (animating, game loop, etc.)
  • Texture blending through Opacity.
  • Socket/TCP programming for multi-player networking support
  • Events (clicking, etc.)
  • Animation - WPF model that uses timers instead of frames.
  • Great debugging support through Visual Studio.

What Silverlight Currently Does Not Support

  • GIF or BMP file formats.

Work around: Use PNG (or JPG) files.

  • Creating images from subsets of larger images.

Work around: You have two options:

  1. Set a clipping region for the image such that you only show the part of the image you want displayed.
  2. Put each image in its own file. Unfortunately, for such work as animated sprites, this means a lot of individual files. Hard to manage.
  • Saving files locally - Due to security concerns, Silverlight 2.0 does not support saving. There is talk to support the SaveFileDialog in the future and I will track this progress closely letting you know what I learn. I need this feature myself (for my map editor)!

Work around: Save to a web server. See Michael Sync's blog here: http://michaelsync.net/category/silverlight under "Uploading with Silveright 2 Beta 1 and WCF"

  • Floating point values for positioning - if you tile images together to form a map, them scroll the map's X and Y position by a decimal value, you will see lines forming between the tiles.

Work around: Use rounded values.

  • Per pixel bitmap editing, bitmap filters (color matrix, etc) and effects (blur, glow, etc).

Work around: Through opacity you can do some pretty cool effects such as texture blending to smoothly blend transitions between map tiles. See this tutorial for an example.

  • 3D rendering – Silverlight 2 does not have any 3D support. However, seen Tip of the Day #71 on Silverlight 3. You will be happy to see that 3D is in the plans.

Work around: There are engines and demos out there that simulate 3D that work fairly well. Examples”

  1. http://www.markdawson.org/kit3d/
  2. http://www.codeplex.com/Balder
  • Sharing of resources is not allowed. For example, sharing a SolidColorBrush between rectangles. If you have 1000 rectangles, they will all need a separate brush for each rectangle.
  • Alignment for text in Textboxes.

Work around: You will have to programmatically center it.

Thank you,
--Mike Snow

 Subscribe in a reader

Comments

toec said:

You can save files locally by using IsolatedStore.  

# March 31, 2008 6:01 PM

mike.snow said:

I don't think the user can get access to these files though. It's just temporary hidden storage that your program can use during runtime.

# March 31, 2008 6:05 PM

toec said:

If you need the users to access the files from outside your SL app, then Iso wouldn't be ideal.  It is persistant across sessions, though, so if you just need a "save game" function, it might be worth a look.

# March 31, 2008 7:45 PM

Dew Drop - April 1, 2008 | Alvin Ashcraft's Morning Dew said:

Pingback from  Dew Drop - April 1, 2008 | Alvin Ashcraft's Morning Dew

# April 1, 2008 8:15 AM

Sopheap Ly said:

Great post! I was wondering if the 'per-pixel bitmap editing' will be introduced or not.

# April 1, 2008 9:12 AM

mike.snow said:

Not anytime soon, but I am certain it will be supported when 3D comes online. I will look into some dates and report back if I find anything.

# April 1, 2008 11:43 AM

Bionic said:

Thanks Mike for your work - this will saving me a lot of time.

At the moment i'm working with three friends of mine on a TowerDefense Game in Silverlight. Your blog is a grat resource for us, thx :-)

# April 1, 2008 12:50 PM

mike.snow said:

Can't wait to see it, let me know when it's posted to preview!

# April 1, 2008 7:21 PM

Bionic said:

I'll give you a shout ;-)

# April 2, 2008 3:05 PM

straylight said:

OMG Bionic!  I also happen to be working on a desktop tower defense game in Silverlight.  Started in SL 1.1 and now 2.0.  We'll have to have a friendly little "code off" :)

# April 3, 2008 8:08 PM

14 Silverlight Tips | DavideZordan.net said:

Pingback from  14 Silverlight Tips | DavideZordan.net

# July 2, 2008 4:33 AM

Silverlight - Tip of the Day by Mike Snow at Blog von J??rgen Ebner said:

Pingback from  Silverlight - Tip of the Day by Mike Snow at Blog von J??rgen Ebner

# July 28, 2008 7:06 AM

Silverlight Tips of the Day - Blog by Mike Snow said:

The purpose of this post is to create an outline summary all the blogs from my Silverlight tips of the

# January 2, 2009 5:57 PM

o UAU nosso de cada dia said:

essa lista eu copiei desse blog bárbaro (acompanhe por RSS você também): uma lista de dicas super úteis

# January 3, 2009 6:25 AM

lepkifke said:

Check out my tower defense game :

www.lepeli.com

The Blog realy helped.

# March 7, 2009 5:51 PM

taylorza said:

<quote>

What Silverlight Currently Does Not Support

•Creating images from subsets of larger images.

</quote>

Obviously this was for Silerlight 2, now with Silverlight 3 we have WriteableBitmap which can be used to achieve this. As part of my own learning experience I have written something to support this.

taylorza.blogspot.com/.../silverlight-spritesheet-management-with.html

# August 22, 2009 10:12 AM