Page 4

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.


Scratch with Intel NUC