[MUSIC PLAYING]
BRIAN YU: Welcome back, everyone, to an introduction
to programming with Scratch.
And last time, we introduced the world of Scratch--
introducing the stage and the sprites that can live on that stage.
And saw how we could change the way the sprites
looked by giving them costumes, and giving them some sounds,
and also add some backdrops to our stage to make
it look a little bit more interesting.
But everything we were doing last time had to be done manually by ourselves--
if we wanted to move the sprite, I had to change the x and y values and drag
the sprite around to a different position, for example--
if I wanted to change the costume, I had to click on a different costume
that I wanted to do.
This time we're going to start programming our Scratch projects,
adding some code so that we can let that code run
and manipulate what happens inside of our Scratch projects as well.
So let's start to take a look at how we might be able to do that by opening up
a new blank Scratch project.
And when we do so, we'll see the stage--
which is pure white by default--
and the default Scratch Cat that's here as well.
Now, remember from last time, if I wanted to move the Scratch Cat,
I had two ways of doing it.
One was to click and drag on the cat and move it around the stage
to wherever I want the Scratch Cat to be--
or secondly, I could use these x and y values down here.
I could change the x value to 0, and the y value to 0
for example to perfectly center the cat inside of the stage.
But this time, we're going to start to introduce these blocks that
have been living on this left side of our Scratch window for some time now,
but we haven't really done very much with just yet.
And each of these blocks is going to perform
some tasks, some action that's happening on the stage of our Scratch program--
and we're going to start to call these blocks functions.
A function, in the context of Scratch, is just
some block that performs some task.
And we might look at this very first block, for example,
which just says Move 10 Steps--
and that is a block which, as you might guess,
has the effect of moving the cat 10 steps.
And so, let's give it a try-- how could we use that block?
Well, if I want to use a block as part of my project,
I'm going to start by taking that block and dragging it
into the Code Editor in the center part of the Scratch interface.
So on the left hand side is, really, just this library
where all of the blocks live to begin with,
but if I want to use a block in my project--
I'm going to take the Move 10 Steps block,
and drag it out into the main part of the Scratch interface
and just drop it off.
And so now, I've added my first block of code, my first function,
into my Scratch project--
and to run it, I can just click on it.
So watch what happens when I click on the Move 10 Steps--
notice that right now the Scratch Cat is right in the middle of the stage,
but as soon as I click the button the cat moves.
Just a little bit, you'll notice it moves slightly to the right,
and you'll notice too that the position of the cat changed.
Originally it was at 0, 0, now x is 10 and y
is 0-- we've moved the Scratch Cat a little bit.
And if I click it again, I can keep moving that cat--
and every time I click it, the cat moves 10 steps to the right.
Notice too that in this Move 10 Steps block there's a bit of an empty gap
here where we filled in the number 10, this
is what we can call an input to a function.
Functions are allowed to take inputs, information
that those function use in order to decide
how it is that they're going to behave.
And the input that this function takes is a number
indicating how many steps we would like to move-- so in this case,
the input is 10, meaning I would like to move 10 steps, but I could change that.
I'll drag the cat back out to give it a little more space to move,
but I could change this input, for example, to 30.
And now, when I click on this block, the cat moves further.
You'll notice every time I click on it, the cat's
moving 30 steps instead of 10 steps.
So I can control, based on this input, how far the cat's going to move.
And if I make it negative-- say negative 20--
now every time I click on the cat, the cat's going to move backwards.
So you can decide, based on what number you write here,
in what direction that cat is going to move.
So this is just one block, one function that we can use inside of our Scratch
project, but there are others as well.
Here's one that, it says Turn 15 Degrees to the Right--
Turn to the Right, or Clockwise 15 Degrees.
So if I want to use that one, let me try dragging that out
into my Block Editor--
I now have two blocks the move 30 steps one, and the turn 15 degrees
to the right one.
And if I click this one, the Turn block, you'll notice the Scratch Cat turns--
every time I click on it, it rotates, changes direction by 15 degrees,
and I can keep clicking on it turning it little by little
until we get back to the original 90 degrees.
So now I have two different blocks, one block that causes the cat to move,
and one block that causes the cat to rotate--
and it turns out I can combine these blocks together.
Often when you're writing programs it's not just
going to be one instruction that you want your program to follow,
but it's going to be some sequence of instructions
that you want your code to follow.
And so, these blocks can snap together, watch what happens--
if I take this Turn 15 Degrees block, and I drag it close to the Move 30
Steps block--
you'll notice that it starts to highlight,
and then when I release my cursor, the block just snaps into place.
These few blocks are now connected to each other inside of a stack which
we can call a script, and now these two blocks together
will run together-- when we run at this stack of blocks,
it's going to run from top to bottom running the first block, which
is Move 30 Steps, and then the second block, which
is Turn to the Right 15 Degrees.
So when I click on it, watch what happens--
the cat moves 30 steps, but it also turns by 15 degrees.
And I can click it again, and that'll happen again--
and if I keep clicking it, now you'll see we've
got this cat moving in a nice circle.
It's moving forward and it's rotating every time,
and I'm doing so by every time I click on this stack running
both of these blocks of our code.
And so by combining together these various different blocks,
we have the ability to create more interesting programs just by deciding
in what sequence-- top to bottom--
we would like for these blocks to ultimately run in.
And there are all sorts of other different motion blocks
that we can use-- notice that the Scratch blocks are all
organized into categories, and those categories are color coded.
And all of these first set of blue blocks,
they're all related to motion-- the movement of the cat.
So there's one block called go to random position-- that one looks fun,
I'll try it.
And now, every time I click on this block, the cat
just moves to a different random position every time.
And maybe that's interesting, but maybe I
don't really want the go to a random position block as part of my program.
So if ever you decide, you know what?
I have a block and I really don't want it--
there are a couple of ways to delete a block in Scratch.
One way is you can Control-click, or right-click on the block,
and you can just click Delete--
that's one way.
The other way is I can take the block, and just drag it off to the left,
put it back into the Library--
and then when I release, the block goes away there as well.
So using this ability to now move our sprites around
just by writing a little bit of code, by putting some blocks together--
let's now try and create a program that does something.
I'm going to use a different sprite, let's not use the cat--
I'll go ahead and delete the cat by pressing the Trashcan
icon next to the cat.
But I'll choose a new sprite, let's go to animals--
so I have a few different options, and I think I
like the hedgehog-- we'll go ahead and use the hedgehog.
And what I want for the hedgehog to do is just walk around the entire stage,
to walk in a rectangle, effectively.
And so, let's assemble together some blocks
to let the hedgehog do just that.
I want the hedgehog to start in the upper left portion of the stage,
and so that's about this x value and about that y value--
and I can be even more precise.
You'll notice that the Go To block, which
is a block that just goes to a particular position,
will def by default include the values for wherever the sprite is currently.
So right now it's negative 168 and 120--
I'm going to change this slightly, negative 180
just to make the number a little cleaner--
but now this block will move this hedgehog
to the upper left portion of the stage.
And now if I wanted to go to the upper right portion of the stage,
I'll use the Go To block again.
And remember that, to control the left or right position of any given sprite,
I can change the x value.
The x value controls whether it's to the left or to the right--
negative means to the left, positive will mean to the right.
So we'll go ahead and change it to positive 180 and then y equals 120.
So it starts with the upper left, and then goes to the upper right,
and I'll add one more after that.
And I want to move it now to the lower right--
I want to sort of make a rectangle all around the stage--
in the lower right, well, that's going to be a positive x value--
so we'll do positive 180.
But now a negative y value-- y control is how far up or down the hedgehog
is going to move.
And I'll do one more with negative for both-- negative 180, negative 120.
That's going to be the bottom left because the x is very negative,
and the y is very negative.
And so what I hope this will do is cause the hedgehog
to just move in a rectangle, go to all four corners of the stage.
So I'll try it, I'll go ahead and click on this block and see what happens.
All right, it didn't do exactly what I expected for it to do.
The hedgehog just jumped immediately to the lower left,
even though the lower left one is this last instruction here--
it seems to have skipped these two in the middle that
tell it to go to the upper right and then to the lower right.
So, what's going on?
Well, it turns out that when a program is running,
the computer can run our programs very, very, very quickly.
So even though our program was going through each of these four lines one
at a time, it happened so quickly-- it went to one location,
then a second location, then a third location, then a fourth location--
that we, the human looking at this project, only
ever saw the final location.
We missed all three of those locations that were in between.
And so sometimes, if I want to be able to see what's
actually happening in a project, I need to tell
Scratch to slow down a little bit.
Don't just immediately go to a particular position,
but take some time in getting there.
And Scratch's word for this is to glide, and so what you'll notice is that--
in addition to just the Go To block that immediately jumps to a particular
location, I have another motion block called Glide--
and this one takes three different inputs.
This one by default says Glide 1 second to this x value and that y value--
and I can use that to say, take some amount of time
to go to a particular position, and let's try that out.
I'll head over back to my Block Editor, and I no longer
want these bottom three blocks--
I'd like my starting position, but these other three I'm
going to need to change.
So I'll take them, drag them over into the Block Library to delete them,
and let me now bring out a Glide block.
Let's take one second to glide to x equals 180, y equals 120--
both positive-- that's going to be in the upper right portion of my stage.
Let's take one more second to go to positive 180 for x, and negative 120
for y-- that's to the right and down, so the bottom right portion of the stage.
And let's take one more second to glide to negative 180,
negative 120, which as you can see here where the hedgehog is now,
that's the lower left corner of the stage.
And if ever you're confused about what those numbers mean and where you are,
you can just drag the hedgehog to the location where you want it to be--
and you'll be able to see what the x and y values for that
are actually going to be.
So now let's try to run the script--
I can do that, again, just by clicking on the script I want to run
and it will run them in sequence.
We start in one corner, and we work our way in a rectangle back to the other
corner-- and if I wanted to end up back at the starting point,
I can add one more Glide, and let's glide back to negative 180 and positive
120-- that's moving up--
and so now when I click on the hedgehog it moves in a rectangle
all around the stage.
And so we've been writing programs now just
by putting these blocks in sequence, deciding what we want our sprite to do,
and then clicking on those blocks to run them and to see our project in action.
And now at this point our project starting
to get a little more complicated, and if I come back to this later,
I might not remember exactly what I was trying to do with these blocks.
I might not remember what all these numbers represent,
and so Scratch gives you the ability to leave comments on your project--
just little sentences, short descriptions
of what it is you were thinking, and that's helpful for two reasons.
It's helpful, number one, if you come back to your project a little bit
later and might not remember exactly what you were thinking--
you can use it as a reminder.
And it's also helpful if someone else is reading your project--
they're looking at the blocks that you used and they want to understand why
did you create the project this way--
you can use comments to explain as well.
I can add a comment just by Right-clicking or Control-clicking
on my stack, and I'll add a comment.
And here in my comment window I'll just say these blocks
move the sprite in a rectangle--
this doesn't affect how the program actually runs,
it's just a little comment that I can collapse the offers a reminder--
some text that you can read a little bit later
to understand what exactly was going on.
So that then is what we can do with motion blocks,
and there are other motion blocks too for changing
what direction the sprite happens to be pointing in,
or moving only in the x, or only in the y direction.
And you can explore some of those options
for what you can do with motion blocks, but let's now
take a look at some of the other categories of blocks
that we have access to as well.
I'll go now to the Looks section--
notice that these are in a different color for a different category--
and here, let me drag out this Say Hello block which looks interesting.
I'll drag it out--
and I'm not going to use these motion blocks anymore, so I'll get rid of them
just by dragging them away--
so now I just have this one Say Hello block.
And let me move the hedgehog to the center
just so we can see it a little more easily-- we'll move it to x equals 0
and y equals 0.
If I click on Say Hello, watch what happens--
a little speech bubble appears next to the hedgehog
and the hedgehog is saying hello.
If I want it to say multiple things, I could stack multiple of these blocks
together-- let's say hello and then say goodbye, for example,
and see what happens--
I'll click on it now, I'll click on it again.
Notice that, again, we seem to have run into a similar bug,
a bug-- some problem with our program that we're going to need to fix.
I wanted for my program to first say hello and then say goodbye,
but every time I click on it, it's just saying goodbye.
And the reason is exactly the same thing that we
saw a moment ago with the hedgehog moving around the stage--
it's that Scratch's running through these blocks
so quickly that we don't get time to see the hello,
we just immediately see the goodbye.
So if we want to see the hello for some time,
we're going to need to tell Scratch to stay there for some number of seconds
before moving on to something else--
and there's a block, fortunately, that will
do that for us, which is this one here.
Say Hello for 2 Seconds will have the effect
of saying hello, but rather than immediately move on to the next block,
it'll stay there for some amount of time that
will give us a chance to read what it is that the hedgehog is actually saying.
So let me delete these blocks dragging them off into the editor,
and replace it with Say Hello for 2 Seconds.
And then if I want another one, I'll drag another block out--
this one will be Say Goodbye for 2 Seconds,
these are stacked on top of each other.
So now, when I click on these blocks, the hedgehog says hello,
and then the hedgehog says goodbye for two seconds as well.
So we've been able to fix the bug that we've been able to create here.
So now, Looks can affect-- not just what the character is saying,
you can get a speech bubble to appear, you
can get a thought bubble to appear with the Think blocks
instead of with the Say blocks, but Looks also
have to do with the costume for a sprite.
Remember that last time we explored costumes and sprites,
and how we could change the different costumes that a sprite might have.
We did that before just by manually clicking on which costume
we want the sprite to take on--
now, we can start to program it using blocks
to decide what's going to happen in our project,
and when our sprites are going to change their costumes.
So let's try a different character, I'm going
to delete my hedgehog sprite by clicking that Trash icon,
and let's create a new sprite.
Go into Animals, and let's choose the bear this time.
And I'm curious as to what costumes the bear has, so I can click on the bear.
I go into the Costumes tab and I see that the bear has
two costumes-- there's one called Bear A that's just the bear as it
is right now, and there's also Bear B where
the bear is standing up a little bit.
So we got Bear A and Bear B, and I can toggle between them in the Costumes tab
to decide what costume the character will take on, but I can program this
as well by assembling some blocks together.
So let me start with a block called Switch Costume to.
Let's start with costume bear A, with the bear
normally the way that it is right now, and let's give it a starting position.
When I start, I would like for it to go to let's say, x equals--
negative 131's OK, let's go negative 120 and negative 50,
just to use some cleaner numbers.
And that's going to be the starting position and the starting
costume for the bear-- every time we click on this script,
it's going to switch to this costume, it's going to move to this location.
But now what I'd like for it to do is I want the bear to walk across the stage,
and when it gets to the other side of the stage,
the bear is going to stand up--
that's maybe what I'd like for the bear to do,
and so let's do that in two steps.
First, I want the bear to walk across the stage,
and then I want the bear to stand up.
Walking across the stage?
That sounds like motion--
so it's going to be in the Motion section of my blocks.
And I'll use this block, we've seen it before,
let's take 2 seconds to glide 2 x equals 120 and y equals negative 50.
So it's going to-- the y is not changing, it's not going up or down--
the only thing that's changing is the x, we're
moving to the right along the stage.
And after you glide there, after you take two seconds to glide there,
now I want it to stand up--
that's going to be Looks, it's what it looks like--
what costume it's taking on--
and here let's go ahead and switch the costume to Bear B, so we'll try it now.
I'll click on this script, and we start on the left-- the bear walks across,
and when it gets to the right side of the stage, it stands up.
And I can click it again, everything will
reset because if we go back to costume A, we go back to the left--
and every time I click it, the bear goes to one side,
and then it stands up at the end of that.
So we can combine Motion and Looks blocks
to start to create stories just by using these sprites
and changing where they are and what costumes they're taking on.
And we can make our stories more interesting
by adding some backdrops to our stage as well,
so let's add a couple of backdrops where we might want for our bear
to be walking through, for example.
So I'll go ahead and choose a new backdrop,
and I think I'll choose the forest--
I'll have the bear walking through the forest.
So that's one possible backdrop of the bear could be in--
I want to pick another one, though, just have a couple of options
that I can work with.
So I'll go back to the bottom right, choose a new backdrop,
and this time I would like--
I'll scroll down near to the bottom.
There is this one, which is called Woods and Bench, which
I'll go ahead and click on as well.
And so now I have the bear in the woods where there's a bench as well.
So I've got these various different backdrops
that I now have as part of my project, and now I'd
like to construct a story that involves the bear moving
through these various different backdrops--
and so let's try and build this story one piece at a time
I want the story to start in the forest, so I'll get rid of these blocks
for now-- we can add them back later--
but there's a block here called Switch Backdrop To, and Switch Backdrop
To will let me choose what backdrop I want the story to have.
So let's start in the forest--
I'm going to choose the backdrop called Forest,
that's where I want the story to begin.
And I want the bear to begin off to the left, so I can move it to where I want,
and I can look at the x and y values to see about what the x and y values
should be, and I'm going to have it go to let's say
negative 120 and negative 50 again--
so just a choice of x and y value.
Now when I click on this block, the bear goes to the forest,
and it goes to a particular location.
And I want for it to also not be standing up--
and so that's its costume.
So we're going to switch its costume to Bear A,
and these all happened so quickly that it doesn't really matter
what order these three blocks are in.
But it is still going to run one at a time--
it just happens so quickly that it looks like everything's just happening all
at once-- where we go to the forest, we go to a particular location,
we switch the costume to Bear A. And now what I want is for the bear to walk off
the stage in this forest, and enter the other backdrop that we had--
the woods with the bench there as well.
And so I want it to walk--
to do that, I can use the Glide block that we saw before.
So let me have the bear take maybe 3 seconds to glide--
I don't want the y value to change, it's just going to walk left and right--
but the x value, I want it to walk off the stage,
so I'm going to make this a big value.
Something like 300 just to try and get it close to the edge of the screen--
and after it walks off stage, now I want to switch the backdrop.
So I'm going to go back to Looks, let's switch the backdrop--
instead of going to the forest, let's now go to the woods with the bench--
so Switch Backdrop to Woods and Bench.
And now, as I'm thinking about this story,
I'm going to have the bear move off to the right,
the backdrop is going to change, and then
I want the bear to come out from the left side-- sort of like it's
moving from one scene into another.
So I need to go back to the far left of my program,
I'll have it go to negative 300 in terms of x, which is really far to the left.
And then let's take maybe 3 seconds to glide to the middle--
x equals zero, that's going to be right at the middle of the stage.
So it's a whole bunch of blocks now, but it's telling a story.
We start in the forest, start on the left side of the stage,
start with costume Bear A. We're going to walk for 3 seconds
to the right side of the stage, then switch the backdrop, go to the far left
again, and then walk back out to the middle.
And you can try this one block at a time to get
a sense for how it's going to work, but when you run it all together now--
I'll go ahead and click on this block--
you see the bear move off to the right, and then it sort of shows up
in another environment.
We can try it again, and pay attention to which block might be happening when.
We start in the forest on the far left, we're
gliding three seconds to the right.
The scene changes, we go to the far left,
and we walk back out to the center.
So by putting these blocks together-- and really by playing around with it--
you might not have gotten to exactly that on the first try--
but you can run the project, and if you don't like where the sprite ended up,
you could tinker with the x and the y values,
or how long it takes to glide from one place to another.
But by assembling those blocks together, you
have the ability to start to tell a story
by creating some interesting blocks.
And there are other blocks that you can use too inside of Looks--
so I'll go ahead and delete these for now--
but in the Looks section, we have the ability
to change the size of the sprite if we want to make them bigger or smaller.
We also have these blocks Show and Hide--
Show and Hide just control this toggle here,
which is whether or not the sprite is actually visible on the stage.
If I click on Hide, the bear goes away--
if I click on Show, the bear appears.
So we've taken a look at how we can have the sprite move around,
we've seen how it can change its looks.
There's a third section here called Sound
that can play some sound for a sprite as well.
So for example here, there's a block called Play Sound Until Done.
And here, if I had multiple sounds, I could
choose from those different sounds, or I could record a new sound
if I wanted to.
And by clicking on this block, you'll hear a sound--
the sound plays.
And so those Sound blocks can be useful too
if you want to play sounds inside of your project.
And one other block that I'll show now inside of Control
is this one called Wait.
Sometimes in your project you just want nothing
to happen for a little bit of time, a little bit
of a pause between things that are happening on the project.
And here, the Wait 1 Second block will wait one second,
and I can change the input to change how long it's waiting--
and then it will move on.
So if I put these together with the Wait 1 Second block
on top and then the Sound, well, then what will happen when I click
is I won't hear the pop right away, but it will be one second--
and then you hear the pop after the end of the second.
And so that too can give you a little bit more control over your project
and how it's working.
And so, let's try and create a project that uses some of those blocks.
I am not going to use the bear, so I'll go ahead and delete the bear.
And I'll go ahead and change my backdrop-- if I click
on Backdrops, back to backdrop one-- which is just
this default white backdrop for now.
But let's add a new sprite just to have a little bit of fun with this, let's
pick a different animal.
And this time I will pick the duck--
so we got our duck.
I want to center the duck, so I'll move it to x equals 0
and y equals zero-- just to move it to the center of the stage.
But here's what I'm going to do, I'm going
to combine some of the blocks we've just been using.
I'm going to go to Looks and hide the duck,
then I want to wait one second-- that's under Control.
So Control in the project, I would like it to wait one second--
and then back to Looks, now I want to show the duck.
And after it shows, let's play a sound--
let's play the duck sound until it's done.
And so this is going to let our duck play a little bit of hide
and seek-- it's going to disappear, and then it's going to appear.
So when I click on this, watch what happens on the stage--
it hides, it waits one second, and after one second it shows up
and it plays the duck sound as well.
And so you could have a lot of fun with these sounds-- right now
the duck just has one sound, but you could add other sounds to it as well.
You could record new sounds, you could upload a sound from your computer
if you'd like to, and we even have the ability
to have other blocks to play sounds-- in particular, musical notes.
There are extensions to Scratch-- extra blocks
that you can add into your Block library that give your Scratch
projects a few extra features.
And let's try that out now, I'll go ahead and delete the duck
and we'll go back to the usual cat.
So I'll choose a sprite and I'll just go ahead and pick the cat again,
and move the cat back to the center.
But notice down here in the bottom left there's this blue block
icon with a plus next to it.
This is where I can get to the extensions for Scratch,
and there are all sorts of different extensions for Scratch that we can use.
We'll take a look at a few of them today,
but we'll start with the Music extension--
and the Music extension really lets you play music using Scratch box.
So here's one called Play Note, and it's saying Play Note 60 for 0.25 beats.
The number of beats, that's how long the notes going to be played for,
60 is just a number corresponding to what note we're playing--
and if you don't happen to know what note corresponds to what number,
that's OK.
If you click on the 60, what you'll see is a little piano up here--
and if you've never played the piano, what I'm going to try to do
is just play a scale where I'm just playing
a whole bunch of notes in sequence that'll sound nice together.
And I'm going to do that just by clicking
on each of these different keys of the keyboard,
and I noticed that every time I click on a different key, the note changes.
Every note has a different number, and so if I want to play all of them--
let me drag out eight of these blocks 1, 2, 3, 4, 5, 6, 7, and 8.
And for each one, I'll select a different key--
this will be the second white key, this will be the third one,
this will be the fourth one, this one will be the fifth one,
this one will be six, seven, and eight.
So I've got eight blocks in sequence, each of which
is playing a different note, and now when I click on this block
you can hear that sort of scale.
And there are other blocks too to change the way this sounds--
I can set the instrument to change to something else
if I want it to be a guitar playing for example.
I can set the instrument to Guitar, and now the instrument
sounds a bit different.
If I want it to go faster or slower, that's
something called tempo in music-- how quickly or slowly the music
is going to play.
I can change it to 80, for example, and try that.
Plays a little bit faster--
I could change it to something smaller like 40
and then it plays a little bit more slowly.
So there are a lot of blocks that you can
use to change the way your project behaves
to add features and interesting activities
to what it is that you're sprites are doing on the stage.
And I'll show you one other extension that's quite fun--
I'll drag the music away for now.
But let's now try the Pen extension-- the Pen extension is
going to let us draw with our sprite.
And so here's how that's going to work--
I'm going to start the cat over on the left hand side,
and I'm going to use this Pen Down block and the Pen Up block
which we'll see in a moment.
And the idea of this now is that I can draw on the stage
just by putting a virtual pen down on the stage,
moving the sprite across the stage, and then picking
the pen back up at the end of it.
And so I'm going to put the Pen Down, go into the Motion
section of blocks-- and this time, let's try moving some number of steps.
Maybe I'll move 30 steps, and then we'll lift the Pen Up--
and so let's try this now.
A click on this block, the pen goes down, we move 30 steps
and we move, and the pen goes back up.
And what you notice is that, as I do this,
the cat is still moving 30 steps every time, but it's leaving behind this line
that the pen is drawing.
The pen's going down, we're drawing this line,
and then it's picking back up again.
And the result is that you can draw shapes, you can create works of art
just by drawing, using a sprite and moving the sprite around and making
sure the pen is down while you're doing so.
And when the pen is up, then it doesn't matter where you move the sprite--
it's not going to drop--
you're only going to be drawing when that pen is actually down.
But you don't have to just create straight lines--
before, when we were first doing motion with the cat,
we had the cat move in a circle.
Remember, when we were having it move a little bit,
and then rotate a little bit, and then move and rotate,
ultimately move in a circle.
So if we wanted to draw a circle on the Scratch stage,
we could do that by combining our code that we
use to move the cat in a circle along with the code
for bringing the pen up, and bringing the pen back down.
And the way we did that is by moving, but then-- before the pen goes up--
let's also have the cat turn by 15 degrees and then lift the pen back up.
And it'll have the cat start around the top of the circle,
and that's probably where I want it to begin.
But before I begin, I want to erase what's
currently been drawn onto the stage, and that's
back in the Pen section of the blocks.
There's one block just called Erase All, that's
going to erase anything that's been drawn onto the stage.
So I'll click that, that erases the pen--
and you'll notice there are other different Pen
blocks I can use to change what color the pen is drawing in,
to change the size of the pen, the thickness with which I'm drawing.
But I'll just stick with the default for now,
and we'll put the pen down, move 30 steps and rotate, move 30 steps
and rotate--
and as I do this over and over again, the cat's moving, and moving.
And what you see is that we end up drawing a circle on the stage
just by putting the pen down--
and every time we move, we rotate a little bit,
and the effect is that we can use the Pen tool to draw out this circle.
And so those are just some of the blocks that you can use in Scratch.
We saw blocks in the Motion category for moving the sprite around
in order to move it left, right, up, or down, or rotate it, for example.
The Looks section of blocks we can use to change the costume of a sprite
to make it look a little bit different, or to change
the backdrop that we see in the stage inside of our Scratch program.
Or even to make our sprites speak up by saying something or thinking
something inside of a speech, or a thought bubble.
We took a look at some Control blocks-- the ability
to wait some number of seconds, the ability to play sounds, the ability
to make music, and use the pen in order to draw images and create works of art.
And we can do all of that just by taking these blocks
and putting them together in the sequence we want them to be in.
And, ultimately using that, you can create some really interesting programs
with Scratch.
That's it for an introduction to programming with Scratch for today.
Next time, we'll take a look at how we can use these sorts of blocks
and take our Scratch Block projects even further.
We'll see you next time.