Taking the Wrong Train Home

WrongTrain
Waiting for the Wrong Train

After the fun and games last night it was time to pack up and go home. Having successfully negotiated the tram to the station I was feeling quite happy. I know the Dutch for “Schipol Airport” (it contains the word ‘Schipol’) , and having heard the announcer use the phrase in reference to the train on the platform I was quite happy to leap aboard in the confident expectation of going there. Unfortunately I don’t know the Dutch for “does not go to”, which meant that after 45 minutes or so I had to leap out of the train and find one that did.

Thanks to a very helpful lady who not only understood panic-stricken English but also knew where the right train was I was able to change direction and get to the airport in time for the flight.  I’m taking a phrase book next time…

Geek Night Files

DevDays 2010 Geek Night Setup
My name in lights…

After the fun and games of Geek Night I’ve now put all the source files and the presentation up.

  • You can find the presentation here.
  • You can find all the sample code here.

There are also some more audience pictures on Flickr. Click on the picture above to find your way to my photostream and take a look. I’m off to find a tram, a train and a plane now…

World’s First Windows Phone Controlled Robot

Oscar Takes a Bow

Oscar, my tiny Micro Framework powered robot has become the other first robot to be controlled by a Windows Phone. Charlie Kindel was kind enough to take part in my demo and give the robot commands during the talk. Thanks for that.

I nearly didn’t make it work though, loading the wrong firmware into a device is never going to end well, but in the end all the components fitted together and a happy ending ensued. I’ll have more pictures, and the slide deck that explains how it all works, along with demo code, tomorrow.

Hardware Setup

This was the setup, you can see Oscar next to my laptop, the Micro Framework board I used as a web host is on the far left.  I also had my own router and WIFI access point so that I could get the phone onto my own private internet…

Devdays 2010 Windows Phone Game Development Talk.

Devdays 2010 Windos Phone Session Audience Left Devdays 2010 Windos Phone Session Audience Right

Here is the content from my session. Thanks for being a great audience. This is actually the content from my TechDays 2010 Portugal session. I, ahem, overwrote the text in the original post. Sorry about that.

The code works on the current version of the CTP for the Windows Phone system. You can download this from here. If you want to use demo 3B to serve out accelerometer information to your phone app make sure that the program is running with Administrator privileges, and that you have modified the URL in the Phone Starlight program to address this host (localhost should just work).

If you want to get started with Windows Phone you can find a list of useful lines (and some FAQ entries) here.

Hello from DevDays 2010

Base Camp in the Tech Days 2010 Speakers Lounge
Setting up for Geek Night tonight. I just love those groovy chairs. Yes, that is a Windows Phone on the desk. And a robot…

It turns out that writing code in airports at 5:00 am actually works sometimes. I was able to get a new version of my program working and even find the source of all my hardware troubles. A dodgy network cable……

My first session is at 3:05 this afternoon, if you are at DevDays 2010 in the Netherlands then feel free to drop along and see more demos than you could shake a stick at…

For those of you not at the conference, I’ll be putting all the sample code and the presentation up on here later today.

Some Days Nothing Works

Daffs

I spent a big chunk of today making things not work. It was as if the god of “Things Not Working” decided to pay me a special visit. It was all really annoying, in that the emulations all worked fine, but the real thing failed in the strangest of ways.  In the end I was reduced to opening the fridge door and watching the light come on, just because I wanted to see some hardware that did the right thing…..

Windows Phone Imagine Cup Competition

logo

Oh to be young again. Students writing XNA or Sliverlight programs (including ones in the First Year at Hull who are turning out very good looking games for their coursework) can now take part in a development competition which is part of the Imagine Cup. The closing date is 24th May, which gives you plenty of time to work up something special. All the entrants who make it to the World Finals in Poland will get a Windows Phone. Lucky people.

Find out more here:

I wonder if they want any help with the judging….

Cletus Clay Rocks

4463053968
Cletus Clay, in the flesh at Platform 2010

