Jul 27

This blog is about Silverlight game development, but if you’re writing managed code for your Silverlight game, why not explore some of the other options available to you as well to get maximum exposure for your game and hopefully make some money as well?

 

XNA Game Studio and Xbox Live Independent Games

XNA Game Studio allows you to create games for Windows, Xbox, and Zune. You write your games in C# and you can write 2D or 3D games (2D only on Zune right now). XNA doesn’t have a vector graphics library built in, so if you want to make your games more portable, stick to image based graphics.

 

Xbox Live Independent Games is a way for you to sell your game on Xbox. Anyone can do it, you just need to pay $99 a year for a premium subscription.

 

As a bit of a shameless plug, I currently have a game on Xbox called Dr. Popper, it’s a simple bubble breaker game but it’s fun even the kids enjoy it. You can download a free trial here (or buy it for a dollar):

 

http://marketplace.xbox.com/en-US/games/media/66acd000-77fe-1000-9115-d80258550147/

 

You make 70% of every sale and now games can be sold in more countries including USA, Canada, UK, Singapore, Germany, Italy, Spain, France, Japan, and Sweden. There are restrictions on the countries that can submit games as well right now, so please view the details before shelling out the $99. With this subscription you also get to playtest and peer review other people’s games for the Independent Games channel.

 

There are some great game development resources available on http://creators.xna.com and even if you don’t end up creating a game in XNA, it can be helpful to get an understanding of how they structure their game class. It may give you some ideas for how to structure things in Silverlight, a lot of my game tutorials came from implementing what they do in a Silverlight way.

 

You can now write 2D games for both XNA and Silverlight using my free SilverSprite library at http://silversprite.codeplex.com. To use it, you would have to write your game in the XNA style and then recompile for Siverlight using the SilverSprite library.

 

Windows Mobile Marketplace

Windows Mobile has a new marketplace coming up for 6.x phones. Think iPhone app store for Windows Mobile and it’s probably pretty close. This is just getting started so instead of jumping into a saturated market like iPhone, why don’t you become an early adopter here?

 

http://developer.windowsmobile.com/Marketplace.aspx

 

Silver Arcade

For Silverlight games, you can get more exposure for your game and hopefully make some money at http://silverarcade.com as the volume of users on the site increases. I’m one of the founders of Silver Arcade, and my partners on the site are extremely talented and we’ll be providing helpful libraries for Silverlight game developers soon.

Jul 15

The WriteableBitmap is one of the most interesting new features in Silverlight 3, especially for game development. I’m looking forward to the first pixel perfect collision game using this technology, one of my favorites was the classic Lemmings game. 

 

The Pixels array contains one integer for every pixel, and you can find the correct array element by indexing row * width + col like this:

 

WriteableBitmap bm = new WriteableBitmap(width, height);
bm.Pixels[row * bm.PixelWidth + col] = value;

 

Personally I would have liked to have seen the Pixels array be made up of unsigned integers, since all bits are used and it would have made using hex values easier. The bytes in the 4 byte integer value correspond to alpha, red, green, and blue respectively. So pretty straightforward, a SetPixel method should look like this:

 

void SetPixel(WriteableBitmap bm, int row, int col, byte alpha,
    byte r, byte g, byte b)

{
    int idx = row * bm.PixelWidth + col;
    bm.Pixels[idx] = (alpha << 24) | (r << 16) | (g << 8) | b;
}

Unfortunately there is a problem with this. This would be fine for ARGB32 format, but what the Pixels array uses is Premultiplied ARGB32. This means that if you specify an alpha value other than 255 (fully opaque), the other 3 values (red, green, and blue) need to be scaled based on the alpha value. A fixed version could look something like this:

 

void SetPixel(WriteableBitmap bm, int row, int col, byte alpha,
    byte r, byte g, byte b)
{
    int idx = row * bm.PixelWidth + col;
    byte r1 = (byte)(r * (alpha / 255d));
    byte g1 = (byte)(g * (alpha / 255d));
    byte b1 = (byte)(b * (alpha / 255d));
    bm.Pixels[idx] = (alpha << 24) | (r1 << 16) | (g1 << 8) | b1;
}

I assume that this format is more easily consumable for display. I spent a few hours figuring this out so hopefully you won’t have to struggle with it.

Jul 15

Pardon the pun, but Behaviors in Silverlight 3 have made me rethink game development in Silverlight and if you’re not looking at Behaviors you should be. I’ll be updating my old game tutorial posts building an asteroids game to use behaviors and I’ll provide full source so that you’ll be able to easily use these Behaviors in your own games.

 

I recommend you look at this video that convinced me this is the way to go:

 

http://www.microsoft.com/video/en/us/details/f8a1c6a2-0fc4-474e-8e7f-c66fc7e7952a

 

As a consequence of this, I’m going to leave my old blog for posterity at http://www.bluerosegames.com/silverlight-games-101 and everything here will be new material.

preload preload preload