Monday 11 February 2013

Scratch - What's Missing

In this posting I want to talk about two things that are missing from the current version of Scratch (I'll also mention the upcoming version).

Before I start I want to acknowledge that the designers of Scratch were anxious to keep the environment simple so that newcomers and kids would not find it too confusing. So the omissions that I am highlighting here were no doubt conscious decisions by the designers. But for people who are used to other languages they are very surprising (and quite annoying to be honest).

The first is that there is no FOR loop.So if you want to perform a loop X times while changing a variable from 1 to X with each iteration, you have to do that yourself. So you need to set the initial value, check against the limit, and increment the variable by hand each time yourself.

In Whack-a-Bird I needed to a nested FOR look to move across the 3x3 matrix of holes while drawing them. Here is now the code ended up (this would have been a lot tighter if there were a FOR block):
In the new version of Scratch (2.0 - currently in beta) there is still no FOR loop!

The second omission is that you can only convert a floating point number to an integer using the ROUND block. There is no block for truncating or rounding down. This is a big omission for games writing.

For example, if you want to convert a number to two components to work with a 4x4 matrix, you will use division and the modulo function to get the two components. In Java it would look like this:

     int y=number/4;
     int x=number % 4; // % in Java is the remainder or modulus or modulo operator

Here is how that would look in Scratch. The second line will work as expected but unfortunately the ROUND block will change the answer by rounding up the result when you don't want it to:


The good news is that this HAS been addressed in Scratch 2.0 which, in addition to a ROUND function, has both CEILING and FLOOR functions.



Second Scratch Game - Whack-a-Bird

The second Scratch game I wrote, and the first I "shared" on the Scratch website, was called "Whack-a-Bird".

I've always liked whack-a-mole games (both the real and the computer versions) and I thought it would be a nice one to do with sprites (controlling position, appearance and detecting clicks).

I decided quite early on that the "mole" should be one of the red angry birds. Then one of my kids reminded me that there should be some targets that you should not want to hit and the black (exploding) angry bird was the obvious candidate.

I used to play a game called "Boulder Dash" back in the 80's and the main character ("Rockford") used to tap his foot if you didn't get on with the game. This made me think that I should animate the splash screen in some way so I put on of the birds onto it and I had him look from left to right continuously. Then I was wondering where to put the instructions so I had him "say" them randomly while waiting for the game to start.

In my version you have 2 minutes for the game, things speed up as time runs down, and then game ends if you miss 10 birds. You can play it here.

Once I had "finished" the game, I decided that an important element was missing - the possibility to have multiple birds popping up at the same time. The obvious solution to this is to have 9 sprites - one per hole. This would be the right solution if you could "clone" sprites during the game but (since you can't in the current version of Scratch) you would need to duplicate the sprite in the designer. I though this was a bit of a cop-out. In the end I created 4 copies of the sprite and I position them randomly into the 9 positions. This version of the game is much harder/more challenging. You can play it here.

Sunday 10 February 2013

Simon Pegg - Run Fat Boy Run

I went into the sitting room the other evening to see what was on TV which was making my wife laugh her head off! Turned out to be the movie "Run Fat Boy Run". It was the scene where Simon Pegg is a security guard and is experiencing some personal discomfort! I sat down and watched the rest of the movie (which we had both seen previously) with her.

The moving is pleasant and heart-warming, and has some extremely funny passages. The scenes with both Pegg and and Dylan Moran are particularly funny. It is directed by David Schwimmer (who makes a cameo appearance) and I think it deserves considerably better than its current 6.6 rating on IMDB (it gets an even worse 5.4 from the critics on Rotten Tomatoes!)

I'm a big Simon Pegg fan (to the extent of following him on Twitter - the pretty intuitive "simonpegg"). I'm not sure where I first came across him but I suspect it was "Shaun of the Dead" first and "Hot Fuzz" second. I had missed "Spaced" completely but have since bought it on DVD - it's also very good.

To be honest I think I enjoy his out-and-out comedy roles most - although I am glad that he's had the level of success to enable him to work on "Mission Impossible" and "Star Trek".

Here's a shot from the movie showing Pegg's character struggling to compete with Hank Azaria:

Saturday 9 February 2013

My first Scratch game

The first game I wrote in Scratch was called Tank and was extremely simple.

I decided to take advantage of the fact that sprites could turn in any direction, and move in that direction, and could be resized.

The idea is to steer a tank to fire on targets which appear in random positions.

The game, as I said, is simple and only has 6 sprites (3 being the tank, the target, and the missile) and 22 scripts. There is a timer which counts down from 60 seconds and you can move from level 1 to 5 as your score increases (with the target getting smaller each time).

You can steer and move with the arrow keys. Late on in dveelopment I added the facility to aim the tank using the mouse (and in so doing created my first checkbox!).

There are still a couple of bugs in it (you can still control the tank even after the game is over, and the target can appear behind the variables at the top of the screen).

Even though it is simple, my kids enjoyed playing it. You can play it here.


Scratch - A great programming environment

Scratch is a programming language/environment which was developed in 2006 at the MIT Media Lab.

It was designed to help kids to learn to program by allowing them to get results fast. It supports "Sprites" and when you launch the program it starts with this sprite already loaded:

In Scratch you don't write code by typing it in. Instead you drag "blocks" from the "Block palette" into the "Script area" and you join them with other blocks.

Here are some very simple examples of how easy it is to get your sprite to do something. The one on the left is the classic "Hello World". The one on the right will simply move your sprite to the right. Both are triggered by clicking on the sprite:

The great things about Scratch in my opinion are:
  • It is easy to create and manipulate sprites, and to respond to events
  • Because you are dragging in code blocks, you can't really make syntax errors (although you can still have bugs of course!)
  • It is easy to integrate sound (audio files, drums, and other instruments)
  • The development environment is very good
  • You can get results quickly
  • It's fun!

But that's not all. The third item in the drop-down menu (after File and Edit) is "Share". Scratch is designed to allow you to share your projects with other people and to run the programs which they have written. You can search for other programs and you can even run them directly on the web page (thanks to Flash and Java players). And if you see a program that you think you could learn something from, then you can download it and see how it works. And you are free to enhance the program which you have downloaded and to upload your own version. Genius!

Scratch can be used to create interactive stories, animations, games, music, and art. You can do simple things with it, and you can also do complex things. Here are links to some classic games written in Scratch which you can run directly from the web page with no download:
Pacman
Space Invaders
Asteroids

To finish up this posting, here's a little piece of code which should make sense even if you don't know Scratch:

Teaching Kids Programming

A few months ago I went looking for some kind of environment to give my eldest daughter some exposure to programming. As she has a iPad I was really looking for something that would work there. I quickly found (to my surprise) that Apple do not want people writing code on iPads!

What we ended up using was Cargo-Bot. This is a free game which teaches some of the basics of solving programming puzzles. The idea is to control a robotic arm which can lift, move, and put down boxes. You are given a starting position and a desired ending position and have to work out an algorithm and then write the "code" by dragging-and-dropping icons for instructions. But to be honest it is more of a puzzle and less of an aid to learning programming. Perhaps we should have downloaded Codea which is the language which Cargo-Bot was written in. But that called for a $10 investment and we just couldn't make up our minds.

In the end, of course, CoderDojo came our way and we discovered that Windows and Scratch was (for us at least) the way to go. My next posting will be on Scratch.

BTW: It seems that Apple are relaxing these rules about not allowing people to write code on the iPad. Perhaps Codea itself is a good example of this.

Here is a picture of a user trying to solve a puzzle in Cargo-Bot:

Friday 8 February 2013

Next Big Irish Band - Keywest

Before I finish up this series of postings with a musical theme, I have to mention the most exciting musical event of the Christmas period for me.

As a family we were in Dublin city centre on the Thursday before Christmas Day.

We wandered on to Grafton Street and we stopped to join a large crowd listening to a band busking on the street.

Turned out they were Keywest and they are absolutely brilliant!

They played the X Factor song "Impossible" and, even though Andy was only learning the lyrics and had to read them from a sheet of paper, their on-the-street version was much better than James Arthur's in-the-studio version.

They are going to be HUGE!

Here are some links:

Website
Facebook
Twitter
YouTube Channel

Here is a video showing what they can do on a cold day in a street in Galway:

Thursday 7 February 2013

Greatest Pop Song

I blogged previously about my two favourite albums ever. And I have blogged about my favourite Christmas songs.

But I don't think I would be able to name my all-time favourite song. Far too many to choose from.

But I realised (when I heard it on the radio recently) that I can easily name the best Pop song ever!

It is Billie Jean by Michael Jackson. It's just amazing. Michael wrote the song and he and Quincy Jones produced it. Whatever about his private life, the man was a musical genius!

And of course when it was released in 1982 it was accompanied by an outstanding (for the time) video:


Popular Music - Q102

Judging by the series of posting I am writing, I must have listened to a lot of music/radio over the last few months. And not just Christmas FM either!

For example, I found myself listening to Q102 one evening, and I discovered that my musical tastes are not as unusual as I imagined. In fact, during an evening of listing to Q102 in the background, I heard many of my favourite songs!

My musical taste therefore might be classified as "middle of the road". Basically I like Pop Music. Nothing to be ashamed of, is it?!

You can see more about Q102 here.

And you can listen live here. I'm listening to it right now and it's great.


Greatest Song Intros

It would be unfair of me to leave the top of great song intros without mentioning this one: Nether Lands by Dan Fogelberg.

It's from an album of the same name released by Dan in 1977.

The orchestral arrangement was by Dan and Dominic Frontiere and the orchestra was conducted by the latter.

I never really came across Dominic Frontiere before or since, except that I know that he composed the music for the '67/'68 TV show "The Invaders" (aside: I went back downstairs late on might when I was a young kid and my dad let me sit with him for a bit while he was watching this show. I can assure you that by the time I went to bed I was too scared to be able to get back to sleep!)

The Style Council - Shout To The Top

I was listening to the radio in the car the other day when I heard the intro to a song and I realised that it may well be the best intro to a song ever!

The song was "Shout To The Top" by The Style Council.

The song itself is good, but the intro is brilliant.

You can hear/see it here: (turn your volume up!)

Sunday 3 February 2013

Ireland beat Wales in Six Nations

Even though I am feeling miserable with a cold, and even though I have a college assignment to complete for Monday, I had the pleasure of watching Ireland beat Wales in the Six Nations on TV this afternoon.

What a performance and what a start to the competition for Ireland!

We were dominant in the first half. And four minutes in the second half, after a Brian O'Driscoll try, we had a 27 point lead!

The remainder of the game saw Wales mount a series of determined attacks, and Ireland organise a heroic defence. And often with only 14 men. Nail biting stuff indeed!

It finished 22-30 and man of the match was non other than the aforementioned Brian O'Driscoll. What an emphatic comeback to match fitness!

A fabulous game for any viewer, but especially for one supporting the winning side.

Here is a picture of Simon Zebo on his way to scoring the first Irish try:


Saturday 2 February 2013

HMV Closes Down

HMV in the UK went into administration and the 16 HMV shops in Ireland closed their doors in the middle of January as HMV Ireland went into receivership.

Whether the doors will open again or not remains to be seen, but I will miss the shop when I go to my local shopping centre. It was a great place to browse around. In early January, in fact, I was there and I bought the first season of the old TV series Kung Fu.

One caller to Today FM summaries this aspect of the situation perfectly. She said that "HMV was like a creche for husbands. It was a great place to send them when you wanted a half an hour of peace".

Here is a picture of one of these lost souls:

Friday 1 February 2013

CoderDojo - Computer programming for kids

CoderDojo is a "movement" which aims to introduce young people to software development ("coding").

It was started in Ireland (in Cork to be more specific) by James Whelton and Bill Liao. There are now 22 countries listed as having CoderDojo clubs.

My daughter started to attend the local club in Malahide late last year and she really enjoys it.

They start people off learning "Scratch" which is a really cool language for developing games, animations, etc. I will return to Scratch in future postings.

A few weeks ago I signed up as a mentor.

In my first class there were 40 kids in the Scratch groups (I counted them!). They were others in other groups (e.g. learning website development).

All of the kids (ages from 8 to 17 in theory but most of them were towards the lower end of that range) sat down at tables and took out their laptops. The parents stayed with the younger kids.

I had never stayed for a class before and wasn't entirely sure what the expect. How could 2 mentors cope with 40 kids for 2 hours?!

But the truth is that most of the kids just worked away independently for the 2 hours. They seemed completely happy.

So the great things are:
1) It's great to see kids developing games rather than just playing them!
2) It's nice to think that we are encouraging the software developers of the future.

