Game Mechanics and Raspberry Pi's running Windows 10

I had a go at writing a game for Three Thing Game last week. Just to be different I thought I'd do a hardware game using Windows 10 on the Raspberry Pi. We had some fun and games getting the Raspberry Pi to work in the labs, mainly because the lab network didn't give them a network address when the Pi asked. That and the fact that for some reason Logitech USB mice just don't work on a Raspberry Pi running Windows 10. No idea why. They just don't.

Anyhoo, we got everything working and I started building the game. I connected two leds and two switches to the Pi and got them working. Then I built the game mechanic. This is the way that the game is supposed to work. My first idea was that the player would have to press the button when the light came on, but I decided that this was a bad idea because after a while the switch will get destroyed by people bashing it in a hurry.

So I switched it around. When the light goes off you need to release the button as fast as you can. I called the game "Lift Off" because that's what you are supposed to do, and I made it competitive. The idea was that two players would compete in a number of rounds over a 30 second period. They'd press the button, the light would come on for a random time and then go off. The game would then time how long it took the player to release their button and then add that time to the player's score. At the end of the time period the player with the lowest score wins.

I got the code working and it was OK. But then I came across serious flaw in the gameplay.

You could win by not pressing the button at all.

If you never press the button, the light never comes on or goes off, and you end up with an unbeatable score of zero points. So I'd invented a game where doing nothing was the absolute best winning strategy. Oh well.

I've now added a timer so that if you don't press the button you get a big penalty, and I'm tuning the gameplay at the moment. I'll blog how the code works a bit later, once I've got the gameplay mechanic properly sorted - something I should have thought about earlier. Another lesson learned.

The experience of writing a C# XAML application for Raspberry Pi was a bit strange, but in a wonderful way. Everything was exactly where I expected it to be, but I was targeting a tiny device. I had access to all usual development tools. I could step through code and view variables in Visual Studio, use all the libraries that I know and love, but I was targeting a device that costs around 25 quid. If you're running Windows 10 and you've got the Visual Studio 2015 preview running you should have a go at this. It is going to make it much, much, easier to create rich applications for cheap embedded controllers. Very nice.

Fun with Lens Extension Tubes

