XNAWP7-1 A introduction

Hello ,

I’ve been thinking about what should be my next post. I’d like to talk about WCF RIA, where I have had some encounters, but it’s like too soon to write about it. On the other hand, I won a raffle and the prize was a book about Windows Phone 7 Game Development (Thanks to 101FreeTechbook and additionally there is going to be a free workshop about XNA 4.0 development at gamedevelopedia (Starting at 17-Jan-2010). Thus, I’ve decided to write a set of tutorials about XNA and WP7 for those who wants to start as well as I want. If everything goes well the series will have the following tag XNAWP7, and I’ll try to post every week about the every new topic. So, lets get started.

WP7: Windows Phone 7 Development
Windows Phone 7‘s the platform Microsoft has release to create new experiences on Windows Phone development. This new platform is based on managed code, so it’s backed on .NET Compact Framework. At this time it’s possible to write application C#. There are two main framework available for WP7 development:

XNA: Xna is Not an Acronym
XNA is a high-performance game framework. It’s over DirectX and it allows to create application taking advantage of high performance on Graphics, sounds, networking and input devices. Additionally, it can take advantage of Microsoft Live to have a customized game experience. The only drawback of this platform is that you have to create most of the components almost from scratch or get a third party framework instead.

SL: Silverlight
Silverlight is framework build on .NET and it allows to create rich interactive applications by using a declarative language (XAML). Xaml uses XML to describe how the UI is drawn, and the C# to details on logic and interaction. This framework also supports game development, this framework is fairly enough for games which does not have high-performance graphics nor have tons of elements. Event though, SL4 is already in the market and SL5 is on feature request on Jan-2011, WP7 uses an special flavor of Silverlight 3. This special flavor of SL3 has removed not related feature of mobile such as System.Window.Browse namespace, and it has added specific new namespaces in order to take advantage of the platform specific items.

Windows Phone 7 and its hardware
Microsoft has defined very specific hardware in order to be able to run properly WP7 Operative System (WP7 OS).

  • 1 Ghz CPU processor
  • WVGA (480×800) or HVGA (480,320)
  • Accelerometer sensor. This sensor helps to detect the orientation of the device, this means it allows to detect if the device is point up, down, left right, etc..
  • GPS sensor This sensor helps to detect the position around the world by detecting the latitude and longitude

Development on WP7
At lats but not least, let see what it’s required to develop on WP7 platform. The SDK is free and it can be downloaded at AppHub If you have Visual Studio already installed the WP7 tools will integrate with VS automatically. If you don’t have Visual Studio, then you can get the Visual Studio Express version for free at Visual Studio Express.
If you wan to run you application in you phone, then you’ll need to get a XNA creators account to being able to deploy your application into your phone. Additionally by acquiring an account you’ll be able to publish your game in the Market place, at this time (Jan-2011) only US and Europe are available to publish content, it’s planned to open more countries during the next years.
Don’t get worried if you don’t have a Windows Phone 7, you can start coding using the emulator which is already included with WP7 SDK, however it’s strongly recommended to use a physical WP7 to perform final tests.

An initial application
As traditional, the hello world application. So, on this little sample you it’s possible to appreciate the basis to display text and sprites.

The Main Game loop
If haven’t worked with game frameworks before, let me point out a concept known as game loop. Traditional programing models are event based, this means that a certain functionality is executed by a given trigger. But the most common video game frameworks does not work on this scheme, instead they use the game loop which is a “infinite” cycle where the application performs an update and then draw the scene. Frameworks such as XNA have methods invoked before and after the game loop is executed to perform initialization tasks, or free resources. This main loop game is implemented by the Game class of XNA. BTW there is a particularity of using XNA on WP7. Normally an application has an entry point such as the main function, and you can clearly see this function on a WP7 template project. However WP7 loads looks for instances of Game in your projects and handles them such a contract to define the execution of your application.

A sprite
The word sprite is an term which hasn’t changed from its origin. During the age of 8-bits the very first images that were drawn on a screen were called sprites. So, an sprite a two dimensional rendered figure ;-). Sprites have become a great resource because much of the game frameworks does not have a graphic interface library (GUI), thus sprites provides a good-alternative mechanism. On XNA an sprite is represented by the Texture2D class.

Sprite font
Particularly XNA has decide to draw text by using sprites. Which means that all the charset is backed by images. A font on XNA is associated to an spritefont. On XNA an sprite is represented by the SpriteFont class.

Drawing sprites
XNA defines a tool for drawing sprites (or spritefonts). XNA helps you to deal with the resources of you application by providing a content loader. This content loader is able to load the sprites, fonts, audio files that you application will consume.

some csharp code
With all the previous things said I’m attaching what it would be the first post (hopefully of many more posts).

Source code is at http://github.com/hmadrigal/xnawp7

XNA 4.0 beta and Swf2Xna


I was reviewing a couple of feeds from and I found two very cool news. The first one is about the XNA 4.0 beta has been released, and it includes a new Touch API which detects gestures 😉

See some information at:


The second news I’ve found it’s about an open source project called Swf2XNA (quite amazing!), so you will be able to run Swf application (aka flash app) in you Xna platform (Xbox, Windows OS, Zune or Windows Mobile 7), … quite good! isn’t ?


That’s all for today!

Enjoy it

Windows Mobile 7 Silverlight or XNA?


You might be wondering why there are two programing models for Window Mobile 7. Well, it’s simple it’s because each model satisfy a different need.
The following link contains a table comparing general capabilities in both frameworks (XNA and Silverlight)