Advanced Scratch – Week 8 – Planning for Christmas

Dear Santa,

I would like a nice new game for Christmas.

I would like it to be a Christmas game where you have to catch the presents in the fireplace

Just to make it easier, here are some more things that I would like it to do.

  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.

So you might need to think about the following:

  1. What to put on the Stage and what to use Sprites for.
  2. Whether one Sprite should be in front of another Sprite. This is something that we have not done before.
  3. How many costumes each Sprite needs
  4. Do you want to use one Sprite for all the Presents and just change the size and colour.
  5. Stamping could be used to get the Presents under the Tree.
  6. How to do the Snow and the Flashing Lights on the Tree.

Beginners Scratch – Challenge 7 – Buid Your Own Game!

These are the notes from our seventh challenge in Season 2 of Scratch Beginners, CoderDojo Athenry.

The challenge this week was to work on your own game. The coding concepts for this challenge are:

  1. Using the Scratch skills you have acquired for your own games
  2. Creativity and imagination
  3. Designing your own program.

A key point in developing your own game is to start simple, get the first idea tested and working, and then start adding more. We also spoke about the usefulness of planning on paper, rather than jumping straight into coding (which can be a tough one to sell!)

Here are the notes from the day (PDF): CDA-S2-Challenge07-YourGame.pdf

If you want to check how we did things in previous challenges, you can find the programs here:

We will continue to work on our own games next week, and I will post a link to a gallery of games that ninjas have produced.

Advanced Scratch – Week 7 – A fancy Piano

What are we going to learn this week:

Modularistion – How to make your code simpler and easier to look after.

Sequential Processing – review

Databases – storing static data to use later in the day.

Remember the Piano last week, where we ended up with the same code repeated again and again, all that copying, yeaagh!!!

Well this week we are going to have a look at doing the same thing but a little smarter.

This is the code that we ended up with last week, where everything was the same apart from the Mouses X position that we were checking.

Well we are going to look at making this a lot smarter.

Let’s imagine if we could get the notes on the Keyboard to got from 1 to 15 instead of 48 to 72, that should then make things a lot simpler. In order to do this we need to do a little number crunching, don’t worry if you don’t understand all of what follows.

My Piano Keyboard goes from X = -222 to x = +222 it would be easier if it went from 0 – to 444?

We can sort this out easily enough, we just make our own variable to store the Mouse X value, and add 222 to it, like this:

So our Keyboard is now 444 units wide and there are 15 keys on it, that means that each key takes up (444 / 15 ) 29.6 units.

If we divide the MouseX value by 29.6, we get the number of the Key that has been pressed (ranging from 0 to 14). For example if the User clicks on the third note, this would have an X value of around -150, we add 222 to that, which gives us 72, we then divide 72 by 29.6 which gives us 2.43, if we just take the number before the decimal point, this gives us 2, which is the third key 0,1,2. And to make it three we just add one.

Now to get just the number to the left of the decimal point is not as simple as rounding, as we always want to round DOWN. So the simplest way to do it in Scratch is to just treat as some text and find out where the “.” is. If it is in the third character then we take tw characters, otherwise we just take one. Fortunately we know that there will only be a maximum of two numbers on the left. And finally we add the one at the end so we end up with this…

Now this has got us a number from 1 to 15, how do we translate that into the correct Note to play?

We need a Database of all the possible Notes that can be played. We will store this information in a List, and fill it full of data when you click on the Green Flag.

The Notes go from 48 through to 72, with a few missing inbetween. What we want to do is have the Notes numbered from 1 to 15. This will make it easier to figure out what note to play when the user clicks on the keyboard.

We fill the list as like this…

So how does this all help us get rid of the big long repeated code block that we had before?

Well, instead of looking to see where the mouse is ourselves we just ask the code that does all the Maths to figure it out for use. We can use a Broadcast and Wait for this, so we have one “if mouse down” which asks the other code what Note should be played.

If you take out the Record and Playback code, this is everything you need…


Beginners Scratch – Challenge 6 – Story-Telling and Scrolling Backgrounds!

This week, our challenge is to work on Animation projects. We are looking at two project ideas: telling stories and scrolling backgrounds.

To tell a story, we have two sprites with speech and pauses carefully timed so that they have a conversation with each other. I just did a simple knock-knock joke, but you could do more.

After, we worked on how to make a scrolling background, a bit like the scrolling demo example that is supplied with Scratch. We figured out how to create the appearance of left/right movement by moving a sprite representing the ground in the opposite direction. We also found out how to make distant background objects, like mountains, move more slowly (called the parallax effect).

Coding concepts that we discussed included:

  1. Speech bubbles and sound
  2. Timing sprites
  3. Loops

Here are the notes from the day (PDF): CDA-S2-Challenge06-StoriesAndScrolling.pdf

Here is my Knock-Knock animation:

And here is my Scrolling Background with Mario:

If you would like us to send you the PowerPoint slides of my notes, get in touch via twitter or by leaving a comment.

Advanced Scratch – Week 6 – Lets Build a Piano


What are we going to learn this week, well it might take two weeks to get this completed.

Lists – How to put stuff in.

Lists – How to get stuff out.

Record – How to record things that happen, we might use a list for this 🙂

Playback – How to replay things that have happened, we might use a list for this 🙂

Mouse – where is it on the Screen, we use this to determine which Piano key has been pressed.


So what is a List, well they are like variables, you get to them from the same screen, but there are just a lot of them joined together. You would normally use them for similar types of things, like a Shopping list for example, where you put different items of food:

Chocolate, Crisps, Biscuits, Tea, Coffee.

We are going to use a list to store all the different Piano Keys that have been clicked. We can then use the same list to Play the Notes back again.

We also get to use the Button Building Block to add some buttons, one for Record and one for Play etc.

So what do we need for out Piano, well, we need a keyboard for a Start, we only need 16 notes (2 octaves) and we can either draw it ourselves or borrow one from somewhere.

Something like this would be good

Then we need to play the right note depending upon where the user has clicked.

There is one piece of easy code that just needs to be repeated over and over again with slightly different numbers. Here is a sample of what is needed and then you just need to repeat it with the different numbers for the location (mouse X / Y position) of the different keys.




Playback Time – so how do we play back what we recorded, well I just imported my Go Button Sprite to start the Playback and added the following code to run when I recieve the Broadcast from the Go Button… Remember how we did this before.

I needed to create another variable as well to keep track of which Note in the List we should be playing.

And finally, there is some initialisation code that keeps things nice and tidy when you click the Green Flag. But you could import another Button and use that to reset the Notes List, which would be much nicer. And don’t forget we already have the Button as a Sprite, so this should be easy to add in.

The go to x,y code I found to be quite useful as when you Click on the Piano Keys it can move the Keyboard around a little. But again, remember this will only happen in “Design” mode, when you switch to Presentation Mode, you won’t see this problem.