If you want to start your own club then take a look here.


Videos of "luckiest people"

You can waste an awful lot of time on YouTube.

I found myself watching videos of "luckiest people" over recent days.

Some of the people are lucky. Some are lucky to be alive! Lots of "wow" moments! Reminds you how thin the line can be between living and dying.

One thing that amazes me is how often a driver/passenger seems to exit a vehicle (no seat belt?) and still SEEMS to be OK.

This video is 9 minutes long and is part 12 in a series!

Worst Drivers Video Compilation

I first saw this on YouTube years ago but I still think it's one of the funniest things I have ever seen.

The person who put it up claims that they are all women drivers but there's no conclusive evidence of this!

Impact of Lance Armstrong

Lance Armstrong made a public admission of his cheating, drug use and general unacceptable behaviour on Oprah recently.

I know very little about Lance Armstrong and I care very little.

What does interest me is the negative impact of his behaviour on others.

I think there are a number of distinct groups here (I am omitting people like his family here).

The first group contains people like Paul Kimmage, David Walsh, Emma O'Reilly and others. These people spoke and wrote about his doping and cheating and he attacked them (and even sued some of them) for doing do. They are now vindicated and he is shown to be the cheat and the liar. I saw David and Emma on The Late Late Show on Friday. They observed (quite rightly in my opinion) that Armstrong has no remorse for what he did, and no remorse for the consequence of his actions. His remorse seems to relate to the fact that he was caught and to the money which he has lost.

