Hull "Cheese Grater"

They're installing a new piece of artwork in Queen's Gardens. It's an intriguing structure of laser-cut steel, welded together and painted white. It looks really good and it casts really nice shadows. I'm not sure of the proper name for it, but us locals have started calling it the "Cheese Grater". I took some pictures of it today, Rather nice.

I just hope they can stop birds from building nests in it. Then again, that might be part of the art. 

The Pimoroni Mood Light Rocks

I just love a busy desk. 

A while back I ordered a Mood Light kit from Pimoroni. It never came (sad face). I told them about this and they dispatched a replacement. The same day. With no quibble or question (happy face). It arrived a couple of days ago and today I found enough time to assemble it.

With it being based on the Raspberry Pi I had to find a video display and a keyboard for it to get things going. I ended up using my video projector of Logo Blaster fame and a little remote keyboard that didn't work until I connected it via a usb hub.

The good news is that the Raspberry Pi experience has come on a lot since my early days with my Pi B. The great news is that the kit itself is awesome. Lovely attention to detail, even down to little rubber feet for the stand. It all fits together in a very impressive way and worked first time. If you're thinking of building one, you'll need to solder the connectors onto the Pi and the display device. If you've not soldered before it might not be the best thing to learn on, but if you've soldered a bit you'll have no problems. You'll need a power supply and a micro-SD card but nothing else, the kit has everything and comes beautifully packed in a nice plastic box. 

Once I'd got the Pi going and set up remote access I was able to do everything via my PC, so I could put my keyboard and monitor away. You control the lights (there are 32 neopixel leds on the lamp) from Python, so there is no limit to what you can make the light do. 

I'm very impressed with the kit and the Raspberry Pi Zero that it is based on. The fact that you can get the thing for thirty quid (or even less if they are having a discount offer running) makes this thing astonishing value. You should get one. So much power and potential for less than a full price video game. I'm going to get the Scroll Bot next.

Sock neurosis

These are definitely wrong

Some time ago number one wife bought me some socks. Very nice. With days of the week on. Arrgh. I've had them a while, and always had a problem wearing them. If there's one thing a chap with a mildly obsessive nature really gets problems with, it's things like these. And never take them on holiday. Especially if you're flying over time zones. 

To make matters even worse, number one son got a set as well. And he came to see us. And the socks got mixed up, so that I have two left hand Tuesday socks. Which I'm wearing today. If you're going to be wrong, do it properly I reckon.

Isle of Man Royal Manx Show

So, today we went to the Isle of Man Royal Manx Show. Wonderful. Rather like the Traction Engine rally of last week, but with more cows. We didn't expect to stay all day, but a combination of good weather and plenty of things to see took us all the way to the Grand Parade at the end. They had dog agility, pony club express, bright blue sheep (and a Bo Peep to go with them). They probably had a kitchen sink somewhere too. And very probably it was beautifully decorated. 

One of the highlights was the Stampede Stunt Company.  They did a fantastic routine showing us the "Way of the Cossack Warrior". Which apparently is all about the Dzhigits of the Cossack people. The pronunciation of which for some reason had me thinking of this video. Anyhoo, they were awesome. Of course I had a camera with me. Of course I took some pictures. 

Impressive

Most impressive

Now you're just showing off...

Isle of Man Motor Museum

After a lovely evening yesterday the weather has turned, well, less nice. So we went off to the Isle of Man Motor Museum to look at cars. There are a lot of awesome cars there. They have a particularly nice selection of large american gas guzzlers with lovely chrome detailing. 

I took quite a few pictures and one or two came out. If you ever find yourself on the Isle of Man, you should check out the museum. If you're driving an electric car (I wasn't) you'll be in for  very pleasant surprise. They have a row of shiny chargers there for you to top up.

Office Lens is awesome

I had a need to scan a document today. Nothing too tricky about that, except that it meant finding the scanner, turning it on, running a program, etc etc. 

Too much like work. 

Then I remembered I had Office Lens on my phone. It's awesome. Point the camera at a page of text and it works out where the edges are, takes a picture, tidies it up and then offers to share it just about anywhere, including on my One Drive disk as a pdf file.

If you've not got this on your phone you're missing out. 

Not for sale

I keep getting emails from people who like my blog and want to put some sponsored content it. I've been offered up to 35 dollars for a slot (assuming these things are for real)

