-
Let's animate Winston
using the shortcuts that you just learned.
-
So, here we've got Winston with his eyes
-
and we've got this eyeSize variable.
-
So if we wanted to make
Winston's eyes get bigger
-
we could just say "eyeSize += 1,"
-
adding one pixel to the size of the eyes
-
each time, and whoah!
Look at it, it's buggin' out!
-
Let's restart -- whoah! Bug out! Bug Out!
-
Now, that's pretty cool.
-
And, it turns out in programming
-
we actually add one to variables a lot.
-
Maybe while animating but also,
-
you'll see there's a lot of other reasons
-
why we add one to variables later.
-
Programmers got bored
of writing "+= 1" all the time
-
because programmers
get bored of silly things.
-
So they came up with
a shorter way of writing it.
-
So instead of "eyeSize += 1,"
we could just write "eyeSize++"
-
You see, it will do
exactly the same thing.
-
It's just a shorter way of doing it.
-
And not only do we use
this in programming,
-
Now most programmers
use it in everyday speech.
-
Because pretty much
we're all familiar with ++.
-
And it's an easy way of saying
-
that you're making
something a little bigger.
-
So if we went to Winston's birthday party,
-
we might say, "Oh, happy birthday
Winston, Winston++!"
-
Because Winston just got a year older.
-
Or if we just learned a new fact you might be like,
-
"Oh, go us, intelligence++!"
-
That's pretty fun.
-
So when should you use ++ versus +=?
-
Well, I think for animation
it's cool to use +=, because then
-
you can use the number scrubber
and you can be like,
-
"Whoah! Let's make it -- whoah whoah!
That was awesome!
-
Let's make it really crazy,
really different!
-
Oh! (laughter) See how fun that is?
-
But, you know, depending
on what you're doing
-
it might be convenient just to say "++."
-
And you'll see later
that there's lots of times
-
when you might want to add one
-
to variables, not just for animation,
-
where the ++ operator
could become even more useful.
-
So just keep that in mind
when you see that ++
-
and try using it in your everyday speech.