Scratch Intermediate & Advanced Challenge 17: Learn about Painting!

CDA-S2-Challenge17-LearnAboutPainting

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.

You can download Paint.NET here: http://www.getpaint.net/download.html

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.

Here are the notes from the day (PDF format): CDA-S2-Challenge17-LearnAboutPainting.pdf

As usual, get in touch on Twitter or in the comments if you would like the PowerPoint version of the notes.

Also this week, our ninjas demonstrated models they had built in plasticine and graphics they had created – follow this link to see them!

Scratch Intermediate & Advanced Challenge 16: Model and Animate!

Challenge16-ModelAndAnimate

(This week, we again merged our Intermediate and Advanced Scratch groups, which means that our Challenge numbering system is now a bit messed up!)

We had lots of fun in CoderDojo Athenry with this challenge, which involved:

  • Making models with plasticine (a.k.a morla or playdough)
  • Converting the physical models into digital ones, by either drawing them in a painting program or photographing them & cleaning the photos up
  • Animating the images in Scratch

Here is a link to my fairly primitive animated Scratch model: our ninjas have made much more impressive models, which we will showcase in a post soon. http://scratch.mit.edu/projects/cdathenry/3270233

Here are my notes from the day (PDF format): CDA-S2-Challenge16-ModelAndAnimate.pdf

As usual, get in touch on Twitter or in the comments if you would like the PowerPoint version of the notes.

Next week, we will extend this topic by continuing to do modelling and have ninjas demonstrate what they have made.

Scratch Advanced – Challenge 17 – Time

Time

Questions.

How do we measure it?

Why are there 60 minutes in an Hour?   Why are there 24 Hours in a Day?

Why are there 365 Days in a Year?

Answers.

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:

GreenFlag

 

 

 

 

 

 

 

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

Start

 

 

 

 

 

 

 

 

 

 

 

 

 

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

 

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

SecondHand

 

 

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