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
Saturday
Nov192011

Nokia Lumia 800 For Free-ish

Lumia 800

Very nice too

I only went into the Orange Shop to see what the phone looked like. I wasn’t really far enough into my contract to make it possible to do a upgrade right now. Except that the phone did look very nice. And I can probably find someone who will give me a few quid for my good condition Samsung Omnia 7 (which was until 30 seconds or so into the demonstration my favourite Windows Phone). But the deal clincher was a good one. Turns out that if you are an employee of the university you can get a 25% discount on your Orange phone bill if you take out a new contract. Which means that over a year I’ll save a goodly chunk of the upgrade price. So that was that. Where do I sign?

I’m now the very proud owner of a Nokia Lumina 800. The wheel has turned all the way round. I started out with Nokia phones all those years ago, with a lovely 7110 (the “Matrix” phone) and went through a number of Nokia devices before I jumped ship because the lure of writing programs for my phone just got too great.

And now I’m back with blue boxes. The packaging and presentation were excellent. The phone is a really, really well crafted object. It has quite a turn of speed compared with the Samsung (not that my old phone was ever much of a slouch). The camera is a step up too, and even takes reasonable flash pictures. I’ve got twice as much space for content and the screen is astonishing. It has the clarity of OLED but isn’t quite as “in your face” as the Sansung.

And it runs Cheese Lander.

Friday
Nov182011

Guide Text Entry in Windows Phone

image
The layout may not be perfect, but it is a lot easier than writing your own text input.

Some of our students are making quite a good job of Evil Squash. There are even a few Windows Phone versions out there, which is nice. One of the things that the game must do is ask the player for their name. Anyone who is using XNA for the game has a problem here, as text entry in XNA can be non-trivial. Unless you use the XNA Guide.

The Guide is a way that you can ask the user questions and do lots of other interesting things. I used it to write a silly program that asks the user for their name.

if (text.Length == 0)
{
    if (!Guide.IsVisible)
    {
        // display the guide

        Guide.BeginShowKeyboardInput(PlayerIndex.One, 
            "Name entry",       // title for the page
            "Enter your name",  // question for user
            "Fred",             // default text
            new AsyncCallback(gotText),  // callback method 
            this);                       // object reference
    }
}

This is the code that I wrote. It is part of the Update method. The variable text is going to hold the name that the user enters. If it is empty I must display the guide to read it. The first thing I do is to check that the guide is not already visible. If it is I don’t need to display it again. Remember that Update is called 30 times a second on the phone, I don’t want to be overwhelmed by loads of guides.

The BeginShowGuide puts the guide on the screen. The first three parameters make very good sense, the last two are a bit more confusing. The fourth parameter gives the Guide the method to call when the user has finished typing in their name and pressed OK to close the Guide down. The fifth parameter just needs to be a reference to an object that can identify the request. I’ve given it the value of this, which is a reference to the current game. The result of this method call is that the guide is displayed, as you can see in the screenshot at the top.

When the user closes the guide, either by pressing ok or cancel, the Guide will call the gotText method that I told it about:

void gotText(IAsyncResult result)
{
    if (result.IsCompleted)
    {
        text = Guide.EndShowKeyboardInput(result);
        if (text == null)
        {
            // user pressed cancel
            text = "Cancelled";
        }
    }
}

This checks to see if the request is completed. If it is the method gets the text from the Guide by calling EndShowKeyboardInput. If the user pressed cancel the Guide will return a null string. The code above sets the text to Cancelled, otherwise the text is left as whatever the user typed in.

My program just draws the name string on the screen:

image

You can find a sample project with this code in it here.

Thursday
Nov172011

Rampant Robots

DSCF5281

We let the students give their robots names. As well as “Pet Art” above we have two Daves and one Eric.

We had a proper session of robot control today. We were making robots that don’t fall off the desk. We had a few miss-wired connections and people discovered that two motors told to go at full speed don’t actually go at the same speed. So the program can’t just assume that things will happen the way they should….

Next week we are going to see about making the control software multi-threaded so that we can drive the motors and monitor the sensors at the same time. Great fun.

Wednesday
Nov162011

Windows Phone Camp Hull

Hull Phone Camp 1

Ben addresses the audience.

Ben and Joanna from Microsoft came to see us today and deliver a full afternoon of Windows Phone sessions. We had phones, programs, pizza and tea and coffee. But no biscuits. Sorry about that. Anyhooo, a great time was had by all. Thanks to Ben and Joanna (I keep thinking of ice-cream when I type their names like this) for coming all this way and back in a day.

We did some silly development and we spent some time making a really funky windows phone camera. I promised a download of the code, here it is.

Tuesday
Nov152011

Our Little Secret at the Gulbenkian Hull

Our Little Secret

There is a new play on at the Gulbenkian Centre on the university campus this week. They’ve made the lobby look really red in honour of this. The play is called “Our Little Secret”. I’ve no idea what the play is about, but if you want to go along and find out you can book tickets on 01482 466607.