Coloured Mine Finder
/This is my second go at Mine Finder. Now the distance from the mine is shown as colours, and when you fidn the mine you get a nice display of all the squares.
Rob Miles on the web. Also available in Real Life (tm)
This is my second go at Mine Finder. Now the distance from the mine is shown as colours, and when you fidn the mine you get a nice display of all the squares.
This is my first version of the “Mine Finder” application that I’m using as an example of programmatically made HTML elements. You click on a cell and it tells you how far the cell is from the mine. The idea is to either find the mine or take it in turns to try and avoid it. The game is quite fun to play.
Each of the cells in the grid is an HTML button which is created by a nested for loop in the program. I’m quite pleased with the code that makes the grid:
let container = document.getElementById("buttonPar");
for (let y = 0; y < height; y++) {
for (let x = 0; x < width; x++) {
let newButton = document.createElement("button");
newButton.className = "upButton";
newButton.setAttribute("x", x);
newButton.setAttribute("y", y);
newButton.textContent = "X";
newButton.setAttribute("onClick", "doButtonClicked(this);");
container.appendChild(newButton);
}
let lineBreak = document.createElement("br");
container.appendChild(lineBreak);
}
All the buttons are assigned to the same event handler and each button is given attributes that give the position of the button in the grid. I like this because we can make the grid any size that we want and the program still works. It’s probably not the best way to make a game like this, you should really use a canvas I guess, but it was quite fun to write.
I remember ages ago listening to a radio interview with two members of Abba. They were asked how they did their song writing. They said it was a bit like being someone hunting a bear. You just had to hang around outside the cave and wait for the bear to come out. A melody might appear at any time, you just had to be ready for it. For them I think this meant sitting in the studio fiddling with this and that, waiting for the tune to turn up.
I think that writing is a bit like that too. I’ve just had quite a nice idea for an example program for the book I’m writing at the moment (gosh - that sounds pretentious - but it’s true). I’ve no clue where it came from, just I’ve spent the whole day putting down bits and bobs and this idea just popped up, mostly fully formed.
The weird, backwards nature of blog reading, where you’re reading episodes successively further into the past, means that you’ll probably see the idea before you discover where it came from, but I’m OK with that. Just remember not to stress if you can’t come up with an idea for something. Just fiddle with things around the issue for a while and, with a bit of luck, something will pop into your head...
Spent most of the day writing. But I still found time to do some piano practice. I’m moving from “can’t play one tune” to “can’t play three tunes”.
I’m back on the road again. Dot Net North have kindly invited me to be the speaker at their first in-person event since the pandemic kicked off. Really looking forward to the event. I’m going to be talking about making music with hardware. There will be devices you can build, devices you can marvel at and hopefully devices that work in front of an audience.
The event is in Manchester on the evening of Tuesday 20th September. You can sign up here.
We had a good time flying this evening . I had the same number of successful take-offs and landings, which is something of a win for me.
The buildings have eyes here
We went to the Forbidden Corner a few years ago. Today we went again. It still rocks. They don’t give you a map. They give you a page with pictures of things that you might see on the way round and then just turn you loose. It’s probably the worst place in the world where you could say “Let’s split up and search the place”. You might never meet again…..
It is in a beautiful area and we were blessed with lovely weather (although it did get a bit hot in the afternoon). If you’ve not been, an you’ve got kids you want to amuse, it is a great place to visit. The café is great too. You have to book in advance though.
I took this picture at Whitby last week. I wonder what would happen if you painted your beach hut a colour that broke the sequence?
My oven is now in the country. Rather excited.
Culinary innovations at Ferens Art Gallery cafe. We call it the “shot sandwich”.
What do you do if you have a five year old that you want to impress. Why, you take them to Hull of course. We started with a coffee (we had coffee - she had juice) at the amazing café in Ferens Art Gallery. Then on to the next room, where they had a fantastic Lego exhibition. Then down to the Museums Quarter to scoot round searching for robots and dragons. Then back for lunch in Ferens, a look at the fountains and then back home for a rest.
Hull is awesome.
What do you show a young guest who you’re trying to impress? How about the insides of a dead Furby. Not my idea actually, she saw them in a box and wanted to take a look. We went through all the various bits and I described what they did. And then we had a performance from the two working ones…
I know that this is not steam powered, but by gum it was fun to watch.
it was really nice to be able to go over to Whitby for their steam fair. It’s the first time we’ve made it in a few years and it was lovely to see it back to its best in beautiful weather. And we managed to fit in a fish pie at the Magpie too. That’s what I call a Sunday well spent.
I don’t think anyone who arrived today was actually that impressed by how tidy my room now is. Although they probably appreciated the way that they were able to walk from one end to the other.
I’ve spent the entire afternoon tidying up. I can now see most of my office floor. I’m starting to like this tidy thing.
The CSI (Crime Scene Investigators) franchise goes back a long way. I’ve still got some of the original DVDs that we bought ages ago. One or two still have the crime scene tapes around them. They must be worth a fortune. Or not.
Anyhoo, after starting in Las Vegas it then moved to New York and Miami. Then it kind of stopped. And now it is back. Unfortunately it is only showing on the Alibi network in the UK, which is not one I have access to. But we managed to get to see an episode last week and it has retained all the bonkers science it used to have, including a rather interesting use for a 3D printer. Worth a look if you can get to watch it.
I had a nice set of devices ready for the hardware meetup tonight, but I was the only one who turned up. No matter, it was nice to have a few chats with the folks in Hull MakerSpace.
Our trains leave mid-afternoon. And the Science Museum has luggage lockers, so it was back to South Kensington for some Science Museum fun. When we arrived the ground floor was a bit of a zoo, but we skipped up to the first floor (medicine) which was lovely and quiet and they had some fascinating stuff. Then up to the information technology floor for even more stuff. Panels from the original Leo computer? Yes please. We went a few years back and the computation stuff was terrible. Just a tiny model computer room from the early eighties. But now they have loads of stuff. And they had a really good game which showed how infections spread around.
Good lunch too. And then we braved the ground floor, at one end of which was a huge and expensive looking exhibition about carbon capture. Which was horrible. It presented this as a viable solution to the policy of burning things for energy. Which I’m not convinced it is. They showed this hugely expensive looking industrial plant that they reckoned could get rid of the emissions of six households. Which is tiny. Why not spend a fraction of the cost of this thing on insulating twelve households so that they only use half the power. One of the worst examples I’ve seen of “green-washing” I’ve seen. In the Science Museum. Wah.
Then we grabbed our luggage and headed for the train. Found a nice nature park near King’s Cross for a drink and then got on the train which left right on time, connected right on time and got us into Cottingham right on time. Everyone was great, trains were clean and shiny and the seats were comfy. And now we’re back.
Up early-ish. Then off to the Tate Modern. Tube travel with an Apple watch is great, you can use it to pay for your trip as long as you hold the thing right up against the reader and wait for the beep before you try to walk through the gates. Otherwise you just bounce off them, which other folks might have found funny if they had time to.
The art in Tate Modern was good, although I’m not clever enough to understand most of it. And there is a disturbing tendency for them to whack a video projector in a room with white walls and call it art. Another nice coffee though….
Then a walk through London to Foyles bookshop for lunch which was great. They didn’t have my books in the shop though. Then up to Leicester Square (Lego store closed – wah) for a look in the Japan Centre, Covent Garden (quick look in the Apple store) and then back again to the flat to rest up for the evening’s entertainment.
Then on to the Albert Hall. We were sat in “the choir” which is a posh term for “behind the orchestra”. However, it was fascinating to watch the players at work and the sound was really good. They played some stuff I knew, plus one “far out” piece that, if I heard it again, I probably wouldn’t recognise – although I’m tempted to have a go at the game in question just to discover what it sounds like there. It was interesting to see how game music has gone from “whatever we can squeeze from the hardware” into an art form in itself. And, like true art, it now has the capacity to be a bit “up-itself”.
I really hope they have another event like this. It was great. And I think I know the best place to sit…
Rob Miles is technology author and educator who spent many years as a lecturer in Computer Science at the University of Hull. He is also a Microsoft Developer Technologies MVP. He is into technology, teaching and photography. He is the author of the World Famous C# Yellow Book and almost as handsome as he thinks he is.