Yesterday at Hull Platform 2010 we had a really good talk from Sarah Web who told us all about Cletus Clay, a new videogame which is being made using “Claymation” animation. This looks absolutely fantastic, with lots of down home humour and cow abducting aliens. You can find out all about Cletus, and even discover how to build some of the game characters yourself at http://www.cletusclay.com/

I am definitely going to get a copy of this game when it comes out…

Hull Platform 2010 Fun and Games

Did a talk today at Hull Platform 2010. This was the first of what will be an annual event bringing together game developers and expertise.

4462282531
This picture was taken during my presentation. I hope I wasn’t going too fast for everyone…

4462268483
Jon Purdy hits the stage

4462266513
Two minutes into Darren’s presentation….

I had great fun and you were all a wonderful audience. I also got to judge the two competitions that they ran, which was also very interesting, with a high standard of entries. During my talk I said I’d put some resources up on the network for you, as it takes a long time to write these down. So, here they all are.

You can get my presentation, along with the XNA games that I showed during the talk, here:

https://static.squarespace.com/static/5019271be4b0807297e8f404/52c5bcfce4b0c4bcc9121347/52c5bd02e4b0c4bcc9123749/1269541761004/Rob%20Miles%20at%20Platform%202010.zip

To compile and run your C# game programs you will need a development environment. This is where you write the code and run it. You can get free versions of the Microsoft Visual Studio tool for the Windows PC  from:

http://www.microsoft.com/express/

If you want to write C# programs you just go for the C# version of Visual Studio. It takes a while to download, but it is worth waiting for…

If you want to write games you can then add the XNA framework which provides a set of resources for both 2D and 3D games. The framework is currently at version 3.1. You add this to your installation of Visual Studio and you can get the framework from:

http://creators.xna.com/en-US/downloads

If you are a student (and have an Athens account to prove it) you can get free copies of the professional versions of Visual Studio (and lots of other free stuff too) from Microsoft Dreamspark:

http://www.dreamspark.com/

I’ve written a Microsoft Press book which teaches programming using XNA games. You can buy it from Amazon here. You can also obtain a free PDF download of this from the Microsoft Faculty Site here:

http://www.facultyresourcecenter.com/curriculum/pfv.aspx?ID=8119

There is no need to actually sign up for faculty resource membership, you can skip that step. However, if you are a teacher or lecturer you can sign up for membership and get all kinds of good stuff, including an entire programming course based on the book content. The process is a bit of a faff (you have to send them something to prove you are a proper teacher) but it is well worth the effort as you get some valuable resources including free XNA Creators Club membership. This makes it possible for your students to put their games up on the Xbox Indie games site for anyone to download and play via Xbox Live.

If you want a free copy of our C# text book (the same one we teach our students from) you can download it in PDF form from:

http://www.csharpcourse.com

I’ve recorded a bunch of screencasts that cover how to get started writing XNA games. The episodes are available from Thirteen One, which is a Hull based gaming magazine. You can find all the screencasts up to now in my index at VerySillyGames:

http://verysillygames.com/Screencasts

If you want advice on getting started in the games (or any other) business you might find it useful to talk to the Enterprise Centre at the Univesity:

http://www.hull.ac.uk/enterprise

 

SoundEffects in Windows Phone Silverlight

Buildings

Silverlight in Windows Phone is a great place to write games. I’m having to pick up a whole bunch of new skills but I reckon that it is well worth the effort. One piece of effort that I’ve had to put in is on playing sounds. It turns out that you use the SoundEffect class from XNA to get the sounds out of your games.

The first step is to add the XNA libraries to your game. Open up the References tab in your project and add the Microsoft.XNA.Framework reference.

Now add a couple of using statements to your program to make the XNA classes easier to get hold of:

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;

The sound you want to play has to be added to your project. You don’t use the Content Manager in Silverlight though, as there isn’t one.  Instead you add the item as content. Make sure that the build action for the resource is set to Content. As with old school XNA, a SoundEffect can be wav file. I just dropped a beep file into the root level:

image

