Categories
Uncategorized

Counting Down to Seven: “Platformer” Running on Windows Phone 7

Welcome to another installment of Counting Down to Seven, a series of articles about mobile app development that I’m writing as we count down the days to MIX10, when we reveal more about the up-and-coming Windows Phone 7 Series.

In my last article in the Counting Down to Seven series, I showed you Platformer, the game starter kit that comes with XNA, the toolset/framework for developing games for Windows, XBox and Zune:

image

Let me now show you this – Platformer running on Windows Phone 7:

That’s Microsoft’s Eric Rudder, Senior VP Technical Strategy demoing Platformer at the TechEd Middle East conference. Not only does Platformer play on Windows Phone, Windows, XBox and Zune, but he also demoed saving the game state on the phone and resuming it from the saved state on an Xbox 360.

Eric also showed that even though Platformer runs on a number of platforms, it’s based on a single codebase with slight platform-specific tweaks for the platforms it targets. This isn’t new: XNA has been about targeting Windows and Xbox 360 from the very beginning, and with version 3.0, the Zune was added to the set of target platforms.

Take a look at this screenshot of the Solution Explorer from Visual Studio 2008 with XNA 3.1 with a Platformer solution loaded. Note how the solution has three projects, one each for targeting Windows. Xbox 360 and Zune:

image

All three games share the same sounds, but the Windows and Xbox 360 versions use a set of higher-resolution graphics while the Zune version uses a lower-resolution set.

XNA also makes use of compiler directives to handle the differences between platforms. For example, here’s a code snippet from Platformer from the Player class, which manages the player’s character in the game:

#if ZUNE
        // Constants for controling horizontal movement
        private const float MoveAcceleration = 7000.0f;
        private const float MaxMoveSpeed = 1000.0f;
        private const float GroundDragFactor = 0.38f;
        private const float AirDragFactor = 0.48f;

...

#else
        // Constants for controling horizontal movement
        private const float MoveAcceleration = 14000.0f;
        private const float MaxMoveSpeed = 2000.0f;
        private const float GroundDragFactor = 0.58f;
        private const float AirDragFactor = 0.65f;

...

#endif

Note how the Zune version has scaled-down values of those used in the Windows and Xbox 360 versions. That’s to account for the Zune’s smaller screen.

XNA on Windows Phone 7, with the ability to save game state on one platform and resume playing on another opens up a world of “ubiquitous gaming” possibilities. I hope that this will bring about some interesting mobile games and bring some attention to the XNA, which I always felt was underappreciated.

This article also appears in Canadian Developer Connection.

Categories
Uncategorized

Counting Down to Seven: Exploring XNA

exploring xna largeCounting Down to Seven (Mar 15th at MIX 10): A series about ideas for mobile apps

Welcome to another article in the Counting Down to Seven series and the first article in the Exploring XNA series — it’s like the chocolate and peanut butter of mobile development!

If you haven’t read Windows Phone team member Charlie Kindel’s latest blog entry yet, do so now. In explaining what’s different in Windows Phone 7, he also lists some technologies that form it basis:

  • .NET
  • Silverlight
  • XNA
  • Web 2.0 standards
  • Microsoft’s developer tools

That’s right: along with Silverlight, one of the core elements of Windows Phone 7 is XNA, the toolset that makes it quite easy to build games for the PC, Xbox 360 and Zune. Kudos to those of you who ratiocinated that Silverlight and XNA would figure into Windows Phone: both are proven user interface technologies that have also shown that they’re capable of living on different platforms.

I’ll cover each of the core elements of Windows Phone 7 in the fullness of time, but for now, why don’t we start with what I consider to be the really fun one – XNA?

(It’s not only fun – it’s the gateway to customers: according to eMarketer, the number of people who play games on their phone has more than doubled in the past couple of years, from 155 million in 2007 to a predicted 340 million by the end of 2010.)

XNA: A Quick Overview

In the venerable geek tradition of using recursive acronyms to name things, XNA is short for “XNA’s Not Acronymed”. In the Microsoft-y tradition of using one name to represent a smorgasbord of things, XNA is a framework, toolset and runtime that makes it easier to build and deploy games.

XNA provides a great skeleton for building 2-D and 3-D games with a set of game-centric class libraries and a straightforward programming model. Its design frees you from a lot of the “yak shaving” and related drudgery involved in game development, letting you spend more time on programming the gameplay instead. Its “simple but not stupid” quality recently allowed me to walk a workshop of Humber College students from an initial “let’s draw a static sprite on the screen” project to a pretty decent “run around the game field, dodging the flying spinning blades” game, complete with animated sprites, sound effects and soundtrack and scoring, all in about three hours. Better still, we had fun doing it.

Required and Optional Tools for XNA Development

Here’s what you need (and some nice-to-haves) to get started with XNA development:

