Sponsored Feature: Games for Zune with XNA Game Studio 3.0
Microsoft's Frank Savage, development manager for the XNA Game Studio Express team, summarizes the capabilities of running XNA Framework games on its Zune portable music player.
At the Game Developers Conference this year, we announced our launch of Microsoft® XNA® Game Studio 3.0. We talked about an exciting new feature – the ability to develop games for your Zune® device! In this article, we’ll summarize for you the capabilities of running XNA Framework games on Zune, and explain how you can make the most of gaming with your Zune.
Cross-Platform
One of the cornerstones of XNA Game Studio is the cross-platform compatibility of the XNA Framework APIs. On Windows® and Xbox 360®, more than 95 percent of the APIs are the same across networking, graphics, audio, input, and storage.
The same is true of Zune—with a couple of notable exceptions. Probably the most obvious is that Zune doesn’t have a 3D hardware accelerator built into it. This makes most of the 3D graphics APIs less valuable since, without hardware acceleration, there isn’t enough CPU performance on even the fastest Windows computers to emulate what a 3D graphics processor can accomplish. However, the 2D SpriteBatch APIs are available, and Zune is quite capable of rendering a lot of 2D sprites, even with alpha blending turned on.
Since it started life as a media player, the typical Zune likely has a bunch of audio tracks on it as well. There are new APIs for Zune that allow games to discover the audio content on Zune and play back this content as music during the game! (The APIs are coming soon for Xbox 360 and Windows as well.)
Let’s take an in-depth look at the device, each API namespace in the XNA Framework, and some of the key differences you can expect on Zune.
Basics
All the Zune devices have a fair amount of “stuff” in common. They all have 16 MB available for the game to run in, a 320×240 display with varying DPI depending on the device size, and some type of mass storage capability ranging from 4 GB flash to 80 GB of hard drive. All the devices have built-in wireless networking as well, which is available to game developers through the XNA Framework network APIs.
While the development experience is similar to the Xbox 360, it is much more seamless. You plug your Zune into a PC that has XNA Game Studio installed, run XNA Game Studio, select Zune as the debug/deploy device, and start developing! Zune automatically switches to the “connect” screen when it detects XNA Game Studio trying to attach; you don’t need to run a special application on Zune.
Games on Zune appear in their own category in the Zune UI and look and feel like other media on the device. The icon and description you provide in XNA Game Studio are copied to the device – this means browsing to games is as rich an experience as browsing to other media. When you “play” the game, it loads and plays just like other media. Once you deploy games to the Zune, you no longer need a PC connection to run them; they just work like any other media on the device.
Input
The support for Zune in XNA Game Studio 3.0 extends to all versions of the Zune device. This includes the original version of the Zune device and the 2.0 version that just shipped this last holiday season.
The input APIs for the device behave like an Xbox 360 Controller with some pieces missing. The 1.0 device control pad works like the D-pad on the Xbox 360 Controller, with the play/pause button mapped to the B button on the controller, and the back button on the device mapped to the BACK button on the controller.
The Zune 2.0 players have a great input device built into them called the Zune Pad, which replaces the control pad on the 1.0 device. The Zune Pad feels like a mouse when you use it.
It makes browsing for music on Zune a snap, even with large amounts of music on the device. The Zune Pad works like an Xbox 360 Controller with the left thumbstick mapped to the Zune Pad touch device. This gives you an analog thumbstick for game play on Zune. You can also “click” the Zune Pad, and the clicks will work as they would with the D-pad on the controller. For example, pressing the center of the Zune Pad (or the v1.0 control pad) works the same as pressing the A button on the Xbox 360 Controller. As you start to play with the Zune Pad and begin to write games for the device, you realize immediately the potential of the Zune for making games.
Graphics
As stated previously, there is no 3D acceleration built into the Zune. However, the complete SpriteBatch API is available as well as some functionality for render targets. You can still use the content pipeline to import textures into your game and then render them as sprites by using the sprite batch functionality. The SpriteBatch API supports alpha blending, additive blending, and no blending. In our tests, alpha blending a thousand or so sprites per frame still ran at close to 30 fps. The refresh rate of the screen is awesome, and there is no ghosting or refresh artifacts visible at very high frame rates.
Since all of the sprite rendering is done using the CPU and software, a lot of filtering you get for free with graphics accelerators just isn’t available on Zune. While you can perform rotation and scaling work on the device, the results may differ slightly from what you are used to seeing on Xbox 360 or Windows. It is often best to scale the art offline in an art tool, or you could use a custom processor in the content pipeline to match Zune’s resolution instead of counting on the scaling functionality at run time to generate the kinds of results you might get through offline scaling.
On the plus side, you can create alpha edges on the sprites and get free antialiasing of the sprites to any background, which makes the sprites much more seamless. Also, z-ordering is still available, so you can use the sprite system to render the sprites in the right order as long you put in the correct depth information. SpriteBatch sorts them correctly and draws them in the right order regardless of the order of the original draw calls. Again, that being said, the more work you do up front, the easier you make it for the processor, which is pulling double duty as both the rasterization engine and the processor running all your C# code!
When you consider that the Zune device initially was not designed with game play and game development in mind, Zune’s overall performance is indeed a pleasant surprise!
Audio
Obviously, Zune excels when it comes to audio playback. The game has access to the music libraries and can present menus that enable you to pick the music you want to hear with the game. You also have the option of leaving the “music” channel alone. This means whatever music you were listening to before the game will continue to play during the game! You can whip up your own favorite playlist for a game, start playing the playlist, and fire up the game while you listen. The game will mix in its own sound effects with the music from your playlist. Zune sound effects are much easier to play than they are on Xbox 360 and Windows. Since the XACT audio engine isn’t available on Zune, the simplified Zune sound API replaces the audio capabilities available through XACT. We modified the content pipeline to take a number of audio formats and convert them to single sound effects that the game can just fire and forget, using the new API.
The good news here is that the new audio API eventually will be available on Windows and Xbox 360. This means you can build the same game on Windows and Xbox 360 as you built for Zune—and it should just compile and work across platforms! Maintaining cross-platform compatibility is a big deal to the XNA Game Studio team. You could build a 320×240 Windows application that doesn’t use the 3D API and uses the new audio API, and it would recompile and run on Zune just fine.
Storage
The Zune devices all have a fair amount – 4 GB at least – of offline storage available for games, saved games, levels, and so on. Even so, as a game creator, you probably don’t want to grab too much storage because the player very likely will use Zune for media playback as well. Once again, keep in mind these storage APIs look and feel exactly like their Windows and Xbox 360 versions.
Networking
Since every Zune has built-in wireless, it would be tragic indeed if you couldn’t use this to play multiplayer games against other people with Zunes. To avoid this tragedy, we provided on the Zune the exact same network APIs that we built for Windows and Xbox 360. You can write multiplayer games for the Zune that use the equivalent of SystemLink. Then you can discover other games running nearby, create lobbies, add/remove players, and build a peer-to-peer or client/server multiplayer game as easily as you can build it for Windows or Xbox 360. Of course, there are caveats to this. The first is that Zune devices connect only to other Zune devices – they cannot connect to Windows or Xbox 360 devices. Zune also has no Internet/Xbox LIVE capability built into it, which means you cannot connect to games by using LIVE. Other than that, everything else works. You don’t even have to be in a Wi-Fi enabled setting because the Zune devices will build up their own ad-hoc network as they find each other!
When?
Zune users want to know when they will be able to build games on their Zune devices. The good news is that, in mid May, we’ll be releasing a Community Technology Preview (CTP)! Be sure to check http://creators.xna.com for information on downloading it. This CTP will support developing games on any retail Zune device. The CTP is free and will also feature a sneak-peak at our support for Visual Studio 2008, which the CTP requires. Of course, we support any version, including Visual C# 2008 Express Edition.
Nearly all of the final Zune API functionality will be in the CTP, so you shouldn’t have much trouble building the game you want to build. As always, please feel free to provide hints, ideas, and suggestions for the final release. You can do this either through the forums or through the Connect database. So, if you want to make games for the Zune using the CTP, the only thing you have to pay for is the Zune device itself. And you already have one of those, right? ;)
Read more about:
FeaturesAbout the Author
You May Also Like