The second group contains people who looked up to or were inspired by Armstrong . I am thinking of the people who worked in his Foundation. I am thinking of Michael J. Fox who spoke so highly of Armstrong in his second book "Always Looking Up: The Adventures of an Incurable Optimist". I can only imagine what these people are feeling. I see that the charitable organisation has taken various steps to distance itself from Armstrong including changing its name in November 2012 to the "Livestrong Foundation".

The third group are the riders who did not achieve what they should have in cycling because they were unwilling to participate in the cheating which contributed to the success of Armstrong and people like him. Can you imagine what it is like to participate in a sport where a man who was cheating won the Tour de France every year from 1999 to 2005? Paul Kimmage referred to Armstrong as the "cancer" of cycling. Paul Kimmage was right.

Here are some interesting videos:
Armstrong swears under oath that he never did or took anything on the banned list (2005)
Armstrong lies in interview (2006)
Armstrong attacks Paul Kimmage (2009)
Michael J. Fox interview Armstrong (date unknown)

Interview with Paul Kimmage
Interview with David Walsh
Emma O'Reilly interview
Interview with Frankie Andreu, former cycling team-mate of Lance Armstrong, and his wife Betsy
Betsy Andreu angry and upset in interview

Heard on an Arts programme on the radio this evening

The host asked the panellists  wrt the lyrics of a song: "Is this clever, or is it too clever?"

No, seriously.

Perhaps he was really asking a question about his own question!

Reminds me of a wonderful sketch on "A Bit of Fry and Laurie" where the host and panellist discussed how many levels a sketch worked on! You can see it here: