0:00:01.304,0:00:03.685
Remember the three steps [br]of making an animation?
0:00:03.685,0:00:06.589
We start out by making some variables[br]outside the draw loop,
0:00:06.589,0:00:08.405
and then inside the draw loop[br]we use those variables
0:00:08.405,0:00:10.011
in our drawing code.
0:00:10.011,0:00:12.039
So we've got a variable [br]for the x position,
0:00:12.039,0:00:14.395
one for the y position, [br]one for the ballWidth,
0:00:14.395,0:00:16.011
and one for the ballHeight.
0:00:16.011,0:00:17.723
And then, at the very end,
0:00:17.723,0:00:20.025
we change those variables [br]a little bit every time,
0:00:20.025,0:00:22.773
so x is going to be [br]the old value of x, plus 1,
0:00:22.773,0:00:24.701
so it's going to be increasing every time;
0:00:24.701,0:00:27.796
y is going be the old value of y, minus 2,
0:00:27.796,0:00:29.801
so y will be decreasing every time;
0:00:29.801,0:00:35.406
ballWidth is going to get the old value[br]of ballWidth times 0.99.
0:00:35.410,0:00:39.409
So since 0.99 is less than 1, [br]we're going to see ballWidth decreasing.
0:00:39.409,0:00:41.839
And ballHeight is going to be[br]the old value of ballHeight
0:00:41.839,0:00:45.501
divided by 1.01, which is greater than 1,
0:00:45.501,0:00:47.963
and so we're also going to see [br]ballHeight decreasing.
0:00:47.963,0:00:50.234
So if I press Restart, you can see
0:00:50.234,0:00:53.585
all of these attributes [br]of the ball changing.
0:00:53.725,0:00:56.607
So if you look at [br]these four lines of code,
0:00:56.607,0:00:59.251
you'll notice that [br]they all follow a similar pattern.
0:00:59.251,0:01:01.400
We've got a variable, [br]then an equals sign,
0:01:01.400,0:01:06.047
then the same variable, some operator --[br]plus, minus, times, divide --
0:01:06.527,0:01:08.593
and some number, okay?
0:01:08.593,0:01:11.772
And this pattern is so common [br]in programming,
0:01:11.772,0:01:14.460
and programmers are so lazy,[br]that they decided,
0:01:14.460,0:01:16.777
"Hey! Since we use this pattern so much,
0:01:16.777,0:01:19.054
"Shouldn't there be [br]an easier way to type it?"
0:01:19.054,0:01:22.006
And so they made a shortcut, [br]and the shortcut goes like this:
0:01:22.006,0:01:24.528
Instead of saying "x gets x plus 1",
0:01:24.528,0:01:29.331
I could say "x plus equals 1." Got it?
0:01:29.331,0:01:35.970
And instead of saying y gets y minus 2,[br]I could say "y minus equals 2."
0:01:36.670,0:01:41.259
And instead of saying [br]ballWidth gets ballWidth times 0.99,
0:01:41.259,0:01:47.686
I can say -- you guessed it --[br]"ballWidth times equals 0.99"
0:01:48.203,0:01:49.832
Finally, instead of saying
0:01:49.832,0:01:53.658
ballHeight gets ballHeight divided by 1.01
0:01:53.658,0:01:57.373
we can say [br]"ballHeight divides equals 1.01."
0:01:57.373,0:01:59.468
So for all of these, what it does is
0:01:59.468,0:02:01.553
it takes the value of the variables,
0:02:01.553,0:02:04.123
so ballWidth, and then this operator,
0:02:04.123,0:02:06.344
and then multiplies it by 0.99.
0:02:06.344,0:02:09.240
So it's going to say, [br]"ballWidth times 0.99"
0:02:09.240,0:02:12.067
and then store it back [br]in the variable, ballWidth.
0:02:12.067,0:02:13.864
And if I press Restart you can see
0:02:13.864,0:02:16.005
our animation looks the same as before.
0:02:16.005,0:02:17.975
And now you get to be lazy too!