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.....