Required

  • Windows 7, Vista or XP, with the latest service packs installed.
  • Visual Studio 2008, which costs money, or Visual C# 2008 Express Edition, which is free-as-in-beer. Don’t let its being free throw you off; it’s a complete IDE and more than enough for developing games. As of this writing, the 2010 editions of Visual Studio, which have not yet hit the “Release to Manufacturing” stage, don’t support XNA game development yet.
  • XNA Game Studio 3.1. This is a set of Visual Studio add-ons and tools for developing games for Windows, Xbox 360 and Zune using XNA. This is also free-as-in-beer.

Optional

Platformer: XNA’s “Right Out of the Box” Game

If you’re the sort who wants to play a game before doing some game development, you’re in luck. XNA provides Platformer, a fully-functional “platform jumper” game as one of its project templates. You can simply treat is as a game, but that would be a waste – its true value is that in its source code are a lot of lessons in building 2-D games with XNA. I’m going to show you how to build a Platformer project.

(In the screenshots below, I opted to use free Visual C# 2008 Express. If you have one of the full version of Visual Studio, the experience will be similar.)

Start up Visual C# 2008 Express or Visual Studio. From the File menu, select New Project… You should see a dialog box like the one shown below appear.

image

In the Project types: list on the left-hand side of the dialog box, select Visual C# and the select XNA Game Studio 3.1 from its sub-menu. In the Templates list on the right-hand side of the dialog box, you should see a number of game application templates. Select Platformer Starter Kit. Fell free to the edit the contents of the Name: textbox if you want to give your project a different from the default and click the OK button.

Visual Studio will generate a new project. You’ll know because the Solution Explorer pane will be filled with projects and their files:

image

Press F5 to run the game. In moments, you’ll be greeted by the screen below:

image

Platformer looks like an homage to both platform games as well as Raiders of the Lost Ark. You’re represented by an Indiana Jones-esque sprite and must reach the “Exit” sign before time runs out. You have the option of collecting gems to increase your score.

You move to the next level if your reach the exit sign before time runs out:

image

Here’s level two, which features more platforms, more gems and a shambling mummy who can kill you with a touch:

image

Here’s level three, which is filled with platforms that you can jump through:

image

Make sure you check out the code for Platformer. Reading it is a great way to learn XNA game development techniques and tricks.

Hello, XNA!

Once you’re done playing Platformer, you might want to try your hand at XNA development. I’m not going to show you how to write anything resembling a game in this article (I’ll do that over the next few articles in this series), but I thought I’d quickly show you how to get the world’s simplest XNA application – in the best “Hello, World!” tradition – up and running.

Just as you did with Platformer, click on the File menu, select New Project… This time, when the New Project dialog box appears, select Windows Game (3.1), give the project a name in the Name text box (I chose HelloXNA) and click OK:

image

Visual Studio (or Visual C# Express) will then generate your game project.

A newly-created XNA game project has all its code living in a single class, which is given the name Game1, which in turn is stored in the file Game1.cs. I want to rename that class to HelloXNA. That’s easily done by moving the cursor over Game1 at the start of the class declaration, right-clicking on it, selecting Refactor from the menu that appears, and then Rename… from the submenu:

image

I could use good ol’ search-and-replace, but it blindly taking the search term and changing it into the replacement term, no matter where it is. Refactor –> Rename… is smarter; it does a true renaming of the identifier without mangling other identifiers that happen to contain the search term. It also allows you to specify whether you want to do the renaming in comments and string literals, which old-school search-and-replace doesn’t do.

When the Rename dialog box appears, enter the new name for the Game1 class, HelloXNA, into the New name: text box. Make sure that the Preview reference changes checkbox is checked before clicking OK:

image

If you checked the Preview reference changes checkbox in the previous dialog box, you’ll see a preview of the changes that will result if you apply Refactor –> Rename…. Click Apply to finalize the renaming:

image

You’ll see that the Game1 class and any references to it in the code have been changed to HelloXNA. For consistency’s sake, we’ll rename the Game1.cs file in which the class formerly known as Game1 to HelloXNA.cs in the Solution Explorer:

image

By default, a brand-new XNA game project without any code added to it does a very simple thing: it draws a blank screen with a cornflower blue background. If you hit F5 to run the application right now, you’ll see this:

image

Now “all you have to do” is write some game code! I’ll walk you through that process over the next few articles in this series.

Next Steps

Cover of O'Reilly's book "Learning XNA 3.0"

You could wait for the next article in this series, but if you’re rarin’ to learn how to develop games with XNA, let me recommend Learning XNA 3.0, written by Aaron Reed and published by O’Reilly. It has a 4.5-star rating at Amazon.com, which it’s earned – it’s a great introduction to XNA development. The first half of the book is devoted to 2-D game development, starting with drawing a sprite on the screen and finishing with a pretty complete game. The second half of the book adds the third dimension and works towards building a 3-D game.

image

You should also get a look at XNA Creators Club, the online community for XNA developers. It features:

  • Links to all the downloads you need to get started developing games with XNA
  • Starter kinds for various game genres – you get Platformer with XNA; you can download starter kits for other game genres, including:
    • Marblets: a marble colour-matching puzzle game.
    • Spacewar: the classic “spaceship vs. spaceship” game that comes in two flavours – retro and evolved.
    • Role-Playing Game: A tile-based RPG engine with support for character classes, multiple party members, items and quests.
    • Racing Game: A 3-D auto racing game featuring advanced graphics, audio and input processing, where you race against the ghost car for the best time.
    • Ship Game: 3-D spaceship combat in a tunnel system with advanced lighting and textures, a full GPU particle system and an advanced physics engine.
    • Net Rumble: A 2-D shooter showcasing XNA’s new multiplayer features in an arena with asteroids, power-ups and up to 16 players.
  • Forums to discuss ideas and ask questions with your fellow XNA game developers
  • A catalog of games created by members of the XNA game developer community. You can try out their games, submit games and vote for games to be included in the Xbox Indie Games catalog, whose games can be purchased through Xbox Live.

If you want to be a rock star on Windows Phone 7, you’re going to want to sharpen your XNA chops. Get a head start and take it out for a spin!

This article also appears in Canadian Developer Connection.

Categories
Uncategorized

O’Reilly’s “Learning XNA 3.0”

Cover of O'Reilly's book "Learning XNA 3.0"

Hey, it looks like I’ve got some potential reading material for the holidays! O’Reilly’s just released their new book, Learning XNA 3.0, an introduction to Microsoft’s 2-D and 3-D game development framework for the PC, Xbox 360 and Zune. Here’s an excerpt from O’Reilly’s description of the book:

Written by an experienced university-level game development instructor, Learning XNA 3.0 walks you through the framework in a clear and understandable step-by-step format. Each chapter offers a self-contained lesson with lots of illustrations and annotated examples to help you master key concepts. Once you finish the book, you’ll know how to develop sophisticated games from start to finish.

  • Learn game development concepts from 2D animation to 3D cameras and effects
  • Delve into high-level shader language (HLSL) and introductory artificial intelligence concepts
  • Develop three complete and exciting games using 2D,3D and multiplayer concepts
  • Develop and deploy games to the Xbox 360 and the Microsoft Zune

While teaching XNA to beginning game developers, author Aaron Reed noticed that several key concepts were difficult for students to grasp. Learning XNA 3.0 was written specifically to address those issues. With this book, you can test your understanding and practice new skills as you go with unique "Test Your Knowledge" exercises and review questions in each chapter.

The book, when purchased from O’Reilly, comes in several formats:

  • Dead-tree format (that is, an actual paperback book): US$34.99 (currently CAD$44.06) / £24.99 in the UK
  • Ebook (PDF, EPUB and Kindle-compatible “Mobipocket” format): US$27.99 (currently CAD$35.23)
  • Dead-tree and ebook: US$45.49 (currently $57.27)

If you’re in Canada, you’ve got a chance to save big. Chapters/Indigo’s online price for the paperback book is CAD$23.09, which makes it cheaper than the electronic version. If you’re an iRewards member, they’ll shave another buck-fifteen off the price to make it CAD$21.94.

Links

Categories
Uncategorized

Salmagundi for Friday, November 7th, 2008

Interview with Chris Slemp, MSDN

joey_devilla_chris_slemp

Here’s another video interview featuring Yours Truly at the PDC: it’s with Chris Slemp, Program Manager for the Server and Tools Online group at Microsoft. In the interview, we talk about MSDN and its new social bookmarking feature.

Click here to watch the video.

“Grim Fandango’s” Puzzle Document

grim_fandango_puzzle_document

If you’re looking to get into the mind of a game designer and the design of one of the most highly-regarded computer adventures games, be sure to check out the Grim Fandango Puzzle Document. Tim Schafer, in “a temporary fit of Cake-induced Grim nostalgia,” decided to put the game’s puzzle design document online in PDF form (it’s 2.3MB in size).

Here’s a great summary of the Grim Fandango Puzzle Document, written by Andy Geers:

I use that word "crafted" because that’s exactly what this newly released document shows: true craftsmanship. We see the incredible attention to detail, the pacing of the narrative as it builds and as the puzzles get increasingly sophisticated, always coaxing the player along with them. As somebody whose spent the last few years trying to write my own adventure game, what struck me most about this document is the sheer simplicity of it – it’s well established that it takes a great deal of clarity and hard work to boil down something so vast as Grim Fandango into such a simple representation that conveys so much information in such a succinct way.

It’s a considerably more interesting read than most specs.

My Job-Related Reading List

Nothing gives you that frozen-caveman-thawed-in-modern-times feeling like returning to a software platform after not developing in it in seven years. Getting back into the swing of Microsoft’s development tools has been fun so far, but it is, as a lot of people have told me, like drinking from the firehose.

reading_list_nov_2008

To quickly get acclimated with C#, ASP.NET and XNA, I’m expensing the following books I bought today:

I’ll let you know what I think of these books as I read them.

“Zero Punctuation” Reviews

And finally, a couple of reviews from my all-time favourite game reviewer, Ben “Yahtzee” Croshaw. The first one’s for Saints Row 2, which includes a great argument for why it might actually be a better game than Grand Theft Auto IV as well as a brilliant concept for a new game:

and here’s the latest review, for Dead Space, which he summarizes as “competent but bland”. Luckily, his review is anything but…