You can also see here that I’ve loaded the framework. Now I can load the SoundEffect in my game:

SoundEffect beep =
             SoundEffect.FromStream(TitleContainer.OpenStream("beep.wav"));

The static FromSteam method will fetch the effect from a stream. The TitleContainer object fills in for the Content Manager in XNA. If you want to put your sounds into a folder you can, but you must give the path (separated using the / character)

image

Sounds folder as part of the project

SoundEffect beep =
   
SoundEffect.FromStream(TitleContainer.OpenStream("Sounds/beep.wav"));

Now I can play my beep sound in the usual way:

beep.Play();

This is the boring form of the Play method call. You can also control the volume, pitch and left-right panning of the sound as well:

beep.Play(
    0.5f,   // half volume
    1.00f,   // one octave higher (-1 is 1 octave lower)
    -1.0f); // on the left (+1 is the right)

Actually, I’ve noticed what might be a problem here. The documentation says that the pitch value goes from –1 (one octave lower) to 1 (one octave higher). This used to work fine when I used XNA 3.1.  When I go for pitches greater than 0.6 I get really weird sounds. I’m not sure why this is, but I’m trying to find out.

Windows Phone Accelerometer Support in XNA

Signs

There is no native XNA support for the accelerometer in Windows Phone. It seems to have been moved into a different sensors class. I hope it doesn’t stay there. The accelerometer support in the Zune HD is fantastically easy to use and well in keeping with the other inputs.

I’ve written a tiny wrapper class that implements the accelerometer using the new sensor interface, but I really think this should really be put back into XNA, as event driven stuff really doesn’t sit well with the XNA philosophy of polling:

public class AccelerometerState
{
    public Vector3 Acceleration;

    public AccelerometerState()
    {
    }
}

public class Accelerometer
{
    static Accelerometer()
    {
        AccelerometerSensor.Default.ReadingChanged +=
            new EventHandler<AccelerometerReadingAsyncEventArgs>
                     Default_ReadingChanged);
    }

    static AccelerometerState state = new AccelerometerState();

    static void Default_ReadingChanged(object sender,
                                      AccelerometerReadingAsyncEventArgs e)
    {
        state.Acceleration.X = (float)e.Value.Value.X;
        state.Acceleration.Y = (float)e.Value.Value.Y;
        state.Acceleration.Z = (float)e.Value.Value.Z;
    }

    public static AccelerometerState GetState()
    {
        return state;
    }
}

You need to add the Microsoft.Devices.Sensors library to your References to make this work.

While writing this I tried to use keyboard input to simulate the accelerometer, and I found that there is no XNA keyboard support in the emulator, which is fair enough I suppose (although I’d like it really).

It does really weird things in the debugger though, I got all kinds of strange readings if I tried to find out what keys are pressed at a breakpoint when using the immediate mode window.

Of course, I’ve not been able to try this on  a real device (I wish) but if anyone out there does I’d love to know if it works or not.

Windows Phone Resources

TechnoMart

 

If you want to get started on Windows Phone development I strongly recommend that you take a look at the videos from Mix. They are very well presented and easy to view on your PC. There is even an HD version of each one.

http://live.visitmix.com/MIX10/Sessions/CL01 – a good introduction to Windows phone and why it is the way it is

http://live.visitmix.com/MIX10/Sessions/CL13 – a good overview of the windows phone and how you build and deploy applications

http://live.visitmix.com/MIX10/Sessions/CL16

http://live.visitmix.com/MIX10/Sessions/CL17 – these two sessions give a very good introduction to Silverlight development on the phone

http://live.visitmix.com/MIX10/Sessions/CL21 – how to use XNA to build games

http://live.visitmix.com/MIX10/Sessions/CL18 – a nice in-depth description of how the phone works internally

You can get the SDK for Windows Phone here.

You can get the first six chapters of the new book from Charles Petzold on Windows Phone development here.

The forums for Windows Phone developers (which are very well staffed with knowledgeable Microsoft moderators) are here.

There is now a Programming Guide for Windows Phone on MSDN which you can find here.