Windows Phone 7 XNA Samples

As promised in yesterday’s application video the XNA Team at Microsoft has just released a couple new (and updated) samples for Windows Phone 7. If you are currently build a WP7 games wish to start a project I suggest you take a look at them to get a better understanding of the capabilities of XNA on Windows Phone 7. Full description of every sample after the break:




This sample shows how to read the accelerometer sensor on Windows Phone 7.
Sample Overview

Windows Phone 7 devices include a number of hardware sensors, one of which is the accelerometer. The accelerometer can be used to detect tilt, shaking, and other motion in three dimensions. This sample illustrates use of an accelerometer class to handle accelerometer data and update the position of a sprite on the screen.



The bounce sample draws and physically simulates 100 spheres of varying size, mass, and weight.

Sample Overview

The physics simulation uses an implicit solver for collision detection and response.  An implicit solver was chosen for its stability and fast performance. The spheres are modeled with some elasticity, and the simulation loses energy by simulating air friction.  The sphereCollisionImplicit function contains the physics algorithm for collision detection and response….

Fuzzy Logic


This sample shows how an AI can use fuzzy logic to make decisions. It also demonstrates a method for organizing different AI behaviors, similar to a state machine.

Sample Overview

When you program the AI for your games, you know that your actors often have to choose between several different options. In many cases, the choice is black and white: if you see the player, attack him. However, the decision making process is often much less clear cut. If you are low on health, go find a med kit. If there is a powerup nearby, pick it up. But how do you define “low on health,” or “nearby?” And what if you’re both low on health and also near a powerup? Which action is more important? You can give your AI actors the ability to make these kinds of “fuzzy” decisions by using fuzzy logic.

Touch Thumbsticks

Description:This sample demonstrates a technique for using the touch panel to provide thumbstick-style controls for a game.
Sample Overview

The sample contains a simple shooter game controlled by holding the phone in landscape orientation, and by using two sides of the screen as thumbsticks. The class that implements the thumbstick logic is segregated for easy reuse in other games using the same control scheme.


Description:This sample demonstrates basic artificial intelligence navigation in 2D, using waypoints.
Sample Overview

When programming the AI for your game, you often want your actors to follow a path that you supply. For example, you may want units in your real-time strategy game to follow orders, or perhaps you want to make a mouse navigate a maze.

This sample uses a tank to demonstrate two examples of this waypoint following behavior. In this sample, you can move the cursor around and add waypoints toward which the tank will move in the order that you add them.

Sprite Sheet

This updated sample for Windows and Windows Phone shows how to implement sprite sheets, combining many separate sprite images into a single larger texture that will be more efficient for the graphics card.

Stock Effects

Description:Stock effects provides source code for the five effects (BasicEffect, SkinnedEffect, EnvironmentMapEffect, DualTextureEffect, and AlphaTestEffect), and the default shader used by SpriteBatch (SpriteEffect), built into the XNA Framework. There also is a command-line utility (CompileEffect) that uses the Content Pipeline to compile a .fx source file into a binary blob that can be passed directly to the XNA Framework Effect class constructor.
Sample Overview

This code is provided for educational purposes. It may be a useful starting point when you create more advanced shaders.

Although the built-in effect classes are simple and easy to use, the shader code behind them is complex because these effects support many rendering options within a single shader. BasicEffect, for example, allows you to toggle on or off texturing, vertex colors, and lighting, and to select per-vertex or per-pixel lighting. To support all possible permutations of these options, BasicEffect ends up needing no less than 20 different vertex shaders and 10 pixel shaders, all of which are combined within a single effect file.

If you want an easy starting point to learn shader programming, use the Shader Series samples. The shader samples are simpler to use than the effects described here because they do not include so many adjustable options.

Content Manifest Extensions
This sample for Windows shows how to build a list of deployed content for your game to use.