Presentit.co.il
Mom, Dad, I wrote my first computer game
KIDS CAN PROGRAM
SCRATCH, 8 LESSONS
THE QUICK AND EASY WAY TO TEACH AND LEARN SCRATCH
BY AVI SALMON
Author of
[pic] [pic]
Copyright © 2013 by Avi Salmon
All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted by any means – electronic, mechanical, photographic (photocopying), recording, or otherwise – without prior permission in writing from the author.
Preface
Congratulations! Thank you for downloading my book. SCRATCH is a kid programming language that simplifies the way kids can program and write code. SCRATCH is highly intuitive and graphical and kids can learn it easily. I have been teaching Scratch kid programming language for a couple of years and it amazes me again and again the abundant joy kids and the teachers get out of it.
If you are a parent, your child will love playing SCRATCH with you. If you are an instructor, you have a proven opportunity to enrich your students and create fun from ordinary teaching materials.
The most common request I get from anyone that wants to start and teach or play with Scratch are teaching materials. This is the reason this book was created. It includes 8 lessons of simple principles in SCRATCH and programming. They are all "fun" and kids will learn things from the back door. The lessons are basic but set a great background for a highly sophisticated project. By not going through such lessons, children are stuck with simple animation and that's it. Going through the lessons enables children to collect different useful principles to be used in innovative projects.
These 8 lessons fit ages 10-12. You will be amazed by the fun and joyful learning you will experience along with the kids. Join me in the journey to get your kids smarter and ready to be technology buffs.
Please, If there are any mistakes or broken links, please do write to me at avi.salmon@. That's the fun about ebooks, you can fix them.
If you liked the book, please don't forget to review it on
Table of Contents
Introduction - Learn to program in a couple of hours!
Getting Started: Creating a new project
Lesson 2 – Drawing
Lesson 3 – The elephant race
Lesson 4 – Talking with Scratch
Lesson 5 – Mastering X-Y coordination
Lesson 6 – The paint program
Lesson 7 – The labyrinth– responding to colors
Lesson 8 – A little touch of math and algorithms.
Scratch 2.0 – Introduction to great cool possibilities in the new Scratch environment.
Introduction - Learn to program in a couple of hours!
Yes, you can! If you can use a computer, you can learn to program, in no time!
Would you like to have fun playing games online, sharing with friends, creating imaginative and fun programs as you learn programming and mathematics? Well, with Scratch, you can do all that and a lot more.
What is Scratch?
Scratch was created by MIT, the Massachusetts Institute of Technology, who wanted everyone to have fun with computers.
It's meant for kids between 8-16 years old, though younger and older people enthusiastically share their creations.
It's a programming language that you can have fun with, creating stories, animations, games, graphics, and interactive platforms. Anything you can come up with, really.
Everything's online and sharable, and there's an enormous community you can share your creations with, or seek inspiration from.
It uses brightly colored command blocks that connect like Legos instead of written script, making it easy to 'see' what's going on when you create something.
Who is it meant for?
Anyone who wants to be creative, have fun and learn programming can use Scratch. It's targeted at children 8-16 years, but avid Scratchers come from all age groups.
What is our goal here?
Scratch helps children think creatively, reason systematically and work collaboratively.
Youngsters learn to program, visually grasp mathematical and logical concepts, and gain confidence as they create and interact with children from all over the globe.
But be careful! If you teach Scratch as a normal profession in school, with exams and grades, you will find yourself losing the kids' enthusiasm and killing their creativity. We highly recommend teaching Scratch in a fun and challenging game atmosphere where the answers are not graded, but rather where beautiful games are created by the children. This will keep them happy to think, create and cooperate and will teach them so many things without them even noticing.
Getting Started: Creating a new project
Go to in your browser, and sign up for an account.
There's certainly plenty to do here:
First of all, create a new project.
Explore other people's projects.
Discuss and interact with the rest of the Scratching community.
Learn more about Scratch in Help.
Manage your Profile, put creations in My Stuff, and check Account Settings.
Let's click on Create to get started!
Take a Look Around
Clicking on Create brings us to the main programming environment in Scratch. This is the editor or workshop where we're going to build all our wonderful animations, graphics and stories.
Let's get to know it.
It consists of four main areas:
The Stage
The Sprite List
The Blocks Palette
The Scripts Area
The Costumes (in a tab right behind the Blocks Palette)
The sound (in a tab right behind the Blocks Palette)
It's very easy to use, and you'll be clicking around the project editor in no time, making awesome creations.
Stage
Sprite List
Blocks Palette
[pic]
Costumes
[pic]
Sounds
[pic]
Lesson 1 – Introduction to Animation
Introduction to Animation
Animation is a very fun piece to start with when dealing with Scratch. Evidence of animation was found in early prehistoric cave drawings. When Walt Disney started dealing with animation, great cartoon and movies came alive and today, most kids’ movies and TV shows are animated. Animation takes still pictures differentiated a bit from one another and displays them fast one after the other. This is precisely what we are going to do in the first lesson. We will create a simple animation scene with our sprite.
Before we begin, let’s get our Scratch account
Scratch 2.0 is a web based application. You need nothing except a PC and web browser that supports Java. Don’t worry about it, almost every new PC will run Scratch easily. You can simply open the Scratch web and start creating your project. You can download the file to your PC and reload it in later stages. However, if you want to savor the fantastic possibilities of Scratch 2.0 as a shared environment, you will want to have your Scratch account setup. After you have your Scratch account you can save all your projects on the cloud and have access to them from every other computer. You can “like”, “share” and comment on other people’s projects and people can do so for your project. You can remix a project from another user and enhance it to your liking and you can view the evolutionary tree of your projects. Now let’s simply open your new Scratch account. If you already have a Scratch account you can skip this part and just login.
Enter the site at
[pic]
Up on the top of the screen choose “Join Scratch”.
Follow the instructions below. Choose your own user name and password. Fill in the details the program requests and… welcome home! After completing this you will have a Scratch account.
After you have an account press “sign in” with your new user and password.
We can now start our first lesson.
Let’s try it
Let’s just try it in Scratch.
On the top menu press “create” and you will go into the project window with an empty project.
[pic]
On the top left we have the stage with the default sprite: the Scratch cat. On the right we have the script area. Make sure that you are in the “scripts” tab.
1. Let's give this project a name up on the left. The default will be “Untiteled” So go on and change it to your preferred name. I chose “basic animation”.
Let’s go to the custom tab.
[pic]
In our project we have one sprite that is called sprite1. The sprite has 2 costumes, both of cats. One is called costome1 and the other costume2.
2. Now lets go back to the script tab and start building our small program. We will start by picking our first building block and putting it into the script area.
[pic]
“When [green flag] is clicked” is the main building block that is activated when the user presses the green flag. We can build many scripts in parallel starting with this event. Now let’s hook a few more commands under this block.
3. We will use the following building blocks.
[pic]
“Switch costumes to […]” – This block picks up the costume we want to use from among the available costumes of the sprite. It is found in the “looks” section.
“Forever” – this block repeats whatever we put in it forever. It will stop only when we press the “stop” sign or a stop command is given in the program. Otherwise, it will loop forever. It is found in the “control” section.
“Wait [Sec] sec's” – this will create a pause or delay which will wait for the number of seconds we enter. It is found in the “control” area.
Now lets build the puzzle in the following way:
[pic]
and press the green flag. What happens?
4. You must have noticed that this animation goes very slowly. Can you guess why?
We waited too long between each time the costume is changed. 1 second is too long. Let's change it to 0.5 sec and see what happens. Try changing the delay to different numbers and see the effect.
[pic]
5. Now we have a walking cat, but it does not move. Let's make him really walk. For that we need to understand the basic directions of the sprite.
[pic]
When a sprite is born, its default direction is to the right, so it heads in the 90° direction as the compass above shows. Control of the direction is in the "Motion" section. Try to grab this block, change the value and click on it to see how direction is changing.
6.
[pic]
To make sure we head towards the right in the beginning of the script we will tell him to turn to 90° and then we will tell him to move a few steps each time it changes a costume:
[pic]
Try it and watch him walking. Follow him until he is reaching the end of the screen. What happens?
7. Sprites do not pass the frame of the screen so our nice cat was stuck when reaching the wall. We can add the block:
[pic]
That changes the direction of the sprite as a billiard ball changes its direction when hitting the edge. Try to add this block from the "Motion" section as follows:
[pic]
Try it and see that the sprite indeed changed its direction but…
8. It turned upside down? In Scratch the sprite has three ways it can change its direction. In order to control it we need to enter the sprite in the "sprites" area in the lower left of the screen and press the “i” on the sprite:
9.
[pic]
This will enter the configuration section of the sprite. There we will find this:
[pic]
These are the three rotation stiles:
a. The first on the left says that the sprite will turn right to the direction it points to. This is the default and you have seen the result.
b. The middle one says the sprite will always be horizontal, but from 0-180 it will point straight to the right and the other half it will point to the left (181-359)
c. The right configuration says that the sprite will always look to the right.
Notice that a sprite always has a direction that can be different to the way he looks. That is, the sprite direction may be 238° but configured to show pointing towards 90°.
Setup the sprite to the middle configuration and watch how it fixes our cat.
10. Let's make the movement of the cat a little more interesting. It starts the program pointing to 90° and goes straight from left to right and right to left. What if we start this program while directing it to an angle not so straight? Let's say 45° or 30°? Try to add as follows and watch what happens. I have also changed the waiting time to be 0.2 sec to make it even faster:
[pic]
11. The last step for this lesson is to make it more colorful by adding a background. Let’s go to the background and choose a nice one for our project:
12.
[pic]
Try more
This was an example for simple animation. You can find this demo project here:
lesson 1 – basic animation
More tasks that can be given in this lesson:
1. Change the animation to a flying bird (or any other animal according to your imagination). You can choose new costumes for the sprite in the costumes tab and choose:
[pic]
2. Add another sprite to the project and animate it in parallel.
3. Make the animation change 10 times and then stop.
A few words to the teacher
Scratch was designed to be very intuitive so kids can figure out what to do on a “makes sense” basis. In the first lesson I will detail exactly how to find the way of doing things, yet as long as we progress, you will find the "how to do it" much easier. This is the exact way to teach Scratch. Don't tell them, let them struggle and find out how to do things. By investigating the tool they will better understand it.
When I present this lesson I like to talk about animation in general and about Walt Disney. They learn in this lesson that the animation they see on TV and in the movie are a set of still pictures. I also like to take one kid and move his hands in two positions as if he was flying. They love this kind of demo.
A very important method of teaching is to explain less before you try. I use an example on the main screen, but before hitting the green flag, ask them what they think will happen. This discussion is very important for learning. For instance in the "wait" section I change the number and I ask what will happen. Some say that the sprite will go faster, some say slower. We talk about it a bit and then we try it. This is a very good practice to hold on to all along the way.
Some of the kids may know Scratch before you teach them or are so talented as to be done before you start. I usually let these kids go on and progress on their own but ask them to do it quietly and attract minimum attention. I usually give them challenges to make them busy such as if a kid comes and says, "I am done." I would tell him, "OK, can you add another character that flies around?" or "Can you make a sound every five seconds?" Even if I didn’t teach them how to do that. They will search for the right building block and use it. Don’t be afraid to give them tasks you have not yet explained. As I have emphasized, it is so intuitive that they can find it by themselves.
I also like to give my performing kids who are done fast the mission of going around and helping the ones going slower.
One rule I stress in class is, "If you are done with the defined tasks, you may proceed however you like, as long as you stay only inside Scratch. No internet, Facebook, etc. Only Scratch….”
Lesson 2 – Drawing
Introduction to drawing
The sprites in Scratch have a very important capability. They have a pen. If we tell them to point the pen downwards, everywhere they move they leave a mark. So we can draw by moving the sprites according to our needs. We can change the pen size and pen color. The pen capabilities are in the "Pen" section.
In this lesson we will draw a rectangle, multiple rectangles and a circle. We will make nice shapes of them. By walking through the drawing we will discuss angles, pen attributes and loops. We will also learn to build a new block of our own. Let's get started.
Let’s try it
1. Open and get into your account. Create a new project. We have the Scratch cat. We can get him to be a little smaller so we will focus on the drawing and not the sprite. We can get him smaller in two ways. The first is to manually click the sign and then the sprite a few times. We can also use this block:
[pic]
to set up the size. The Scratch cat is 100% when a new project is born. Try and change the number and see the effect. Note that if you want to activate a specific block, like this one, you don’t need to put it in a script. Just double click on it wherever it is and it will execute. You can go to the “Looks” area, find that block, change the number and double click on it.
2. Let's write a script that draws a rectangle. When we create a new project, the cat sprite turns to the right (90°). We explain how to draw a rectangle by walking and turning like that:
[pic]
I really like taking a kid and verbally commanding him to do those steps (walk two steps, turn right…).
Don’t forget to get the pen down as above.
Now look at this script: we are repeating the same thing over and over. We can use a loop to simplify this script. Loops can be found in the “control area”. Change this code to:
[pic]
Notice I added “clear” to clean the screen each time I start so I start from an empty drawing.
This should be the result so far:
[pic]
3. Now we know how to draw one rectangle. Let's change the pen size and color before we paint it. Try different sizes and different pen colors to see the effect:
[pic]
[pic]
4. Let’s wrap our loop (repeat 4 times) with another loop. The way I like to teach this to kids is by walking them through the thinking process. Each time I ask them what they think will happen, we watch and analyze the results. Here:
What will happen? Guess then try:
[pic]
Nothing really happens, it just repeats the same rectangle over and over 20 times.
5. Now add a small turn of 10° like this. What will happen? Guess then try:
[pic]
Now we get this very nice shape. Stop for a minute and discuss what happened with the kids:
[pic]
Notice that the shape did not complete a full circle. This is a great point to discuss with the kids. What should be changed in order to fill out a nice compete shape.
The answer is that we need to change the "20" in the outer loop to 36. Why? Usually when I do it with kids they just guess. We try the guess until we reach an undestanding. Then I ask them:
a. What if turn was 5°? 20°?
b. What if move 50 steps was "100"?
6. Let's change the color of the pen each time we complete a rectangle. Let's also set the pen size to three. Notice that we used this command in order to change the color. Remember that each color has a representative number:
[pic]
and the new script is:
[pic]
The result (kids love this one…):
[pic]
7. Let's learn a nice trick. In Scratch 2.0 we can build our own blocks. Let's take the part:
[pic]
and turn it into a new block of our own. We will also set it nicely so it will pen down at the beginning and pen up at the end.
Go to the "more blocks" section and choose "new block". You will get this window. Write the name of the new block:
[pic]
Press “OK” and, voila, a new block called “Draw rectangle” is born.
A definition block has been made:
[pic]
to which we can now add commands below. This will be the definition of this new block. Whenever we use it, it will run the commands in the block definition. Notice that it is defined in the script area where we have been when we opened it. I recommend adding them in the background or in one main sprite so you will know where to find all these new block definitions.
We will add the definition like:
[pic]
So we can now use the new block in our script.
8. Let’s rewrite our script with the new Draw rectangle command:
[pic]
It looks much nicer.
Notice that our rectangle knows to draw rectangles only for size 50. In order to make it a smarter block that can draw different sizes of rectangles let’s go to the next step.
9. Lets fix our new "Draw rectangle" block to receive a parameter that will define the size. Go to the block definition in the "More blocks" section.
Right click on in and choose "edit",
[pic]
press the option, then choose "Add number input". Edit the text created to "size". From now on in that block we can use the parameter "size" that will be an input to the block. Like this:
[pic]
10. After drawing a rectangle, how would you draw a circle? Actually you can't draw a circle but you can draw something that looks like a circle. If you go a small step and turn a small angle, you will get a polygon with a lot of sides, i.e., if you will go 1 step forward and turn 1°, repeating it 30 times, you will get a circle. Like this:
11.
[pic]
If it goes too slowly for you, you can go to the menu and select Edit ( turbo mode. This will make the program run as fast as it can except for the delays that you will put in.
You can also make this faster by changing it to repeat 36 times with the steps below:
[pic]
or the resolution if the Scratch result seems the same.
Try more
This was an example for a simple drawing. You can find this demo project here:
Lesson 2 - drawing rectangles
Lesson 2 - drawing a circle
More tasks that can be given in these lessons:
1. Try drawing this:
[pic]
2. Draw your name.
3. Make a new circle block as we did for rectangles.
4. Draw multiple circles like we have done for multiple rectangles:
[pic]
The solution is on the next page. Try thinking before you turn the page.
[pic]
This is the solution to multiple circles.
A Few words to the teacher
While playing with drawing, kids learn a lot about angles and loops. Use a lot of colors and increase pen size to get kids excited. Kids love to see the multiple rectangles or circles with colors changing.
Don’t forget to ask them what they think will happen before you press the green flag. The discussion is very important for learning.
Let the kids investigate more blocks in the "pen" section on their own. Investigation is part of self-learning and Scratch is intuitive enough to let the kids find out stuff by themselves.
For a good explanation, you need to help the kids see from the eyes of the sprite. If the sprite turns, they can imagine themselves turning. Seeing from the eyes of the sprite helps kids understand complex drawings and patterns such as the repetitive rectangle or circles.
You can also try to challenge them to draw triangles. You can even tell them to try to draw a right angle triangle – this will lead them to understand the issue of Pythagoras sentences. I am not elaborating about math learning in this book, but you may think about it and ask yourself about this challenge.
In this lesson we are doing very simple drawings. Scratch can help you draw much more sophisticated patterns. You can do some fractals by using recursion. Again, it is not part of the scope of this book but given to you here as food for thought.
Lesson 3 – The elephant race
Introduction to random numbers
In this lesson we are going to use random numbers in order to create unpredictable behavior. We are going to build a game where two elephants are running and competing against each other. We can only guess who will win the race since we will use numbers that are chosen in real time by the software. It is an important tool to use in order to create games and other unpredictable results.
In this lesson we will use two sprites and we will experience writing an exciting game for the first time. It is fun to see how kids are happy to gamble what elephant will win and the way they cheer their chosen elephant.
Let's try it
Open a new project. Let’s follow the steps below to create our first running elephant.
1. Change the name of the default sprite to "elephant 1". Do this by clicking on sprite1 in the sprite area. You should click on the "i" in the upper left side of the sprite. A dialog box will be opened and let you change the name of the sprite.
2. Go to the costumes tab and choose two new costumes from the library. Chose elephant-a and elephant-b from the animal section.
3. Go to the script tab. We will now initialize the elephant to start. We want to prepare him for the race in several ways:
a. Get him smaller
b. Get him to point to 90°.
c. Put him in the starting position. You may notice that the x-y coordination shows his position. Choose the values shown in this example and we will discuss x-y coordination right after this page.
So this should be the beginning of your script to set the elephant in place:
[pic]
Break: Let's discuss x-y coordination. Every point in the stage can be defined by an X and a Y axis. This is the way the stage is defined:
[pic]
The X axis is the horizontal one and the y axis is the vertical. X runs -240 (leftmost) to 240 (rightmost) and Y is running from -180 (lowermost) to 180 (uppermost). Every point on the stage can be described by two numbers X and Y. The middle will be 0,0 (X=0, Y=0). When we write two numbers with a comma, the first is the X value and the second is the Y. In our example we put the first elephant at -180, 100. Try to see where it goes. Note that when the mouse goes over the stage, the X-Y coordination is always shown on the bottom right of the stage.
4. Until now we started everything with the green flag. Let's start the race when a new event happens. Go to the event section and you will find a few events that can start scripts:
[pic]
That is, when a key is clicked or when the sprite is clicked.
Let’s start the race when the letter "s" is clicked. Add this script to the sprite:
[pic]
Try it. When you press the green flag the elephant will go into position. When you press the "s" key he will start walking. No surprises so far, the elephant is going five steps at a time with a constant predictable pace.
5. Now comes the fun part. Instead of telling the elephant to move five steps at a time, let’s tell him to pick a number between 3-10 each time. Now the elephant will progress with his walk in a pace we can't predict. The way we do it is that we choose from the "Operators" section the block:
[pic]
and we insert the values that we want the script to choose from. The script will now look like this:
[pic]
Try it. You still can't really tell that its pace is not predictable, but you will see it better in the next steps.
6. Let's make the other elephant do things. After setting up the first elephant, we can duplicate the sprite and a new sprite will be created with the same costumes and scripts inside. Right click on elephent-1 in the sprite area and press duplicate. You will have two sprites now that act the same. Go into the new elephant 2 (which was numbered automatically) and see that it has the same script. Since we want it to start from another position on the stage, lets change its X-Y position to X = -190, the same as in the other elephant since we want it to start from the exact horizontal position, and Y=-100 to be on the lower side of the stage.
[pic]
Try it now. Press the green flag and then the "s" key. What do you see?
Now you can see how they are not progressing at the same pace.
7. Let's draw an end line. Go to the Stage 1 backdrop and edit a finish line. It should be very intuitive to do so:
[pic]
8. I want to add a condition that tells the sprites that if they touch a black area, such as the rectangle I draw, to stop the program. I am doing this by adding an "If" statement as follows:
[pic]
This "if" statement asks a question, i.e., is the sprite touching a black color, and if the answer is "yes" it will do whatever is written inside the "if" statement. In this example it will stop all programs. Do this to both sprites and play the game. You will see that the program stops when the first elephant is touching the line and you can see who won.
9. The race is set, but as you can imagine, it is so basic. We can add a lot of things to this project according to our wildest imagination. See the "Try more" section which follows and start playing.
Try More
This was an example for a simple way of using random numbers and writing our first game. You can find this demo project here:
Lesson 3 – The Elephant race
Here are some ideas you can try to investigate, improve, and challenge yourself:
1. You don’t need to write all the projects from Scratch. You can take the example project listed above, press the "see inside" button, and then press the remix button.
[pic]
This will immediately copy the project to your account and you can start from there. Remixing is a big deal in Scratch 2.0 and is a great idea to evolutionize projects. You take a good project someone did and you make it better or suit it to your needs. You can even browse the Remix tree to see how the project evolved from one user to the other and pick your own branch that you would like to continue from.
[pic]
2. Add a nice background.
3. Make the elephant that won say:
[pic]
In order to do so you need to use blocks and methods we have not talked about before. Yet this is the way to learn Scratch: browse the blocks, try, investigate, and fail. This is the right way to go.
4. Add sounds when the race is on. (We did not explain this either. Find out how…)
5. Add a third sprite that when the user presses "s" he calls "ready, set.." and then fire – and only then the race begins.
A Few words to the teacher
In this lesson you may use the fun part of playing. Teaching by playing is one of the most efficient ways to learn. When the elephant race is ready, let the kids bet who will win. After starting, let them cheer their elephant, Let them enjoy the game.
As you have noticed I explain less and less where to find things and blocks and even give challenges I did not explain. This is of key importance while teaching Scratch or any other language. The kids need to use the intuitive advantage of the software and find things on their own. Kids are able to learn most of these materials just by looking around in the software and trying it. Our job as a teacher is to guide them in what to look for.
The classes in this book help a lot in building the structure of the lesson. But don’t worry if your kids start enhancing the games or go on to develop their own ideas. This is just as well. It is good. My rules in class are that:
a. They need to try what I show.
b. They can add variation as they like.
c. They can then do anything they like as long as they stay inside Scratch (and not drafting on Facebook and the others).
.
Lesson 4 – Talking with Scratch
Introduction to data Input and output
Scratch can receive data from the user and use it in the program. The data can be a number or a text. This is an important way to interact with the user. "What is your age?", "What level are you?" and so on. Sprites can output data as well by saying things. In this lesson we will make an interactive program where Scratch asks a question, receives the data from the user and reacts to it. We will see how we can react differently to different data.
The program we will write asks the user his age, then it responds to the question in one of two different ways. If the age is under 10 the program will answer "Hey, you have a long way to go". If above 10 the program will answer "Big kid, huh?"
We will program only a basic conversation, but as you may understand, this conversation can be enhanced to be longer. The important thing is to understand the principle of getting data from the user and using it in the program.
We will also discover the term "variable" for the first time and use it. This is another fundamental part of programming. Variables hold all kinds of data we use and manipulate with our programming.
Let's try it
1. Create a new project and call it "Talk with Scratch".
2. Let's understand how we can input data. Add this script:
[pic]
When you use the "ask and wait" the program will open a window to the user and wait for the user to enter something. When the user writes something and presses "enter", the data he inserted goes into a special variable that holds the answer. A variable is a container of data and this is a special variable called "answer". If you mark it as in the example above, you can see the content of the variable live in the program. Try to see how you can repetitively enter data. Try entering a number, then try to enter a word. See what happens. I wrote "enter something". You can edit the question the sprite will ask. Try to change it to "What’s your name?" and see how it looks.
3. Let's refer to the data given by the user. Let's ask "What is your name?", wait for the answer and use the answer in the sprite answer:
[pic]
The "ask" comes from the "sensing" section. The "say" can be found in the "looks" section.
Remember that you can use the color code to know where the blocks came from.
In this example the program will ask "What is your name" and wait for an answer. You can guess intuitively what will happen. It will say "Hello!", then wait 2 sec and say "I know you are…", wait for another 2 sec and then say the name as it was entered. See that we use the variable "Answer" that holds the answer inside it as the input to the "Say" block.
4. Having it say things step by step does not flow so nicely. We want the sprite to say something like, "Hi Avi" (if Avi is the answer) in a single sentence.
We can use the "join" block to do that.
[pic]
So now the script will look like:
[pic]
We can also insert a "join" inside another "join" to concatenate more than two stings. Like this:
[pic]
and the result looks like this:
[pic]
5. When we enter data, we can either enter text, like a name, or a number, like 12. Scratch knows how to identify what you entered, so if it asks what is your name and you answer 12, Scratch will know you have entered a number and use it as a number. Let's experiment with this. Let's write this script:
[pic]
The script will ask you for your age. The age will be entered into the "answer" variable, and then the sprite will say that your age next year will be… and it calculates the result to be your age +1.
Notice that we did the calculation by using a green operator block from the "Operator" section. This is the way we manipulate numbers. Try this, enter your age and see the result.
Question: “What will happen if we enter text?” The sprite asks us what is our age and we will answer "Avi". Guess the answer and try it. Try to understand what happened.
Scratch needs to calculate the "answer" + 1. If the answer is a number it has no problem doing that. But if the "answer" is "Avi", how can you add 1 to Avi? It does not make sense. Scratch does not fail and it just evaluates any text as the number 0. That is why the answer should be 0+1, that is 1.
6. At this stage when I teach kids, I let them play a bit and invent all kinds of dialogs between the program and the user. Then I come up with a challenge they don’t yet have the tools to answer, but investigating Scratch is always valuable.
I tell them to ask the age of the user. If the answer is less than, let's say 10, the sprite will answer, "Hey, you are pretty young". If it is equal to or above 10 it will answer, "Big guy, hey…". Needless to say, you can adopt this text to your ideas and environment, although the condition depends upon the age given must stay.
In this case they need to handle a condition. I then hint that they should use these blocks but I don’t tell them how. Trying to figure out is a learning catalyzer.
[pic]
Let them think and try for a while. The solution will look like this:
[pic]
7. We can nest an "if" within another "if" to get more than two answers. If we want to answer "Young guy" for ages under 10. Answer "growing up kid" if the answer is between 10 and 19. Answer "Big guy" if the answer is 20 and above. The solution in this case would be:
[pic]
8. We can now build a whole chat. The game will ask for the name, answer, then ask for an age, answer and so goes the chat. This is the place to start imagining and creating.
9.
Try More
This was an example of a simple way of getting input from the user and responses to the data given.
You can find this demo project here:
Lesson 4 – talking with Scratch
More ideas you can apply around this subject:
1. Respond in action, not only text, i.e., ask for a number to clap, and then the sprite will clap the requested amount. You can jump, walk, make sounds or whatever you like.
2. Draw something according to the input. Example: ask for a size and draw a rectangle of this size.
Challenge:
1. Ask for a number and build a polygon with this number of sides.
2. Ask for two inputs, X and Y and then position the sprite at those coordinates. Try to first get the inputs and only then jump to position. Note that you will need to have another variable other than "answer".
A Few words to the teacher
This lesson may bring with it lots of fun and creativity. Yet, this lesson can be very boring…
Teachers may fall into exhorting teaching about conditions and giving the kids exercises using data that is entered and what the result should be trying to complicate or elaborate it in order to test the understanding of the kids.
I highly recommend keeping this fun and making the scenarios funny and relevant. That way you will keep the kids’ attention and learning will get stronger by just doing and building the scenarios.
Code may start getting complicated at this stage as we increase the dialogs so we need to teach them step by step so they won’t be afraid of a long complex program. If a kid builds his own scenario he will be in control and not be frightened by a long code. A kid seeing such a long script right at the beginning can get scared and not even try understanding what is written.
This is why every kid should build this step after step.
Lesson 5 – Mastering X-Y coordination
Introduction to X-Y coordinates
In this lesson we are going to focus on the stage X-Y location. Our stage is a 2D (two dimensional) stage, and as such, it has two axes that can define any point on the stage. The X axis is the horizontal axis and the Y axis is the vertical axis. We can import an XY background to help by going to the stage background and choosing a new background from the backdrop library ( other ( xy-grid. Here is how it looks after we have set up this backdrop:
[pic]
The X scale goes from -240 on the left to +240 on the right. The Y goes from -180 on the bottom to +180 on the top. Now every point on the stage can get the values of X and Y to determine its exact position. It is easy to write right these two points in brackets where the first number shows the X value and the second shows the Y value, e.g., in the next screenshot (0,0), that is X=0, Y=0, point A in the middle of the screen.
[pic]
Point B would be (100,100) – That is X=100 and Y=100
Point C would be (-200, 100) – That is X= -200 and Y = 100
Point D would be (200, -100)
And point E would be (100, 50)
While moving the mouse over the stage you can see the mouse coordinate position on the bottom left of the stage (when you are in coding mode).
Let's try it
1. Create a new project and call it "coordinates".
2. Set the stage to have the xy-grid coordinates background. Go to the backdrop area, choose Backdrop tab, get a new backdrop by choosing a backdrop from the library: go to "Others" and find the xy-grid there.
3. Let’s get the cat in the middle of the stage, point (0,0), clean the screen of any drawings, set the "pen down" and set the size of the pen to be 5:
[pic]
We are set to start.
4. Let’s walk around by moving the sprite between different points. Notice that we use a "glide" block that will move the sprite to the defined point in the defined time. Try it and see how he glides between the points and paints as he goes:
[pic]
5. Change it all to be the same by using the "go to" block. What is the difference?
[pic]
It did the same thing but very fast. If you press the green flag and see no change it's because it cleared everything and painted it again so fast that it seems nothing happened. Jump to different points to see the effect.
6. Here is a cool thing to try and do. Afterwards you have the touch and feel of coordinates. Write your name using "pen up" and "pen down" and moving on the screen. Here is my name. You can browse here and look inside this project:
[pic]
and the result is:
[pic]
Try more
This was an example of a simple way to navigate on the stage using coordinates.
You can find this demo project here:
Lesson 5 – x-y coordinates
More ideas you can do around this subject:
3. Draw geometric shapes like rectangles, triangles or freehand shapes.
4. Draw a dashed line.
5. Repeat forever to Get X and Y as inputs and jump/draw to that point.
A Few words to the teacher
I must admit that this lesson is less fun than the others but it is important to understand and use coordinates for any purpose. In order to make it enjoyable, writing the name challenge is the best. Kids, as all people, like to hear and see the sound and look of their name, so use that.
Lesson 6 – The paint program
Introduction to stamping
We are going to build a paint program. We saw how lines are drawn when the pen goes down. Today we will see how to stamp a sprite on the stage. That means that when we give a "stamp" block to a sprite in a script, it will stamp itself on the stage and leave his image constantly there. We will make a sprite in the shape of a dot so it will constantly stamp itself on the stage, making ourselves a paint program.
Let's try it
1. Create a project and call it "paint".
2. Let`s make the sprite become a dot.
3. Go to the main cat sprite costumes. Click on the first costume. You can see you have an editing tool:
[pic]
4. This is a very basic editing tool that you can change, delete or create from your own image. Try to click on the cat and delete it (with the delete button on the keyboard). Then draw a small circle in the center and fill it with black color. Change the name of the sprite to "Black" (on the upper left where it now says “cat-a”).
[pic]
5. By right clicking the black custom and press "duplicate", create more costumes with red, green or whatever you like:
[pic]
6. Let's build a script that stamps the sprite all the time:
[pic]
Try it. It will stamp the dot costume but will not stop doing it.
7. It is annoying so lets add a condition to stamp only when the mouse is clicked.
[pic]
8. We want to be able to change colors. Since we already prepared costumes with different colors, we just need a method to switch costumes. There are a few ways to do that. Let's make it by pressing keys. If an "R" key is pressed we will move to Red, "B" for blue and so on. Add the following script:
And here is what I draw:
[pic]
9. Working with this drawing method creates flickering lines since when we move fast there are gaps between stamps. Let's move to a different method by drawing lines to the point we move. Change the scripts to draw lines with "pen down":
[pic]
Notice that I changed the scripts to fit the new method. No "stamp" is needed. We added a third script at the bottom to "pen down" when the mouse is clicked and "pen up" elsewhere.
Try more
This was an example of a program that is painting. You will see that the kids like to draw things when the program is working. It is much more than just using a paint program that was downloaded and the kids enjoy the creation.
Here is the link to the sample program:
Lesson 6 - Paint
More ideas you can apply around this subject:
1. Add buttons that change color or size
2. Add eraser function. Hint: you can stamp a sprite with a white big rectangle.
3. Stamp specific shapes like flowers or trees when pressing a specific button.
A few words to the teacher
In this lesson the kids can feel how it is easy to create programs that imitate very famous programs like "paint". You should emphasize this to encourage them and show them that they can grow and do big things on their own. Give them the time to enjoy the result and let them draw. Even print the screen and show it to all.
In this lesson we used two methods to paint. The first was by stamping dots and the second by constantly drawing a line. The first method did not give good results as the line was broken by the dots. I could have showed you the line method in the beginning and you can try this in your classes. But it is good to go over the process of implementing one method, understand its faults and try another method.
Let them think and try to solve the problems with the dots by themselves. This is a learning process. Guide them slowly to the solution.
Scratch, like any other software language, can do the same things in a different ways. Talk about this with the children and understand that you should expect a lot of solutions to the same challenge.
Lesson 7 – The labyrinth– responding to colors
Introduction to the labyrinth
In this lesson we will build a labyrinth game where the sprite needs to go from the entrance of the labyrinth to the exit without touching the walls. This is a cute game and by making it we will learn a few important principles. The first is reacting to colors on the stage. When the sprite will touch a wall which has a specific color it will react to this event and stop the game. The second principle will be sending a message between sprites.
Let's try it
1. Create a project and call it "Labyrinth"
2. Go to the stage section and click on “backdrop1”. This is the default backdrop. Now go to backdrop tab and choose “backdrop1”. You can see it's all white. We can edit it with the drawing tools which are very intuitive to use.
[pic]
3. Try to edit the backdrop to look like this:
[pic]
As you can see, it does not need to be perfectly shaped. I have built it from rectangles and filled them. All in black color.
4. We will use the cat as the sprite that will be guided into the labyrinth. Let's make the cat small enough to enter the labyrinth. We will guide the cat with arrows. Note that the coordinates I have entered fit the labyrinth I drew, you will need to find the right coordinates that fits your drawing. Here is the script to do so:
[pic]
Notice that we can navigate the cat all around the stage, over black lines and nothing will happen.
5. We want the cat to jump to the start position whenever it touches the color black. In order to do so we will add a forever loop that always checks for this event as follows. Notice that in order to set this sensor to a specific color, in our case black, you need to touch the little square of the color and after that touch anywhere on the screen on the color you like. For setting this to black I touched the square and then touched the black color of the labyrinth.
[pic]
6. To make the game more interesting lets add a new sprite at the end of the labyrinth. When the cat reaches this sprite it will say something, i.e."Wheepee! I have done it…".
I have added another sprite as follows :
[pic]
and added the script in the cat scripts:
[pic]
7. The ending that we have done is nice, but I want us to have a really cool ending. When it reaches the muffin a dancer will appear and there will be music. I will add another sprite that will be the dancer. Find the dancer I have chosen, it has 4 costumes in it.
[pic]
8. We want this sprite to hide itself when we start the program, but we want it to appear and dance when we reach the muffin. We will use messages. Sprites can send messages for other sprites to listen and react to. In the cat sprite we will send a message by adding the "broadcast" block.
When adding a "broadcast" board you can add a new message or use an existing one. Touch the small black triangle in the block, choose "new message" and define a message called "start dancing".
[pic]
9. In the dancer sprite script area, add the following scripts. The script on the left makes sure to hide the sprite when the program starts. The script on the right waits for the message "start dancing". When that happens she will change the costumes a few times so it appears like dancing. At the end the sprite will hide itself and stop all actions. Game over.
[pic]
Try More
This was an example of a Labyrinth program which uses color sensing and also use messages between sprites to activate one another. The sample project can be found here:
Lesson 7 - labyrinth
Some more ideas you can pursue around this subject:
1. Add bad points every time you fail. After 5 tries… Game over.
2. Add music when the dancer dances.
3. Add time. How much time did it take you to get to the muffin? Show the clock counting and stopping when reaching the goal.
A Few words to the teacher
The emphasis in this lesson should be on the principle of sensing a color and the principle of messaging.
The sensing is important for any game that reacts to the stage colors. It opens great possibilities to create reaction to the stage. You can also discuss different kinds of events that the sprites can react to like bumping into other sprites or clicking on a sprite.
The principle of messaging is important for interactive games with multiple players that react to one another. This is a powerful tool to be used in all kinds of games.
Don’t forget to let the kids try to solve challenges by themselves.
Lesson 8 – A little touch of math and algorithms.
Introduction to math thinking
You can use Scratch and other kid programming languages to teach you programming. Yet, you can leverage the learning to a higher scale and use Scratch to teach other professions such as math, arts, history or anything you like. It may serve as a tool to be used by all other professions. In this lesson we will use Scratch to demonstrate mathematical thinking. We will first use Scratch to serve us as a computing machine to solve a riddle. After that we will see how math solves the same problem much easier.
The background story:
The legend tells the story of Carl Friedrich Gauss, later a distinguished mathematician, who set as a young kid in class when the teacher decided to punish the entire class. The punishment was to calculate 1 + 2 + 3 + 4 ... and so until 100. The teacher was sure that it would take the kids a lot of time to solve and even if they completed the task, something would go wrong and they would need to re-compute everything. He expected a little rest until the children reached the result. To his disappointment, the young Gauss raised his hand after about a minute and gave the answer: 5050.
Let's use Scratch to help us quickly calculate 1+2+3+4… +100. Even until 1000 or even 10,000,000…
It’s a computer, It works fast so let it work for us.
1. Open a new project and call it, let’s say, "calculate".
2. Create 2 variables in the "data" section. One will be "current number" which will hold the number to add (starting with 1, then 2 and so on). The second will be the summary that accumulates when we add 1+2+3… At the end the summary will hold the final result.
[pic]
3. We want to know how many loops to run. 1+2+3+4…. When? That we will ask the user. As we saw earlier you can ask the user a question and the answer will go to a variable called "answer". Let’s start building the script.
[pic]
4. Now we have inside "answer" the number that the user was asked to calculate the series to. We want to repeat the calculation 1+2+3… the number of times the user asked. Before we do that we need to set the starting values of the “current number" and the "summary", like this:
[pic]
5. Inside the "repeat", we want to do the calculation and on each round to add to the summary the current number. This is how it will look:
[pic]
6. Notice that in order to set the "summary" to be "summary" + "current count", we used a green operator "+". Operators on the green section are used for all kind of calculation, like adding, subtracting, multiplying and all kind of other functions.
7. We are almost done. We just need to let the Cat sprite declare the result at the end. If you start the program and enter the value 100, as in the story, it will give the result very fast, in a blink of an eye. But then try 100,000 or 1,000,000…
[pic]
Make sure to mark the checkbox near the variables in the data section so you can see the program progressing.
[pic]
8. The method we did so far describes the power of computers to run large calculations in a relatively short period of time. Yet, to calculate to a million it takes the computer a few seconds. Imagine how much time it would have taken the kids in the Gauss class.
Gauss thought differently. He did not calculate – he thought Mathematics… Here is how the story continues:
The boy imagined the problem as if they were stones on the sea shore. In his imagination he arranged triangular shaped stones, as follows with the filled blue circles:
[pic]
He arranged them as in the riddle, 1, then 2 and so on. In this example it is 5. Now he arranged the same triangle stones just the opposite, as drawn with the white circles. You can see that he got a rectangle where one side is 5 and a second side 6. If he would have built it to 10, then it would have been 10 and 11 and in the general case N, it would become a rectangle of N and N+1. Now to calculate how many stones are there in the rectangle is easy: 5x6 or in the general case N x (N+1). But we have double the amount of stones, we just need to know how many solid blue stones we have, so we just need to divide by 2. So we got a formula to calculate:
1+2+3+…+N = N x (N+1) / 2.
9. Let’s do that in Scratch. Our first cat sprite calculated the riddle by adding the numbers. We will add another sprite that will get the same data and calculate with the formula. Let's see who gets the answer faster. Add a message “start calculate” that is being sent by the first sprite:
[pic]
Create another sprite that receives the message and calculate with the formula. In the new sprite script area write this script:
[pic]
Here are my two sprites captured. The second sprite (the duck) calculates with the formula and gives the result immediately while the cat that is adding the numbers keeps on thinking. At the end he will output the same result.
[pic]
Try More
This was an example of a math issue that was handled through Scratch.
The sample program can be found here:
Lesson 8 - math
More ideas you can use with this subject:
1. Make a program that calculates the roots of a squared equation.
2. Build up Fibonacci numbers (0,1,1,2,3,5,8…)
A few words to the teacher
Math is a huge and wonderful world that can be investigated by using Scratch. In the additional information you can find links to more and more ideas in math.
This is a great opportunity to turn math subjects, which can be boring and not appealing, into a wonderful world of play. A story told about math, as in this chapter, can make a formula come to life with a story behind it.
This chapter was just a taste of it. All computer science is based on math. The message should be:
a. Don’t be afraid of math
b. It's even cool
c. You can make very nice things in programming using math thinking.
Scratch 2.0 – Introduction to great cool possibilities in the new Scratch environment.
Scratch 2.0 was introduced in 2013. Until Scratch 2.0, Scratch was evolved until reaching Scratch 1.4.
The new environment of Scratch 2.0 provides several capabilities that enhance the possibilities of Scratch. Using Scratch 2.0 enables far more options and possibilities by adding main new concepts. In this chapter we follow the new capabilities and understand how to leverage them to our needs.
This will be a basic overview.
Originally, Scratch 1.4 was downloadable offline software (also free). While the project was created on the child's computer, it could be uploaded to the online community directly from Scratch 1.4.
Scratch 2.0 is a web based tool. This means that unlike Scratch 1.4 you don’t need to install anything. You just open the site and you can work immediately, even without having a Scratch account. Yet you want to have a Scratch account in order to be able to save and publish your work.
You can always open an old 1.4 projects in Scratch 2.0 from a file in your computer and you can also save your projects to a file. Programs that were made in Scratch 2.0 will simply not work with Scratch 1.4 but the opposite will work: projects written in 1.4 will work with Scratch 2.0.
Here is what Scratch 1.4 looks like:
[pic]
And here is what Scratch 2.0 looks like:
[pic]
The fact that it is web based means that you need an internet connection to work on Scratch 2.0 where in Scratch 1.4 you could have worked offline.
So what can you do in Scratch 2.0?
This section will cover in general features and capabilities of Scratch 2.0, but will not get into deep explanations and demonstration. It is out of the scope of this book. Yet, you are welcome to sign up for free to TBD and get endless information about Scratch 2.0 and other great kid technology stuff.
1. Sharing your project with the world is almost automatic. First, your project will automatically be saved as you work on it, if you're logged in, and you can view your project from any computer in the world. Once you press the "publish" button, everyone can see your project and look inside the code.
2. In the new paint editor, when you are editing a sprite costume, you can use vector graphics so that images can scale to different sizes without getting jagged. With bitmap, as in Scratch 1.4, it is difficult to edit a sprite image while in vector graphic you can move and break the shape.
3. On the bottom of the screen you have a “Backpack”. The Backpack lets you copy and move sprites, costumes, backdrops, and scripts from any project to another. If you're logged in, you can open your Backpack inside any project. This is a wonderful tool to drag stuff from project to project, or between sprites and reuse elements between them.
4. You can use the webcam on your computer to interact with projects by moving your hands or body. It is very interactive and kids enjoy this quite a lot.
5. You can now make your own programming blocks as we have seen in Lesson 2. This is equal to functions in other programming languages. You can also call from a function to itself. This is very strong when creating recursion but beyond the scope of this book.
6. Use clone blocks in your scripts to make copies of sprites. This is a powerful tool that can be used in amazing projects, but, again, beyond the scope of this book
7. Store numbers in cloud variables to create surveys and other projects. When marking a variable as a cloud variable, you can create projects that can be opened in parallel by a few other users and proceed to cooperate with them.
8. You and everybody can see your working directory. You have a main all projects, a sub directory of shared projects and another sub directory of unshared projects. You can also create studios and send a link to the studios for everyone to share.
9. On the home page, you can see what others have shared recently and scroll to see many more projects.
10. When viewing a project, click "see inside" to see how it works, and change and experiment with the scripts.
11. Inside any project, click "Remix" to save your own version and make changes. When you remix, a project is immediately created in your area and you can improve the project from that point on. But more than that, you have a way to see the evolution tree that shows from whom you remixed and who remixed your project. This is a very strong sharing tool.
12. After you share it, the project page will highlight the original creators and links to their projects.
13. Click your username or icon to go to your Profile page, where you can feature one of your projects and tell others what you're working on.
14. People can post comments on your Profile page and "follow" your Scratch account to see updates.
The Scratch guys at MIT are improving the tool all the time and will release new features in the future. It’s great to track the Scratch site for news. They have plenty of tips and tutorials out there as well.
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related searches
- village of rosemont il government
- rosemont il hotels map
- cook county il job opportunities
- rosemont il convention center
- rosemont il municipal code
- il school report cards
- il report card
- il nurse aide registry
- johnson county il recording fees
- university of il springfield il
- rosemont il events calendar
- co signer vs co borrower