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.