Windows Phone Developer Tools CTP First Impressions

Posted by

What I should have mentioned was XNA 4.0 was just a part of the download mentioned in the last post. It also allows the writing of Silverlight applications and under the Visual Studio 2010 Express Edition.

It’s been a while since I’ve used XNA in any form whatsoever, so coming into XNA 4.0 with a half-cocked memory of what was what and finding out a great deal of it “actually wasn’t” was something of an experience.

I decided to knock up a quick and dirty missile game, and the first thing that was obvious to me is that I’m almost as bad of an artist as I am a programmer hence what looks like a total lack of effort on my part 🙂

missilegame

The lack of orientation support for the Windows Phone 7 as of the moment is definitely an issue, meaning that you have to resort to various tricks to emulate this functionality. I look forward to that getting sorted out.

Visual Studio 2010 doesn’t seem too bad in all, although I wasn’t aware of a new feature that when you run your mouse over the left-column, it highlights the square chunk around the associated code.

Funny thing is, when you don’t realize this feature exists, just running the mouse past it darkens the block of code for a spit second, causing what seemed to me, like my monitor momentarily losing brightness and the ensuing dread of an RMA.

Drawing lines was a complete pain. Mixing the spritebatch and primitive drawing wasn’t a great idea, and also I wanted thick lines, which in XNA, isn’t really supported out of the box, so I opted for a rather hacky approach which seems okay.

private void DrawLine2(Color color, float x, float y, float length, float angle, int thickness)
{

	spriteBatch.Draw(
		texWhitePixel, 
		new Rectangle((int)x, (int)y, (int)length, thickness), 
		new Rectangle(0, 0, 1, 1),
		color, 
		MathHelper.ToRadians(360.0f - angle),
		Vector2.Zero,
		SpriteEffects.None,
		1);

}

For the record, here’s a snippet for creating blank textures:

public static Texture2D CreateTexture(GraphicsDevice graphics, int width, int height, Color color)
{

	Texture2D tex = new Texture2D(graphics, width, height);

	uint [] data = new uint[width * height];

	for (int y = 0; y < height; y++ )
	{

		for (int x = 0; x < width; x++)
		{

			data[(y * width) + x] = color.PackedValue;

		}

	}

	tex.SetData(data);

	return tex;

}

Hopefully I’ll make something a little more serious in time.

Terry Butler