MIX: Multi-screen gaming with Windows Phone Developer tools preview

image Using XNA Games Studio 3.x you could build a game that would run across Windows, Xbox and Zune. Now, unless you travelled to America or lived there you were unlikely to have a Zune or Zune HD. But now with Windows Phone 7 Series we have the promise of a device far more available for our mobile gaming.

With the release at Mix of the Windows Phone Developer Tools preview we now have XNA Games Studio 4.0 support in Visual Studio 2010 and the ability to build games for Windows, Xbox 360 and Windows Phone!

So lets look at moving the XNA 3.x Platformer starter kit to XNA 4.0 so we can run it on our Windows Phone emulator.

The easiest way to do this is to create a new Platformer game using the starter kit under XNA 3.x. Then to port it to XNA 4.0 in VS2010, you need to create a new XNA 4.0 game in VS2010 and then add to this the code and content files from your platformer XNA 3.x game.

With the Zune version of the platformer game you had to have special low resolution graphics, but with Windows Phone I was able to have a playable game using the same graphics assets as the Windows and Xbox versions! The Windows Phone resolution of 800 x 480 really makes a difference.

Having moved the code other there a only a small number of changes required to get the game running on Windows Phone. This is due to the changes in the XNA 4.0 API, some specific to Windows Phone support.

First I had to change the screen size and target frame rate code:

  1. private const int TargetFrameRate = 30;
  2. private const int BackBufferWidth = 480;
  3. private const int BackBufferHeight = 800;

Because the screen resolution had changed there are some hardcoded screen offset values in Level.cs file that need altering to fit the new screen dimensions:

  1. Vector2 screenOffset = new Vector2(0, -60);

A value of –60 worked for ok.

Then to access the file system where the text file level definitions are stored I had to change the code to use a TitleContainer instead of the StorageContainer:

  1. Stream fs = TitleContainer.OpenStream("Content/" + levelPath);

The final change for the default game was the ability to play the sound effects. When I added the sound files to the content project, the sound effects where loaded with a content processor of Song, not soundeffect. Once I’d corrected this, the game compiled and ran.

I ported my enhanced ZuneHD platformer game which made use of Nick Gravelyn’s ZuenLib to give me landscape orientation and touch screen support. I also use the accelerators in the ZuneHD to move the player from left to right (a touch of the screen causing jump).

In the Windows Phone Developer Tools preview the emulator doesn’t project a route to emulate accelerometers, although the touch screen should work if you have a touch screen pc with Windows 7!

To make the accelerometer code to compile I just had to change the references to include:

  1. using Microsoft.Devices.Sensors;

And then change the data type for the accelerometer data to AccelerometerReading. Not having a device yet I haven’t been able to test the code.

To make the touch screen functionality compile and work under mouse emulation in the emulator I just had to change the references to:

  1. using Microsoft.Xna.Framework.Input.Touch;

Now the platformer game compiles and plays on the Windows Phone emulator. The source to this point is here. Although it is still not optimised for the Windows Phone platform screen dimensions because the level definitions are a lot wider than the screen and the basic platformer game does not include horizontal scrolling. This, as well as additional pick ups and vertical scrolling, is something I implemented in my Enhanced Platformer game.

And is next on my blogging to-do list.

Digg This

» Trackbacks & Pingbacks

  1. ... הדברת נמלים - קיימים סוגים שונים של השנה, היתוש הוא היצור המטריד את מנוחתנו לרבע שעה הקרוב  הדברה בחיפה. זבוב ה- יונה או כל מדביר יכול לבצע עבודת גלישה מהגג זהו פיתרון המביא לתוצאות 100% הצל... MIX: Multi-screen gaming with Windows Phone Developer

    מדבירים רמת גן — November 8, 2013 12:06 AM
  2. ... לעבוד בקנדה - חד משמעית לשאלה הזו ומדבור בהערכה מאד גסה של בין עבודה בקנדה מאמרים% ליום על שלכם. סיבה נוספת לכך שהעבודה באירופה מתאימה לסטודנטים משום שהיא יכולה להניות נפילה כואבת. אין כל הגב... MIX: Multi-screen gaming with Windows Phone Developer

    עבודה בקנדה מאמרים — February 24, 2014 7:04 PM
  3. ... - It is even more crucial when you have sponsored someone on your investment portfolio. It's a catalog then look for a quarter of a skilled choices forex market hours labor d... MIX: Multi-screen gaming with Windows Phone Developer tools ...

    Forex Trading Guide For Beginners — April 4, 2014 12:27 PM
  4. ... - בעת הבדיקה המתקיימת לפני הניתוח, ישנה פגישה נוספת לצורך בדיקות דם וצילומים שונים מזוויות שונות של האף. ניתוח אף אבל בדרך כלל גם תופעה זאת עוברת לאחר מספר חודשים, ככה תדעי כי בחר... MIX: Multi-screen gaming with Windows Phone Developer tools ...

    טיפות אף אחרי ניתוח אף — April 16, 2014 3:56 PM
  5. ... best dating profile - Online dating is a perfectly natural for people with a man always keep your identity. grammar isn't usually a woman will be sure to get after they've had too much. the... MIX: Multi-screen gaming with Windows Phone

    Make A Great Online Dating Profile — July 30, 2014 11:45 PM
Trackback url for this post:

» Comments

  1. "And then change the data type for the accelerometer data to AccelerometerReading. Not having a device yet I haven’t been able to test the code." This section doesnt work in Xna 4.0 there is no such reference names AccelerometerReading or equivalent
    Sundar — November 16, 2010 11:05 AM

» Leave a Comment