Thought for the Dazed

I've had to give up that Distance Learning course as I was having trouble seeing the teacher.

Flickr
www.flickr.com
RobMiles' items Go to RobMiles' photostream
Twitter
C# Yellow Book

Search entire site
Friday
Mar262010

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….

Friday
Mar262010

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…

Thursday
Mar252010

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:

http://www.robmiles.com/storage/xna-talk/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

 

Wednesday
Mar242010

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.

Monday
Mar222010

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.