In keeping with the CoderDojo ethos, these belts were earned by our young people meeting agreed standards in different coding disciplines. Belts are not for winning competitions against each other, but celebrate personal achievement, and are never given away without being earned.

This week, Martha led a great session in which she showed the ninjas how to use a painting program. There are of course lots of reasons why this is useful for coding:

For animation, as we have been working on in recent weeks

For graphics for websites, including logo design as the HTML group are working on

For buttons, icons, and other graphics in other apps and programs

The specific program that Martha used is Paint.NET. This is free (though not open-source) and is pretty easy to use, while being quite a bit more advanced than either the Paint editor in Scratch or Microsoft Paint that is installed in Windows by default.

Paint.NET works on Windows only: if you have a Linux or Mac laptop, many of the same functions are available in other painting packages, and the mentors will help you bridge the gap. One good alternative is Pinta Paint, which is multi-platform and its functionality is based on that of Paint.NET.

We have to go back in History to find out why we 60 in time quite a lot. It is thanks to the Babylonians that we have the modern day usage of 60 seconds in a minute and 60 minutes in an hour and even 360 degrees in a circle (60 x 6)

The reason that they used 60 is because it can be divided by a lot of different numbers, for example:

60 / 1 = 60

60 / 2 = 30

60 / 3 = 20

60 / 4 = 15

60 / 5 = 12

60 / 6 = 10

60 / 10 = 6

60 / 12 = 5

60 / 15 = 4

60 / 20 = 3

60 / 30 = 2

60 / 60 = 1

And for the 24 Hours in a Day, we have to thank the Egyptians who came up with that idea. They actually used 12 for Day time and 12 for Night time. But it wasn’t till a lot later that each of these 12 parts became the same length of time.

So what is a day? Well as most of you know it is the time it takes for the earth to turn round once on it’s axis.

This isn’t strictly true though as it only takes the earth 23hr and 56 minutes to spin once, the extra four minutes are taken up by turning to face the sun properly again.

So you should strictly say that 24 hours is the time it takes the Earth to face the Sun again, when you measure from Noon on one day to Noon on the next day.

And finally 365 days in the year, again this is something that we all know, it’s the number of days that it takes for the Earth to travel once around the Sun.

We have an Experiment we can do here as well.

If the Sun is the size of a Football, how big is the Earth and how far away will it be to be in scale?

And just out of interest here are some other planets years:

Mercury 88 days

Venus 224 days

Mars 687 days

Jupiter 4331 days

Saturn 10832 days

Uranus 307999 days

Neptune 60190 days

and finally poor old Pluto 90520 days, which is roughly 248 Earth Years.

So what does all this have to do with Computers, well all Computers have a clock and calendar in them to tell the time, so we are going to build one in Scratch, this will hopefully demonstrate how something that we take for granted and don’t even think about very much can become quite complex when you try and convert it into a Computer program.

Some of the things that you will have to think about:

1. The days in each month are not the same.

2. The hour hand does two circuits of the clock, the minute and second only one before the next thing changes.

3. Leap years. This is a fun one.

4. Daylight Savings Time (DST) When does it happen and which way do the clocks go?

We will need a few Sprites:

1. Second Hand

2. Minute Hand

3. Hour Hand

4. Clock Face

5. Day of Month

6. Month

7. Year

Now for the coding. Although we think of time in 60 minutes and 12 hours, all the hands on the clock actually need to turn through 360 degrees, so it is easier to code with that in mind rather than 60 seconds for example.

So, if you have your sprites setup, you will need some variables to store the position of each hand. Once you have those, you can put the code together, something like this to initialise all your variables:

And then as you can see I am broadcasting Start which contains the main code like this:

And for each of the hands, something like this should be enough:

The +90 is because Scratch has 0 degrees pointing LEFT, not UP!

The full Scratch project has been uploaded to the Scratch WebSite as well, for those of you who want to cheat :).

This week, you can choose to either create a 2-player networked game with a friend, or if you don’t feel like doing networking, you can write a 1-player version where you play against the computer. It’s up to you!