# Coder Dojo Athenry – Belts.

Scratch Beginners – White and Yellow Belts

Python Coders

And the Party!

# Beginners Scratch – Challenge 9 – Create a Breakout Game

This week, the challenge in Beginners’ Scratch was to write your own version of the classic Breakout game.

This game uses lots of the big ideas that we have encountered in previous weeks, and that are good to know about when preparing to get yellow belts. These big ideas include:

• Loops and Decisions
• Making Sprites Move
• Animation and Sound

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

Here is my version of the game: http://scratch.mit.edu/projects/cdathenry/2964870

If you would like a copy of my slides in PowerPoint format, get in touch via Twitter or the comments.

# Scratch Advanced – Week 10 – Christmas Game – Final Episode

What are we going to learn this week.

1. Global Variables – A  Variable that all Sprites can see.

2. More requirements

3. Ninja Belts

And that is about it for new things. We are primarily going to be concerned with getting the Present working in the Christmas Game and the final display of what you have caught.

Now, we will start in reverse and look at the “more requirements” part first. Remember we had a requirement for the game that a present should fall and if we catch it, it should be put under the tree. Well we can write that out a little better as another set of Requirements, so here goes:

More Requirements:

The present should:

1. There should be Ten presents.

2. The presents should fall in the two minutes at random times.

3. Each present should fall from the Sleigh to the ground.

4. If the present touches the fire, then it is caught, and should be moved under the tree, anywhere under the tree, but not all on top of each other.

5. Each present should be a different size and colour.

6. If a present is caught we need to keep track of how many we have caught.

So, what we can do is create one present that meets all of the above requirements and then copy it.

For number 6, it looks like we need a Global Variable so all the Present Sprites can update it. So lets make that..

And while we are on the subject of Global Variables, if the Present Sprite needs to drop from the Sleigh, it needs to know where it is, so the Sleigh needs to update a Global Variable with it’s X value all the time.

If you select the Stage, when you create a variable it is automatically a Global Variable. You don’t get the option to create it “for this Sprite only”

We need one for the X Position of the Sleigh and one to record the number of Presents.  Don’t forget to update the Sleigh Sprite so that it updates the X Position variable. Something like this:

Notice that I don’t have the Green Flag to Start the Game, I have used a GameStart broadcast, this is Broadcast from the Stage where I have all my initialisation code as well.

While we are creating the Global Variables, we can also create the two lists that we need to store the names and descriptions, so two lists as well.

This is what I have to set the lists at the begining of the Game:

Now back to the Present and the requirements.

This is the code that I have that meets the requirements… Random Colour, Random time delay, after the delay, go the X Position of the Sleigh…

Now we have to sort out how to recognise if the present has been caught by the fireplace. I picked one of the colours in the fire, and used the if touching code to find out if it has been caught. If it is caught, then we move it to the Tree.

We don’t just move the Present to the same point though otherwise they would all land on top of each other. I pick a random point under the Tree. Like this:

# Beginners Scratch – Challenge 8 – Start Preparing to Earn Your First Belt!

The ninjas of CoderDojo Athenry are starting to get ready for a new challenge: to earn belts!

Like martial arts dojos, the CoderDojo movement award belts of various colours from white to black, in recognition of skill levels in different coding disciplines. One big difference, though: our belts are USB memory keys that you can wear on your wrist!

Two weeks before the day on which we will be awarding belts, we took time to explain the process the the ninjas. The Scratch Beginners can earn one of two possible belts:

1. White Belts for commitment and basic skills (based on attending for 5 weeks or more)
2. Yellow Scratch Belts for competence in Scratch programming

The Scatch Advanced group have the potential to earn Yellow or Blue Scratch belts, and the Python  Beginners have the potential to earn White or Yellow Python belts.

To earn a Yellow Belt, you have to first be eligible for a White Belt. You also have to write a program in advance, and explain aspects of it to the mentors on the day, in order demonstrate your knowledge of Scratch programming concepts such as:

• Loops (FOREVER or REPEAT blocks)
• Decisions (IF blocks): for example, testing if one sprite is touching another or a colour, or testing the value of a variable
• Variables
• Animation and sound
• Sprites controlled by keyboard or mouse
• Other features such as Broadcasts and speech bubbles are good to have too.

Here are the presentation slides from the day, in PDF format: CDA-S2-Challenge08-PrepareForBelts.pdf

If you would like us to send you these slides in PowerPoint format, feel free to get in touch on Twitter or via the comments!

# Scratch Advanced – Week 9 – Christmas Game Part 2

1. Code reuse
2. Testing and Debugging
3. Exams!

1. Code Reuse – how to plan ahead and only write something once, remember the button we did that we exported and used again in other projects? Well, you can do the same kind of thing
within Scratch if you need several Sprites to do exactly the same thing.

First you create one Sprite and add all the code that you need for that one Sprite.

When you are happy with the way that Sprite works then just right click on the Sprite and select duplicate. The key to getting the best out this of this functionality is to ensure that the first Sprite that you have done has everythin working correctly.

2. Testing and Debugging – This is normally done using the original requirements, you basically go through the list of things that the Game should do and tick them off if it works. It helps if you have the list written down and then you know what you are testing.

And, it also helps if you get someone else to test your Game, as they will test it differently to you.

So here is the list of requirements from last week:

1.It needs to look like my living room with a nice window and lovely fire place.
2.At Christmas, when you look out the window it is normally snowing.
3.We normally have our tree in the corner, with a nice set of lights on it.
4.Santa normally flies across the top of the house and drops the presents down the chimney, lately he has not had a good aim, so we will need to be able to move the fireplace left and right.
5.If we catch the presents, we can move them to under the tree.
6.I don’t want the game to last more than two minutes.
7.And when it ends I want to know what all the Presents are.

It’s best to use Presentation Mode to do your testing.

And go through each item on it’s own. At the moment we haven’t completed all the code for everything, so you can only test the parts that are complete.

If it passes, perfect, if not, it’s time to start debugging.

Debugging, the first thing to do is run your test again, to confirm that it’s not working. There are two very important things to know here:

1. What SHOULD happen – this is what is described in the list of requirements.
2. What is happening – this is the result of your test.

When you have those two bits worked out, you can start looking at the code to see what is wrong.

In Scratch, it is possible to see which piece of code is actually running, this is done using the Edit – Start Single Stepping.

Try it out, but DON’T use the Green Flag to start everything, just click on one of the Control Blocks to start that one piece of code.

3 Exams – ok, don’t panic, but it is that time of year again.

We are all going for the Blue Belt this time, and your knowledge will be tested on what we have learnt in the last 8 weeks. Here is a refresher of the things that we have covered:

Week 1. Movies.
Week 2. Sliders and Buttons
Week 3. Random Numbers, Stamping, Saving Images.
Week 4. Exporting Sprites
Week 5. Code Reuse – Parallel and Sequential Programming.
Week 6. Lists, for saving data and reading it out.
Week 7. Code Modules, using LIsts as a Database.
Week 8. Coding to Requirements.