Page 1

1


1. Story making and ‘Object’ concept Hello, and welcome back! So, in the last episode, we learned the basics of ‘Scratch’, and created a very simple program. It was pretty straight forward, right? But today, we will take the time to make something a little more sophisticated and fun. Let’s try making the characters respond to the inputs from the keyboard. So first, let’s think of a scenario like a cat eating a donut. To create this scene into a program, look at the ‘Sprite List’ section. On the top right corner of the section, it says, ‘New sprite’. Click on the very first icon beside it. It’s called ‘Choose sprite from library.’

When the new ‘Sprite Library’ window pops up, look towards the left-hand side and click on ‘Things’ under the category, ‘ALL.’ When you see the donut, double-click on the icon.

2


Now, when you look at your ‘Stage’, you will notice that the donut is overlapping the cat. This will always happen to any new sprite that you open because all the new sprites always appear in the middle of the stage. So, let’s move the cat to the left, and the donut to the right. The computer program consider the cat and the doughnut as two separate “objects.” So, we have to create 2 separate programs for each of the objects and see what happens when these two objects touch, or collide, each other.

3


2. How to Program the ‘Object’, Cat So, let’s create a story where the program makes the cat move forward when we press the right arrow key, and move it backwards when we press the left arrow key. First, make sure that in the ‘Sprite list’, the cat is selected. It should have a blue border around the cat icon. Then, go to the ‘Palette’ section and click on the function, ‘Events.’ Drag 2 ‘when space key pressed’ blocks to the ‘Scripts area’ and set one of them as ‘right arrow’ and the other as ‘left arrow’.

After that, go to the ‘Motion’s function and drag another 2 ‘move 10 steps’ blocks to the ‘Script area’ and link each block one-by-one to the other 2 original blocks that are already inside the ‘Scripts area’. Then, change the number of steps on the block that is under the ‘when left arrow is pressed’ block to ‘-10 steps’. Now, try pressing on the left and right arrow keys and see how the cat moves.

But we’re not quite done with the story. We still have to create a program where the cat responds to the donut object when they meet each other. So, lets make a scenario, in which the cat ‘meows’ and the word ‘munch, munch’ appears when the cat touches the donut.

4


3. How to Program for situations when different objects meet each other Go to the ‘Control’ function and drag the ‘if then’ block onto the ‘Scripts area’. Then, go to the function, ‘Sensing’, and drag the ‘touching ?’ block towards the ‘if then’ block on the ‘Scripts area’, and try to insert the blue block into the hexagonal shape that is on the gold block. A rule of thumb is that, you’ll know that a block will fit into a slot or shape when a white border appears around the shape that you want to insert.

Now, click on the facing-down arrow in between ‘touching’ and the ‘question mark’, and choose ‘Donut’ from the list. After that, drag the ‘play sound meow’ block from the ‘Sound’ function and insert it in the ‘if then’ block. Then, go to the ‘Looks’ function and drag the ‘say hello! for 2 secs’ block directly underneath the ‘play sound meow’ block.

Change the phrase, ‘Hello!’ to ‘Munch, munch. This is truly the best!’

5


4. How to Program the ‘Object’, Donut First, check if the donut has been selected in the ‘Sprite List’. Then, go back to the ‘Control’ function and drag the ‘if then’ block, and insert the ‘touching ?’ block from the ‘sensing’ function into the hexagonal slot again. This time, choose ‘Sprite1’ from the list.

Now, to fill in the ‘if then’ block, drag the ‘say hello! for 2 secs’ block, and change the phrase to ‘Please, No! NO! NO!’, and the time to 3 seconds. To make as if the donut is disappearing, in the same function, drag the ‘hide’ block directly below the ‘say hello! for 2 secs’ block. To make the donut disappear while the cat is eating, go to the ‘control’ function, drag the ‘wait 1 secs’ block, and change the time to 5 seconds.

6


Add the block in between the 2 purple blocks. But, nothing happens when the cat touches the donut with just the ‘if then’ block. So, go to the ‘Events’ function and link the ‘when right arrow key pressed’ block on top of the ‘if then’ block. Remember, we are still programming the ‘donut’ object. Now, let’s select the cat in the ‘Sprite List’. In the ‘Scripts area’, combine the ‘when right arrow key pressed’ and ‘move 10 steps’ blocks with the ‘if then’ block, like how you did in the donut’s script. All set!

To re-start the story, as in, to make the donut re-appear after it disappears, go to the ‘Sprite List’, right-click the ‘Donut’, and choose ‘show’ from the list.

7

Scratch with Intel NUC  

www.teenspc.co.kr