WEBVTT

00:01.230 --> 00:09.690
Know that we have our aliens drawing and we can actually shoot them I want to of finish up the explosion

00:09.690 --> 00:17.900
of it and to do that we'll need a new function and call it update.

00:17.960 --> 00:18.900
Aliance

00:21.200 --> 00:23.360
and take the game

00:28.160 --> 00:30.620
and take alians

00:36.370 --> 00:38.470
and take the player

00:42.450 --> 00:43.710
in.

00:43.780 --> 00:49.330
I'm also going to pass in the shields for him but not going to use this lecture but will need them for

00:49.340 --> 00:49.950
later.

00:54.530 --> 01:07.550
That so the aliens are going to do is it's going to come down the explosion every time it updates and

01:07.550 --> 01:13.850
then any any aliens that are exploding

01:16.160 --> 01:18.840
should then kind of be cleared.

01:19.020 --> 01:32.980
OK so to say if it's aliens dot explosion Taimur is greater than zero.

01:34.320 --> 01:39.580
Returned equals zero then or say aliens dot an explosion

01:41.940 --> 01:52.350
Ramer minus minus k so even if even if it's 0 then it will get minus minus that will equal to not in

01:52.360 --> 01:52.870
place.

01:52.870 --> 02:04.720
So if explosion remember is zero then explosion

02:07.450 --> 02:15.240
timer will be set to not in play effectively.

02:16.160 --> 02:24.660
So then we're going to go through all the aliens

02:58.540 --> 03:11.830
that and to check to see if they're exploding ants row column and if they're exploding

03:14.720 --> 03:18.470
and the timer explosion timer

03:23.850 --> 03:27.650
is equal to not in play.

03:30.800 --> 03:32.400
Playing like this.

03:33.420 --> 03:36.130
Then we're going to set the aliens to be dead.

03:38.290 --> 03:38.760
OK.

03:38.790 --> 03:46.410
So essentially we're just kind of clearing all the aliens that have been exploding up until this point

03:47.170 --> 03:51.490
and we're just setting them to be gone now.

03:51.510 --> 04:10.310
So if we actually call this in it's a game and say date aliens in repasts game player whether the player

04:10.740 --> 04:11.990
or aliens

04:16.050 --> 04:25.910
and the player the shields and the number of shields like so OK.

04:26.180 --> 04:27.440
So if you run this

04:31.140 --> 04:36.720
then you see how it explodes for a second and then it disappears.

04:36.800 --> 04:39.690
They just kind of what you want.

04:39.870 --> 04:42.790
So that looks pretty good so far.

04:46.270 --> 04:53.020
Now we want to have our aliens kind of move.

04:53.500 --> 04:54.250
OK.

04:54.610 --> 05:04.930
And to do that we'll be still working in the aliens function and we're going to have

05:08.320 --> 05:24.320
centrally we're going to count down the amount of time that the alien.

05:24.370 --> 05:34.000
So essentially every few every amount of a certain amount of time we're going to move the alien to the

05:34.030 --> 05:35.880
right or left.

05:37.700 --> 05:50.350
So to do that we're going to we're going to make a new function first.

05:51.260 --> 06:03.830
And we're going to call it a reset movement time and make a new function here.

06:03.840 --> 06:13.160
BOYD It's called Reset movement time like this in we're going to pass it in the alien swarm

06:24.590 --> 06:32.480
and this is really it's kind of up to you how you want to implement it.

06:32.480 --> 06:38.080
Actually there's no right way.

06:38.110 --> 06:42.260
I don't think to do it.

06:42.290 --> 06:47.410
But here's kind of what I found to be kind of nice in a movement.

06:47.410 --> 06:56.330
Time is the movie Time and we're going to set it to some amount and it's going to be based on the current

06:56.330 --> 07:05.810
line that the aliens are on times two plus two times or five or five times

07:10.560 --> 07:13.680
the amount of aliens that are left.

07:14.440 --> 07:22.840
So it means that none of you are left over.

07:23.210 --> 07:27.880
Of the number total aliens

07:37.800 --> 07:38.390
OK.

07:38.550 --> 07:42.080
So this is kind of just something I came up with.

07:43.750 --> 07:53.100
So essentially though the lower the amount of aliens the lower this movement time will be essentially

07:53.380 --> 07:53.790
trying.

07:53.800 --> 08:06.250
So meaning that after we every time this in time hits zero will move the alien K and it it goes faster

08:06.250 --> 08:11.040
depending on depending on how many aliens are left.

08:11.440 --> 08:15.090
So this is just something I sort of came up with.

08:15.100 --> 08:21.620
It doesn't really matter you can come up with your own kind of formula or use mine.

08:21.760 --> 08:23.710
It doesn't matter that much.

08:23.810 --> 08:31.090
OK so I'm actually going to call it in initialize aliens.

08:31.150 --> 08:33.320
I'm going to say here.

08:35.660 --> 08:39.200
So notice we never set movement time ever.

08:39.680 --> 08:50.540
So we're going to reset time.

08:50.750 --> 09:07.170
Really it's like so and now every so often when the movement time is zero we will essentially move the

09:07.170 --> 09:08.060
aliens.

09:08.100 --> 09:22.430
So aliens Dot meant time is minus and then we're going to need some which you need some

09:26.100 --> 09:32.580
boolean values and stuff that's cool and I say move horizontal

09:36.080 --> 09:39.560
and can move horizontal.

09:40.590 --> 09:47.170
If it's if 0 is greater than or equal to the aliens movement time.

09:47.210 --> 09:53.130
So basically if if the moving time is zero we're going.

09:53.290 --> 09:54.120
OK.

09:54.710 --> 09:55.670
And

09:58.660 --> 10:03.930
going to also need so if I just kind of run this for now.

10:06.660 --> 10:17.790
Not going to move yet but see how you say I kind of kill this row of aliance

10:20.670 --> 10:33.010
if they should move to the right day initially and if these aliens hit the edge of the screen then it'll

10:33.040 --> 10:35.490
move down and then go back.

10:35.500 --> 10:36.070
OK.

10:36.400 --> 10:39.370
So we need some way of getting

10:41.840 --> 10:53.930
like all the empty columns and rows that exist to the left and right of the alien swarm.

10:54.050 --> 11:00.920
And so if I kill that it's killed three columns of the alien swarm so now they would they would only

11:00.920 --> 11:05.240
move down if these guys.

11:05.250 --> 11:09.140
These aliens are here hit the right edge.

11:09.220 --> 11:15.820
KAYE So we're going to kind of have to factor that in somehow.

11:16.200 --> 11:34.300
And we're going to do that by having some say empty columns to the left in just how many empty columns

11:35.630 --> 11:36.700
to the right

11:40.170 --> 11:43.350
and also we don't have empty columns to the bottom.

11:43.600 --> 11:46.970
Well are empty roads.

11:47.010 --> 11:47.820
Yes.

11:53.360 --> 11:54.150
OK.

11:54.630 --> 11:57.000
And I'm going to.

11:57.090 --> 12:04.450
Not yet but I'm going to write the function called find empty rows and columns.

12:06.980 --> 12:13.620
And I'm going to pass the aliens and the empty homes if it's

12:17.350 --> 12:21.420
de columns.

12:21.880 --> 12:22.750
Right.

12:25.060 --> 12:37.100
D Rose bottom.

12:37.740 --> 12:38.700
OK.

12:38.780 --> 12:46.250
And these largely find all the empty row empty columns and and bottom rows that we have in the elite.

12:46.340 --> 12:48.050
It's OK.

12:48.170 --> 12:55.880
And again we're going to need that so when they actually move to the right or left in the then we know

12:57.650 --> 12:59.140
which.

12:59.570 --> 13:06.340
Which columns should hit the the edge before it actually moves down.

13:06.490 --> 13:07.560
And then back.

13:07.560 --> 13:08.080
OK.

13:10.230 --> 13:14.560
So we're going to need that at some point or we're not going to implement that just yet.

13:14.780 --> 13:23.900
And in a minute and or in say a number of columns is the number is

13:26.780 --> 13:28.550
is the number of

13:31.190 --> 13:35.080
union columns minus empty

13:37.570 --> 13:42.990
columns left minus the in the columns right.

13:45.390 --> 13:52.970
That's just how many are actually left and we're going to get the Left position

13:58.090 --> 13:59.610
of the aliens

14:02.490 --> 14:08.950
and or in-seat aliens dot Sion X plus

14:11.240 --> 14:16.810
and B are empty columns.

14:19.920 --> 14:24.760
And d Combs left Heinz

14:29.310 --> 14:41.790
unions don't great sized weight loss.

14:41.890 --> 14:46.120
You know it's expanding

14:58.060 --> 15:02.530
and we're also going to need the right position

15:13.630 --> 15:18.870
or should be left in the ocean.

15:20.990 --> 15:28.480
What's the number columns that we have times in

15:31.780 --> 15:33.360
sed rate.

15:33.750 --> 15:35.550
So it's

15:43.720 --> 15:51.310
just the number of columns it's one times you know millions

15:53.940 --> 16:01.740
patting things are just getting the left and right side of the aliens warm day.

16:01.840 --> 16:03.650
It's already here.

16:03.700 --> 16:05.320
So if

16:09.540 --> 16:20.620
you're right alien position is greater then the game not the size.

16:21.150 --> 16:27.730
Wit and we're going in the right direction.

16:30.210 --> 16:31.580
It's greater than zero.

16:32.570 --> 16:33.260
Or

16:35.990 --> 16:38.820
the left alien position.

16:40.740 --> 16:42.330
Is less than or equal to zero.

16:42.350 --> 16:48.210
And aliens dot direction is less than zero.

16:53.910 --> 16:54.720
And

16:58.130 --> 17:07.530
we have to move horizontal or the next move is the horse is a horizontal move and we're not done game.

17:11.760 --> 17:16.410
So we're not at the end of the actual thing here.

17:18.500 --> 17:26.420
So lines really just means like level or at or like not level but like what current row we're at.

17:26.420 --> 17:42.160
So if the row is 11 then we have to invade now essentially then we will move I say move horizontal is

17:42.160 --> 17:47.410
false because we're actually going to move down here.

17:47.590 --> 18:03.030
This is the move down because we've hidden edge K and or Asay aliens dot position dot y plus plus the

18:03.040 --> 18:04.990
next line.

18:04.990 --> 18:09.570
Aliens dot line minus minus.

18:09.660 --> 18:11.340
We're going to switch the direction

18:17.840 --> 18:20.450
this means.

18:22.200 --> 18:30.610
Action and you're also going to reset the movement time

18:33.560 --> 18:42.610
the aliens say because we need to do this all over again the next time right.

18:43.160 --> 18:46.810
And we're going to say If move.

18:46.830 --> 18:47.690
Horizontal

18:51.980 --> 19:04.460
then the aliens position X plus ghouls aliens direction.

19:04.800 --> 19:07.490
We're going to reset the movement time again.

19:09.050 --> 19:12.480
Because we just went whatever direction that we're going in.

19:12.470 --> 19:21.710
So you have to wait some amount of time again to do it and say aliens dot animation

19:24.230 --> 19:28.030
and animation.

19:28.100 --> 19:31.190
So if it was 0 then it should be 1.

19:31.200 --> 19:32.090
Otherwise it's

19:35.380 --> 19:39.890
so this was kind of a lot of stuff and we're still not done.

19:40.360 --> 19:44.890
But kind of to recap essentially again if I run this

19:48.750 --> 19:51.170
this for now.

19:51.330 --> 19:57.820
So if I run this up see how they're moving already.

20:00.260 --> 20:01.960
They're not animating yet.

20:02.690 --> 20:07.610
So once they hit the right edge here they should go back

20:12.110 --> 20:16.320
see it drop down and then now they're going backwards.

20:16.320 --> 20:16.750
OK.

20:18.200 --> 20:28.660
So that's kind of nice but kind of recap this or actually this is actually a good example.

20:28.660 --> 20:29.200
So

20:32.500 --> 20:38.980
the reason why we did this kind of left alien position right aliens mission is to see where the left

20:38.980 --> 20:40.020
most are.

20:40.030 --> 20:43.700
In this case the most alien position is which is right here.

20:43.840 --> 20:50.080
So say I only had I had like this.

20:50.140 --> 20:54.640
This is still the rate most alien position because I have an alien on the right.

20:54.760 --> 20:55.460
OK.

20:55.540 --> 20:58.910
So this whole column hasn't been cleared yet.

20:59.020 --> 21:08.370
So if this hit the right edge then we should drop down and then go to the left again.

21:08.710 --> 21:17.230
So that's really what all of this is saying saying find me the left edge of the aliens find me the right

21:17.230 --> 21:26.950
edge if the right edge of the aliens is greater than the window size.

21:26.950 --> 21:34.990
So if it's at the if it's at the actual and or the rightmost edge of the window and we're going in the

21:34.990 --> 21:47.780
right direction or if we're at or if the left edge of the aliens is at the left edge of the screen and

21:47.800 --> 22:00.840
we're going left and we have it and we can move right then go down OK so move down and then switch or

22:01.440 --> 22:03.070
directions.

22:03.930 --> 22:12.980
And Doree this line stuff for now we're going to get to that of later so move down and then don't move

22:12.990 --> 22:13.900
horizontal.

22:14.120 --> 22:15.320
OK.

22:15.330 --> 22:23.460
And then otherwise if we didn't move down just keep moving in the direction you're going and then reset

22:23.460 --> 22:27.890
your movement time and then switch your animation.

22:29.210 --> 22:31.360
So now let's deal with the animations.

22:31.370 --> 22:34.580
It kind of looks kind of good.

22:35.480 --> 22:38.800
So don't worry about this stuff yet.

22:38.960 --> 22:40.420
OK.

22:40.460 --> 22:42.010
We'll do this after.

22:42.500 --> 22:44.150
So in our

22:46.290 --> 22:47.340
utils

22:49.780 --> 22:56.550
what I want to do is I want to have the offset here.

22:58.140 --> 23:01.230
And this offset will actually be animation.

23:01.230 --> 23:07.300
And so if you look at Texana baiters that H.

23:07.380 --> 23:18.450
So it goes 0 1 2 3 for our sprites and the height of the sprite is 2.

23:18.450 --> 23:27.600
So we have to go by twos for animations so 0 is the first animation and then it's starting at 2 0 1

23:27.600 --> 23:31.220
2 is the next Sprite to draw.

23:31.410 --> 23:37.210
Ok so this offset here really will be the animation that we're at.

23:37.480 --> 23:38.120
OK.

23:38.990 --> 23:45.700
So now that we have that in our raw

23:48.480 --> 23:58.600
in our draw we need to also pass the animation that we're on aliens

24:00.750 --> 24:10.720
animation times the aliens dot straight sized dot height.

24:11.710 --> 24:14.860
Are going to pass this.

24:15.100 --> 24:17.410
So this will kind of skip.

24:17.470 --> 24:26.200
So if the animation is 0 then it'll only draw the first two and if the animation is one it'll skip the

24:26.200 --> 24:28.810
first two and then only draw the second two.

24:28.960 --> 24:33.240
OK so are shouldn't be here it should be.

24:33.350 --> 24:39.030
No no animation for the explosion should be in the actual when it's alive.

24:39.790 --> 24:42.790
And just copy and paste that for each one

24:49.000 --> 24:49.800
OK.

24:49.840 --> 24:52.750
So now if we run this

24:57.360 --> 25:04.030
see them move or see them animate as they move.

25:08.100 --> 25:09.720
So you know that's working.

25:13.490 --> 25:19.270
And it should drop down and keep animating and going to laugh.

25:19.660 --> 25:23.570
Hey so that's pretty cool.

25:23.630 --> 25:32.450
But they don't teach us this too but they don't actually hit the proper edge yet we still haven't done

25:32.450 --> 25:41.510
that because we can commented out this function and what this function will do.

25:42.960 --> 25:52.990
Is it will actually find which rows and columns are actually got this point.

25:54.040 --> 25:56.840
So what's actually infinite this.

25:57.030 --> 26:01.320
This one's going to be actually fairly long.

26:02.760 --> 26:03.540
Fortunately

26:06.990 --> 26:08.570
But it's important to us.

26:08.590 --> 26:10.630
So Boyd

26:13.950 --> 26:17.050
an we're not going to change the aliens at all.

26:22.540 --> 26:28.530
Passed in these by reference because these are going to be kind of the output function

26:33.230 --> 26:36.240
so start implementing this.

26:36.260 --> 26:42.660
So I hope the animation portion of it made sense of what's what's happening.

26:42.670 --> 26:43.910
OK.

26:47.870 --> 26:49.630
I hope hope that makes sense.

26:49.630 --> 26:57.040
So really we're just kind of indexing further into the array for the sprites.

26:57.050 --> 27:01.160
Jay that's that's really what this is this is doing.

27:03.860 --> 27:07.510
So for the find empty rows and columns

27:12.300 --> 27:17.480
save you found false

27:20.910 --> 27:25.330
in we're going to go by columns this time and not rows

27:30.510 --> 27:34.300
and this will be kind of the left.

27:35.370 --> 27:37.130
We're going to check all the left columns.

27:40.860 --> 27:41.150
It's

27:44.310 --> 27:44.600
from

27:50.520 --> 27:51.060
column

27:55.050 --> 27:59.120
that and then we'll go through rows of that column

28:14.360 --> 28:21.640
and this found will essentially once we find someone in that column then we're done.

28:22.630 --> 28:33.760
So if aliens dot millions of row and column.

28:34.210 --> 28:37.580
So as long as it's dead we'll keep going.

28:37.920 --> 28:48.110
We're exploring the as dead.

28:48.200 --> 28:50.270
Or maybe we shouldn't have it actually.

28:50.330 --> 28:57.490
So maybe if it's exploding it shouldn't because there might be some weird problem with that actually.

28:57.530 --> 29:05.950
So if the row alien is one

29:14.060 --> 29:18.710
so if we're at like the end of the rose.

29:18.910 --> 29:21.710
So this is the last row

29:25.680 --> 29:28.290
then we know there's no

29:30.960 --> 29:33.020
there's no column there.

29:33.040 --> 29:33.810
They're all that

29:39.440 --> 29:45.880
should be.

29:46.270 --> 29:49.610
Otherwise we found one.

29:49.770 --> 29:56.490
So we should kind of exit out of this and we're done and we're done.

29:56.990 --> 30:01.540
And that's essentially what we're going to do for the other side.

30:03.790 --> 30:11.010
So I reset this false accuracy for it.

30:11.010 --> 30:11.760
See

30:14.840 --> 30:15.990
Ilion.

30:16.010 --> 30:18.760
COLMES So now we're starting at the right

30:21.450 --> 30:27.900
sees zero found.

30:28.180 --> 30:29.350
It's minus.

30:29.390 --> 30:32.030
So start from the right and work your way back.

30:32.120 --> 30:38.170
Back in the couples column C

30:47.690 --> 30:57.590
is in row 0 row is less than number of alien rows.

30:57.800 --> 31:00.170
And again we haven't found anything

31:04.210 --> 31:08.490
ropes plus.

31:08.700 --> 31:20.830
So basically the same thing if aliens dot row column is dead.

31:25.070 --> 31:25.590
Right.

31:36.630 --> 31:41.970
And if the rover at the last row

31:46.430 --> 31:49.580
then this is an empty column

31:53.250 --> 31:54.650
go straight.

31:59.130 --> 32:03.510
Going otherwise we found something

32:07.580 --> 32:08.960
exit out of this entire.

32:08.960 --> 32:12.200
And raising this found by the way to the exit of two loops.

32:12.260 --> 32:12.920
OK.

32:13.280 --> 32:21.540
So both loops are exiting out of that's where we're now using break here just for information.

32:21.810 --> 32:25.380
And we're also going to loop over the

32:29.040 --> 32:32.340
loop over the bottom

32:35.210 --> 33:19.730
falls or in touch bottom rows they.

33:19.840 --> 33:29.270
So if gange these same thing and dot row home

33:32.120 --> 33:33.890
it's all dead.

33:36.210 --> 33:39.180
Then read the last column

33:52.940 --> 33:59.550
and we know we have an empty row in the bottom

34:04.120 --> 34:10.910
K else.

34:11.570 --> 34:23.780
So I don't run this without calling this function and I'm going to run this with calling this function.

34:23.800 --> 34:35.410
So I'm going to not call this function you know run it and when do is I'm going to attempt to you destroy

34:35.410 --> 34:36.270
them all.

34:37.370 --> 34:42.390
For they get to and this

34:45.420 --> 34:54.970
so yeah see how they drop down even though they weren't at the edge.

34:55.090 --> 34:58.490
So which is I'm going to do this again.

34:58.500 --> 35:02.980
But have this find empty rows and columns

35:06.210 --> 35:08.580
to do the same thing.

35:22.630 --> 35:24.560
Kill three or one or three columns.

35:24.570 --> 35:26.920
Why not.

35:27.150 --> 35:30.100
Now see how they're not dropping down.

35:30.100 --> 35:41.470
They should have been dropping down by now if we had the find empty rows and columns called or not called.

35:41.540 --> 35:43.320
So see how they dropped down now.

35:43.860 --> 35:46.870
And at the end of this day.

35:47.100 --> 35:52.010
So that's why we need that function to actually

35:54.800 --> 35:58.690
to actually hit the edge properly.

36:05.390 --> 36:09.720
They just get the idea it's going to take too long to get.

36:09.730 --> 36:12.730
So you get the idea.

36:12.820 --> 36:16.010
So now that we have all that done

36:18.870 --> 36:21.500
in the next lecture

36:25.200 --> 36:30.780
we're going to work on having the aliens kind of destroying the shields.

36:31.060 --> 36:32.330
So see you then.
