Code Club – Space Invaders

I’ve been running a Code Club at a school only a few miles away from where I work for 5 weeks now and I’ve been thoroughly enjoying it. Although it does a good job of challenging for ‘busiest hour’ of my week award each time.

As the children had already done some scratch (namely “Whack-a-Witch”) in year 5 we decided to jump straight into the Level 2 projects provided by Code Club. Starting with the Fish Chomp one which the children completed in the first two weeks without any major hiccups. We then moved onto the fruit machine, this provided a fair bit of amusement with the images changing too fast to be able to tell what they were and similar. The main parts the children found challenging were:

  • The event broadcasting
  • The large nested conditional statement at the end of the project (to determine if the player had won).
  • Scoping of variables (using “For this sprite only” for some variables and “For all sprites” for others.)

About half the group advanced onto the “What’s that” project and faced some of the same complications.

However, after completing each project the children would always ask “Can I create my own game now?” and the answer was of course no… But after 4 weeks of the other projects I thought we would take a break from the official Code Club ones, and see if letting them create their own games (sort of), that require the 3 points above would help them understand them better. So I decided on a good old classic, namely “Space Invaders”.

The Code Club project handouts are very nicely produced and designed well for children, they take them through the basic blocks they need for each section and show them using colour screenshots of the scripts. However the colour images of the blocks doesn’t work quite as well when photocopied in black and white (as they do at school). Many of the children also know where to find the appropriate blocks in Scratch better than I do. But when they are given a black and white image of blocks they seem to rely too much on trying to work out what the picture is of, instead of working out what the block might be in order to achieve the goal.

So for the reason above and that I don’t have a design team to hand I opted for producing a guide to create Space Invaders which only guided the children as to which bit to do next and hints of things to consider. But I didn’t tell them which blocks they needed to make their scripts with (of course as in any programming language the same thing can be achieved in many ways anyway), this they had to work out by them selves.

As I said above the children were quite into the idea of creating their own games, but at the end of week 4 when we told them next week they were going to be making their own versions of Space Invaders they all got excited (so it was a thumbs up for that idea, phew!).

Week 5 Code Club finally came round and we had a room full of excited children wanting to get cracking on their Space Invaders games, so with my simple guide to step them through the process and their brains bursting with ideas they all got going. The first five minutes was rather peaceful as they all started drawing their laser cannons and so didn’t require any scripting help.

In fact, getting the laser cannon to move left and right happened with only one or two questions where some children were trying to use the glide block, which then only allowed them to go from there current location to a hard coded one (although with extra work could have been to any location) but their class mates for the most part were able to help them keep their script simple and just use the “move # steps” block instead.

Firing the laser however turned out to be a bit more of a challenge. All the children were able to make to the laser move when the “space” key was pressed but then getting it to start from the Laser Cannon and move vertically proved more challenging. Again some children tried using the glide blocks (which again could be made to work, but you couldn’t just hard code in the x and y coordinates) again using a “move # steps” block seemed the simplest one here. Getting the order of script correct was important because otherwise the Laser would always appear from the last position you fired from instead of the current one (if you put your “go to” block last). Very few of the children were aware of how to set the direction of a sprite using the compass (blue line) above the scripts tab and so initially we had some horizontally firing lasers, easily solved though.

After nearly an hour all the children had moving Laser Cannons and firing lasers. Most of them had moving aliens and several had moving and shooting aliens. So hopefully next week we should get onto some points scoring.

The handout isn’t finished yet, as it only gets as far points scoring but I will complete it over the next week or two. I have made it available below for anyone who’s interested. I will also improve it with my experiences from above (hopefully to make it slightly easier).

space_invaders in scratch (PDF)