Lesson 1: Animating Letters with Costumes This is an example of a sprite. A sprite can be any thing, person, or place you want it to be. You control what a sprite does. Sprites start out knowing how to do some things, like move, turn, and talk, but it is your job to make sprites do more complicated actions by combining the things it already knows. So in a way, you are teaching the sprite what to do. You can teach it to walk, jump, pick up objects, go through mazes, and many other things. Let us see what Scratch looks like when you start it up. You tell a sprite to do something by putting a Script Block into the Main Script Window. The Script Blocks you can choose from are organized into categories for Motion, Looks, Sound, Pen, Control, Sensing, Numbers, and Variables. We’ll be learning all about those different commands. To pick which Sprite you are controlling, you select it from the window on the bottom right. You can see your sprites acting out their commands in your World Preview Window. In this lesson you will teach the letters of your name to change into a different picture when you click on them. To do this, you must create those letters and them tell each of them everything it must do, step by step. We’ll see there are 4 steps. 1. Import a single letter that is in your name and a different picture it should switch to. 2. Make the letter change to the picture when it is clicked. 3. Change the program so it switches 10 tends between costumes. 4. Make all of the letters of your name behave like this We’ll implement each of those steps. 1) Import a letter and a picture We aren’t going to be using the cat Sprite in this program, so we’ll start by deleting it. You can do this by “right clicking” on the cat and then selecting “delete” from the pop-up menu. Next, we will import one of the letters in your name. You do this by clicking the “folder” button under the Stage; you’ll then see that the different Sprites are organized into different categories and folders. We want to look at the Letters. Double-click on Letters to open it. You’ll then see folders for different styles of letters; double-click on a style (e.g., Scratch) and then double-click on the letter you want (e.g., ‘A’). Now, you’ll see your letter in the middle of the Stage. Let us now pick a costume that you want that letter to switch to. Each Sprite can have different costumes associated with it; you can make a sprite look different by changing its costume. Click on the Costumes tab. You’ll see the first costume is the letter you imported. Pick a new costume by clicking Import. You can then look through the Animals, Fantasy, People, Things, and Transportation sprites included with Scratch. You might want to pick an object that starts with the same letter as the letter it is switching from. (Each costume has a name associated with it. You should always give good descriptive names to your Sprites and their Costumes. Rename your two costumes “letter” and “picture” to describe them.) Your costumes should look something like this when you are done. 2) Switch between costumes To make it look like your letter is switching into the other picture, you need to tell the sprite to switch between different costumes. Tell the cat to switch costumes by going back to the Scripts tab, click in the Top Left Menu, and then find it into the script window. If you double click on will keep switching between the two costumes. Try it out. and drag the sprite We want the letter to switch costumes not when we double-click on those instructions, but instead when a person clicks on the letter. To make the letter respond to clicking, add “when Sprite1 clicked” before next costume. That command will then start when the sprite is clicked. You can find this command by clicking Menu. Test out your scripts now. in the Top Left 3) Switch between costumes many times Right now, your letter switches to the picture and back one time when you click on it. What if you want to make the costumes switch many times after the user clicks it just once? One way to do this would be to put multiple next costumes on top of each other. But, that would take us a long time to drag the blocks into place. A better way is to tell Scratch to repeat the commands multiple times. You can do this with the repeat block. You can find this control structure under the Control menu. Put the command next costume inside of the repeat block. When you test your program, how does it look? It doesn’t look right, because you aren’t able to see the different costume; Scratch is switching to the next costume before you have time to see the first one. We can fix this problem by having Scratch wait before it moves to the next command. Under the Control menu, you will find this command: . Insert the wait command after the next costume command. How does this look? You probably think that it looks like the costumes are switching too slowly. Waiting for 1 second between switches is too long. Experiment with smaller wait times, like .5 seconds or .25 seconds. Use whatever value you think looks best! You can also change the number of times the repeat block runs; right now, it is set to switch costumes 10 times. You can change this value if you like. 4) Copying to new letters We now want to make new costumes for all of the letters of your name. To do this, you will first Import a New Sprite for each letter of your name. The letters will not show up in the order you want them on the Stage, so use the mouse to drag them to the places you want them. Next, you need to select new costumes for each of the letters. For each letter, click on the Costumes tab and then click the Import button. Select new pictures that you like. (It is much more fun, but more time consuming, if you draw your own pictures. To do this, click on Paint after New costume instead of Import. Scratch comes with a Paint tool that you can explore on your own.) After you have all of your letters and pictures, you need to write the scripts for each. You could drag and drop the Script blocks like you did for your first letter, but there is an easier way in Scratch. You can copy scripts from one sprite to another by dragging them on top of the new Sprite. When you do this, you should then see that the sprite says Scripts:1 underneath of it. If you look at the Scripts for the Sprite, you will see that one small thing changed. Instead of the control block saying “When Sprite1 clicked” it now says “When Sprite2 clicked.” Each Sprite has its own scripts and its scripts need to be activated by different events. Scratch knows that you want to activate these scripts now when this sprite is clicked. Test this out now. Everything should work as planned! One problem you might see is that some of your pictures could be too large. If you want some of the costumes to be smaller, click on the Edit button next to the costume. You will then be running the Paint editor which allows you to change costumes in any way you want. You can click on the Shrink button multiple times to make the costume a little smaller. 5) Saving your work You are now done with your first Scratch lesson. You’ve created your name from letter sprites that switch to different pictures when the user clicks on them. Save your project so you can use it later. Save it as “Lesson 1” in a new folder “Lessons”. To make a new folder, click the new folder button in the save window. Things to Remember You control what a Sprite does. Each sprite has its own Scripts, Costumes, and Sounds. To make a sprite do something, you put commands in the Script box. When Script Blocks are connected, they activate one at a time, starting from the top. You can double-click on commands to make them execute. You can copy a group of commands by right clicking a selecting “duplicate”. You can disconnect a list of commands by grabbing the commands that should be removed. Sprites can have different costumes. A sprite can switch between costumes to change the way it looks. You can edit and make new costumes for a sprite. You can make a costume smaller by clicking on Edit and then clicking multiple times on the Shrink button You can make a sprite respond to being clicked with the When Sprite Pressed control block at the the top of a list of commands. The commands underneath it will start when that sprite is clicked. The repeat control block runs the commands that are inside of the loop a number of times; the number of times is specified at the top of the loop. Final Code This is what your script should look like for each letter of your name. The word “Sprite1” will be different for each Sprite. Week 1 Homework For next week, you should finish this project for your first name. Feel free to explore Scratch and do things a little differently than we wrote in this lesson. For example, you can draw your own letters or pictures as costumes. You can change the amount of time Scratch waits between switching costumes. You can change the number of times Scratch repeats the costume changes. You can even activate the costume changes in a different way: instead of using the control block when Sprite1 clicked to start the script, you could use the control block When key pressed; this control block is activated when the user presses that particular key on the keyboard; you probably want each letter to be activated with its own key name. You can install Scratch on your home computer with your parents’ help. They can go to the website http://scratch.mit.edu and click on the Download button on the upper right part of the page. Scratch is free for both Windows and Macintosh machines. If you have any problems using Scratch on your computer at home, you can borrow an XO laptop for future weeks. We do not have USB flash drives this first week, but we should have them by next week. Next week, one of the things we will learn is how to save Scratch projects on USB drives so you can move your projects between home and school.