Go me. 

However, at the moment I'm afraid that space on these hallowed pages is not for sale. I don't really want to turn my blog into a profit centre. I write the posts manly for my own amusement. At least, I'm the only one that laughs at most of the jokes. 

Monday Snaps are going to be on holiday over the next couple of weeks while I write about Python. 

Traction Engines at Whitby

Gentlemen, start your engines....

Expect to find a lot of pictures of traction engines and cars appearing in my blog over the next few days. Today we went to the Whitby Traction Engine Rally. It was awesome. There were traction engines, classic cars, funfair rides and stalls selling spanners.

Spanners

The weather was kind to us (it only rained once for a bit) and a good time was had by all. I took my camera with some ancient lenses and took some pictures I'm really quite happy with. 

Monday Snaps: Cheese Physics

Last week we got the cheese moving around the screen using the cursor keys. It wasn't very good. The cheese just moved as long as you held the key down. This kind of movement is fine for some kinds of game where the action is fast and frantic, for example the paddle in a breakout game. So, feel free to steal that movement code for any of your game object that need immediate movement.

However, for Cheese Lander the skill is actually in controlling the speed of the cheese. And one way to do this is to add a bit of physics. To understand what we are going to do, we have to understand a bit about speed and acceleration.

Speed is the rate of change of my position. Each time round the game loop I could add a speed of 1 pixel to my cheese. After sixty times round the game loop my cheese would have moved sixty pixels. 

Acceleration is the rate of change of the speed. Each time round my game loop I could add an acceleration of 0.1 to my speed value. So after ten ticks the cheese would be moving at the rate of 1 pixel per game loop. After ten more ticks the cheese would be moving at a rate of two pixels per game loop, and so on. 

The game needs to store the acceleration and velocity values as real numbers this time, because the acceleration value will be quite small.

double cheeseXSpeed = 0;
double cheeseYSpeed = 0;

double cheeseXAccel = 0.01;
double cheeseYAccel = 0.01;

The initial value of the speed will be zero because the cheese is not moving. The acceleration value that you see above works quite well with a game updating 60 times a second.  

void updateCheese()
{
    cheese.Left += cheeseXSpeed;
    cheese.Top += cheeseYSpeed;

    if (SnapsEngine.GetRightGamepad())
        cheeseXSpeed += cheeseXAccel;

    if (SnapsEngine.GetLeftGamepad())
        cheeseXSpeed -= cheeseXAccel;

    if (SnapsEngine.GetDownGamepad())
        cheeseYSpeed += cheeseYAccel;

    if (SnapsEngine.GetUpGamepad())
        cheeseYSpeed -= cheeseYAccel;
}

This is the part of the updateCheese method that implements our physics. The first thing it does is update the position of the cheese by adding the speed of the cheese to its position. Then it reads the gamepad to determine if the speed needs to be changed in any particular direction. This code is very similar to the code in the previous version of the game, but instead the speed values are updated, not the position of the cheese.  Pressing a key in a particular direction causes it to accelerate in that direction. 

The final refinement is to make the cheese "bounce" when it hits the edge of the screen. In the previous version of the game we "clamped" the cheese so that it could not move off the edges. In this version we are going to reverse the speed of the cheese when it hits an edge, giving a great "bounce" effect.

if (cheese.Left < 0)
{
    cheese.Left = 0;
    cheeseXSpeed *= -1;
}

if (cheese.Right > (SnapsEngine.GameViewportWidth))
{
    cheese.Right = SnapsEngine.GameViewportWidth;
    cheeseXSpeed *= -1;
}

if (cheese.Top < 0)
{
    cheese.Top = 0;
    cheeseYSpeed *= -1;
}

if (cheese.Bottom > SnapsEngine.GameViewportHeight)
{
    cheese.Bottom = SnapsEngine.GameViewportHeight;
    cheeseYSpeed *= -1;
}

This is the same code that we saw last week, with the one change that the speed value is reversed after the cheese has been put back on the screen.

This code is great for user controlled physics based objects. It's also great for chasing aliens who can be made to accelerate in the direction of the player. 

Next week we'll take a look at the game win condition, where we have to touch the cheese down on the bread really, really, gently.

Remember that the Monday Snaps are brought to you by my book.....