For a while these stick on jewels and bits and bobs have been floating around the house (not literally, that would be scary - they've just been in a little jar on a shelf). Anyhoo, I thought I'd try to take some pictures of them. I bought some extension tubes off eBay some time back and I wanted to see if they work.

You can use extension tubes if you have a camera which uses interchangeable lenses. The tubes fit between the lens and the camera and have the effect of drastically decreasing the focus distance, making it much easier to take pictures of tiny things. The tubes usually come in sets of two or three, which you can combine to get different focus distances.

These are a rather racy red colour, which is nice I suppose, but the important thing is that they preserve all the electrical connections between the camera and the lens, so that focus and aperture control all still work. You can pick sets like this up on eBay for less than twenty pounds or so, and they are fun to play with. Make sure you get the set that matches your type of camera.

When you start to use them you'll discover that you can focus very close to things (beware of bashing the lens into the thing you are taking a picture of) and that the depth of field (the range of parts of the picture that are in focus), is very shallow. You can address this by adjusting the aperture, try using F8 or so, but then you'll need a lot more light.

I take lots and lots of pictures with the camera on continuous shooting, and rock slowly backwards and forwards during shooting so that the focus changes. Then I go back and pick the ones that I like the best .If you use a larger aperture (F4 or so) then you can get some interesting effects where not all the picture is sharp.

The tubes worked fine, and I got one or two shots that I'm happy with.

Windows 10 + Three Thing Game Ends

Hardy Survivors

Hardy Survivors

We reached the end stops today. By the finish we had 12 teams taking their games through to the finals. Two teams of judges went round and judged six entries each. Then we took each judges top three and brought them together to make the top six finalists. And then we settled down in Lecture Theatre D to look at the game videos the teams had prepared.

Team Spooky Elephant

Team Spooky Elephant

First up was team "Spooky Elephant" who's take on "Abel Pots Sink" had Cain pushing a water filled sink  to catch crockery hurled by a vengeful Abel. Motion captured graphics and sloshing water effects made for madcap gameplay accompanied by a Benny Hill soundtrack. 

Team 1

Team 1

Next up was "Team 1" who had a taken "Jury Hang Hung" and made a life management game for a hapless individual that needed to be kept out of trouble. This game ran on Windows desktop, Phone and Raspberry Pi, a splendid technical achievement.

Team Don't know

Team Don't know

This is team "Don't Know", who took "Coil Loop Wire" and made a platformer where the aim is to protect the coil at all costs. 

Team GDB

Team GDB

Here we have the entry from Team GDB who took "Food Much Many" and built a multiplayer fighting game where the aim is to destroy the edible scenery and drop your opponent into a vat of deadly custard. 

Betajester and Squid Physics

Betajester and Squid Physics

This is a joint effort from Betajester and Squid Phyics, who took "Envy Cars Toys" and built a sandboxed car fighting game in the micro-machines mould. Aiming envious blows at better vehicles than the one you start with allows to to change places with the good cars and progress to bigger and bigger battles. 

"Blue Team of Death"

"Blue Team of Death"

BlueTeam of Death took the words "Eyed Wide View" and made a maze based first person shooter with a great eight bit ambience. Destroy the eyes and progress through the rooms to win. Too much damage causes your view of the playfield to widen and distort, making it harder to aim. 

The judges went away for deliberation and we passed the time exchanging Pirate jokes and discussing whether we should have a Three Thing Game trophy (general consensus - great idea). Then the judges came back and announced the winners. 

Third Place - Spooky Elephant

Third Place - Spooky Elephant

Team Spooky Elephant were commended for making a highly playable and amusing game, and got third place. 

Second Pace - GDB

Second Pace - GDB

Second place went to team GDB who's multiplayer action and adherence to the theme made for some great gameplay. 

First Place - Blue Team of Death

First Place - Blue Team of Death

You know the judges have done a great job when the announce the winner and the room cheers and applauds. "Blue Team of Death" really wowed the audience with a fantastic game which was built from scratch, assets and all and then coded up using Unity, a platform that neither of them had used much. Two strong messages from the judges: great game, and you should get this in the marketplace as soon as possible. 

Judge's special mention - Johnson sings the blues

Judge's special mention - Johnson sings the blues

Before the judges wrapped up, they wanted to mention the team "Johnson sings the blues" who made it into the top six, but were prevented from appearing in the final because they had not got around to making a video. Their game, based on "Rave Cant Rave" was a chunk of multi-player mayhem with a screen that seemed to use up all the colours there are. At once. The team got a special award and was sent away with the strong message "Next time, make a video". 

You can see the winning game video here. I'll put up links to the other entries as I get them. 

Thanks to Warren, Lee, Simon, Nick and Josh for judging. Thanks to Lee, Simon, Dean and Nick for coming along and helping make the event the massive success it was. 

Three Thing Game will be back in November. With a revised Thingomatic and a trophy. Oh yes. 

Windows 10 + Three Thing Game GameJam Starts

The GameJam started promptly today at 10:00 am. By 10:30 most of the teams had turned up and signed in. All things considered, what with it being the last two days of the semester, we had a pretty good turnout. Plenty of teams and plenty of things, courtesy of the Thingomatic. Which worked fine, although it was a bit hungry on the battery side.

Before we started coding we had talks from Lee Stott (Windows 10), Nick Smith (Marmalade) and Dean Ellis (MonoGame). And then, after lunch Simon Jackson gave a talk about Unity. Great stuff, turning the event into a mini-conference as well as a hackathon.

The serious development started in the afternoon. We had the run of our large computer lab, which had been specially re-imaged with Windows 10 just for the event.

This is the team from Hull College who were using the cross platform abilities of Windows 10 to deploy a game across desktop, phone and Raspberry Pi. And it worked too. I took lots more pictures of the event. You can find them here.

TTG02.jpg

Of course we had pizza. And of course there was plenty.

One of the prizes is an "Xbox Onsie". David and Simon couldn't resist putting them on and modelling them...

When I left everyone was settling down for the night. My plan was to come back early and get cracking on my game....

Three Thing Game Thingomatic Lives

We are holding a Windows 10 gaming event at the end of this week. It's going to be a Three Thing Game, which is great, but we aren't going to have an auction for the things this time. 

For this competition we will be using the newly created Thingomatic (patent pending). You can see it above. It is an Arduino linked to a tiny associative word database that I got from those awfully nice people at Akafugu. You just press a button and you get three four letter things that are related in some way. I'm going to let each team press the button three times and pick the best three things from what comes up. Should be fun.

And by Thursday I might even have printed a box for it. 

If you are coming to the event, it all starts at 10:00 am on Thursday 11th in Lecture Theatre D in the Robert Blackburn Building on the Hull University campus. We will be having introduction sessions there, prior to moving to the Fenner computer suite for the actual development. 

It's going to be great fun. 

Splatoon Rocks

I'm not worried about the future of Nintendo. Not when they keep putting out video games of this quality. Splatoon is kind of hard to explain. You wonder if they started with the name and built it from there, or if a programmer came along and said "I've just written this great bit of code that lets you lay paint down on scenery....". Either way the game rocks.

Each player is part kid, part squid. You can play on your own, or as part of a team aiming to paint the town red (or whatever colour you've been assigned). When you change into squid mode you can move quickly through paint of your own colour. So you can spray the floors and walls in front of you and then zoom through it. You can use your "squiddiness" to go under barriers too. And of course your paint gun is pretty fatal to players shooting a different colour.

The rounds are timed and the player who has covered the most territory wins. There are some splendid weapons, including a paint roller that is horribly effective at close range. There's a story mode and lots of challenges too.

I must come clean at this point, I've not actually played it. But I watched the rest of the family having a go and much fun was had. You can do a two player mode, but you'll need some joypad like controllers, it won't work with just a second Wii controller. We used a classic controller and that worked fine.

Apparently the game works really well in network multiplayer too.

C# Yellow Book in Korean

The C# Yellow Book is going worldwide, which is wonderful. I've just agreed to the publication of a Korean version. I got an email a while back from an agent and we a presently drawing up the contracts to get it translated and into the shops.

I've only been to Korea once, I spent a week or so in Seoul as part of the 2007 Imagine Cup World Finals. It is a wonderful place. I'd go back there in a heartbeat.

I really hope I can get hold of a printed copy when it is ready. I'd love to be able to point at it on the bookshelf and say "I wrote that....".

If you are happy with an English version you can get a copy, along with a complete undergraduate course, from here:

http://www.csharpcourse.com/

I am not always me

You know those scary moments that you have every now and then, when the world seems to wobble slightly on its axis and you fret that horrible things are happening that you are only just becoming aware of? 

Well, just had one of those. On Tuesday, just as I was limbering up to do my talk at the Institute of Physics, I got an email from booking.com congratulating me for making a booking I hadn't made. Oh dear.

I'm not that happy with Booking.com to be honest. Last year I used them to book a few days in a Swansea guest house. It was very nice and all, but the company is now convinced that Swansea is the only place I want to go in the world, and keep sending me what they think are enticing offers to stay in the area again. And they keep telling me that "I've unlocked another discount". I haven't. I've just not used the company for a while. And it is likely to stay that way.

Unlike someone with a similar name to mine, who has just made a booking using my email address. I got the "click here to confirm it is you" message (which conspicuously lacks anywhere you can click to confirm it isn't you). I sent an email off to customer support and got nothing back. Except more emails about few places that my namesake might like to visit. Near Swansea as it turns out.

I've just got an email from booking.com addressed to my namesake, asking me to rate my recent interaction with a customer support person. Oh well. That has to count as progress I suppose.

Hull Windows 10 Three Thing Game - Still Time to Register

The event is filling up nicely, but we still have room for a few more folks if you want to come along. The labs are being imaged, the things are being polished and it all starts next Thursday.

If you've registered we'll have "Things on the Day" for you to base your game on, or you can have your things next Monday. Keep an eye on your mailbox for details of the all important "Thing Picking" process.

If you are in Hull next Thursday-Friday (11th and 12th of June) then you really should come along. We've got Microsoft, MonoGame and Marmalade coming along. And Unity, which doesn't begin with M, but we are giving it a free pass this time. And it is Middleware, so I guess that counts.

Anyhoo, you can find out the precise programme and sign up here:

http://www.threethinggame.com/

Remember, this is a special event in that you don't have to be a Hull student to come along (although you'll be most welcome if you do). Any local developer, or out-of-town folks who want to come along and play with Windows 10 game making can come along. And we'll have free pizza. As in PIZZA THAT IS FREE.

Talking Teaching at the Institute of Physics

One of my slides....

One of my slides....

I went to Sheffield today. It's a nice enough train ride, straight from Cottingham. Even nicer when you have company (thanks to David and Emily for being in the right place at the right time).

The reason for the trip was a meeting entitled "Developments in Teaching Physics Students Computer Programming Skills", which had been organised by the Institute of Physics Higher Education Group. They'd asked me along to talk about my experiences teaching programming. Turns out I can do that.....

It was a really interesting day. Physics is a fantastic subject. And work in the field is greatly aided by a bit of programming expertise. There was considerable discussion about whether the expertise should be given in a programming language (for example Python) or using one of the popular lab packages such as LabView. Or perhaps a tool such as MatLab or Mathematica? Or you could just do things in Excel. Much to think about here...

I gave a little talk about the importance of the practical side of things, with emphasis on professional elements. I also mentioned a little framework I'm working on to help things along (of which much more real soon).

Everyone was really concerned to make sure that the skills taught were appropriate and useful, and given in a proper physics context. I think that in this company I'm more of a "means" person, with a focus on the process of producing a quality solution, where as the Physics folks are much more "ends" types, who see computing as a small component in a much larger picture.

Ether way it was a very useful and thought provoking meeting of minds.

 

Reading "Forbidden" Web Pages with C#

In my session at Techdays last week I was showing how to make an asynchronous method that reads a web page. I was bemoaning the way that my method worked for www.bbc.co.uk but not for the wonderful site that is www.robmiles.com. When I try to read "my" page the request fails with a "403 Forbidden error".

Well, many thanks to Erik van Telgen, René Vermijs and @HenroOnline who all came back with the answer. Turns out that, unlike the liberal BBC, my blog host insists that that any read requests come from browsers, not programs. Fortunately it is easy to modify the web request to appear to be from a browser, and so get the Html back.

public async Task<string> GetPageAsStringAsync(string url)
{
    HttpClient x = new HttpClient();
    x.DefaultRequestHeaders.Add("user-agent", 
        "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)");
    HttpResponseMessage response = await x.GetAsync(url);
    string content = await response.Content.ReadAsStringAsync();
    return content;
}

This version of "GetPageAsStringAsync" returns the contents of a page and impersonates a browser when it does it.

string site = await GetPageAsString(@"http://www.robmiles.com");

It's very easy to use, as you can see above. And this works perfectly. Many thanks for your help folks.

I really hope that I get invited back to Techdays next year, I'm sure by then I'll have another bunch of technical problems I can get help with...

Eye Test

Coming soon to a face near me...

Coming soon to a face near me...

So, I went for an eye test yesterday. Cue all the eye test jokes.

"Tell me sir, have your eyes ever been checked?"
"No, they've always been blue."

"Can you see that eye-test on the wall?"
"What wall?"

etc etc

Anyhoo, I was pleased to find out that my eyes haven't changed that much since last time. I've had my present specs for quite a few years. A year and a half ago a bit fell off and I made a "temporary" repair using heat shrink tubing that has been a bit less temporary than I intended.

This time I've just gone for a single pair of glasses. No messing around with "two for one" deals. Experiments have shown that I can't wear two pairs of glasses at the same time, and that I'll probably lose the second pair anyway. They should arrive in a couple of weeks. Rather excited.

Plane Rainbow

As we were in the shuttle bus out to the plane to fly back last night there was the most amazing rainbow over the airport. When we got off to head into the plane I threw all my bags down on the concrete, grabbed the camera and took a few shots.  I'm quite pleased with the composition, although it really had nothing at all to do with me, and everything to do with dumb luck.

TechDays Sessions Fun

First Great Audience for the Universal Application Session

First Great Audience for the Universal Application Session

I don't know what it is about audiences from the Netherlands. But they are around the best in the world. Up for anything, attentive and just generally fantastic.

Await and Async audience

Await and Async audience

Both sessions seemed to go really well (at least most of the jokes got appropriate laughs or groans). I've passed the slides and demo programs over to the conference folks and they should be available soon. I'll post them here on the blog (with a bit of extra howto stuff) next week as well.

Thanks to the Techdays crew for inviting me. I was in the Hague for just about 24 hours, but they were lovely...

Flying to TechDays

Flew out to Techdays today. The weather was nice and now I'm allowed to use my phone all the way through the flight I did just that. This was the view from the plane as we flew over the UK coastline.

My sessions are tomorrow, but tonight we had a dinner in the Speaker's Lounge which was great. I was able to catch up with lots of folks I've not seen for a while. Good to see you all again.

The bags the are giving the delegates this year are really nice, and the speakers get one each too. And the speakers lounge has some very groovy furniture.

Mad Max: Fury Road

Over last weekend we went to see Mad Max: Fury Road.  Wow.

It is as if the director had watched every Michael Bay Transformers movie and then decided that he could go to around 11 or 12 on that scale. Or more. The action is relentless, violent and in some parts a bit queasy making (at least for wimpy old me).

Tom Hardy does a great job as Max. Not that he has to say much. I think they gave him his script written on the back of a cigarette packet. Charlize Theron is great in the film as well. She has lines and everything. All the souls in the movie are tortured, torturing or both.

If you like your action fast moving and with lots of spectacle then you'll love it. If you prefer films where the most action packed thing that happens is that Lady Faversham comes to visit and they can't find the best tablecloth, then you might want to give it a miss.