WEBVTT

00:00.530 --> 00:04.150
Now we have the aliens moving around.

00:04.150 --> 00:09.420
We should combine them with the shields.

00:09.710 --> 00:13.060
To do that to make a new function

00:16.720 --> 00:20.550
is going to be called destroy a shield.

00:20.580 --> 00:25.590
It's it's going to take in the swarm

00:35.340 --> 00:37.960
and it can take the shield as well

00:49.790 --> 01:07.220
and shoot it down here and call them or call it intially when we move down or move to the left or right.

01:07.230 --> 01:10.860
So it call it great here.

01:11.390 --> 01:11.910
Troy

01:14.980 --> 01:28.950
yields like that unions shields member of shields remember that we passed it in before last time to

01:29.040 --> 01:32.060
call it here as well so we'll destroy all the shields.

01:32.150 --> 01:33.850
They kind of overlap.

01:34.100 --> 01:41.920
OK so now that we call them How is this going to work.

01:42.030 --> 01:51.660
Well they all we're going to do is go through all the shields or all the aliens or the

01:56.020 --> 01:56.640
RO

02:00.550 --> 02:05.530
alien Roux's plus

02:09.610 --> 02:10.580
go.

02:10.660 --> 02:25.990
Call us.

02:26.510 --> 02:36.280
And if the alien at that row and column is alive

02:41.820 --> 02:46.030
then we will essentially kind of collide them with the shield.

02:46.170 --> 02:54.330
So first we'll get the position exposition and one position of this current alien

02:59.180 --> 03:00.350
is for

03:15.570 --> 03:17.150
which separates these

03:21.620 --> 03:29.600
y position.

03:29.820 --> 03:33.380
Colin Roe

03:46.040 --> 03:46.860
Okay.

03:47.350 --> 03:52.380
And I think what we'll do is have a new function.

03:52.480 --> 03:55.600
This one's going to be fairly complicated.

03:57.800 --> 04:10.190
And we call it Clyde shields with you you know passing the shields and the number of shields and the

04:10.190 --> 04:20.600
exposition in the y position and the size of the aliens you just pass in

04:23.470 --> 04:26.280
criticizing this day.

04:26.420 --> 04:27.790
So we don't have this function yet.

04:28.160 --> 04:35.000
But essentially all we're doing is going through all the aliens and then colliding current alien that

04:35.000 --> 04:40.860
ranch with all the shields that it actually collides with.

04:41.070 --> 04:44.490
And so of kind of the major outline of it

04:48.030 --> 04:50.150
is declared here.

05:11.190 --> 05:13.360
Size.

05:13.560 --> 05:17.780
Konst.

05:18.830 --> 05:19.850
Scott's.

05:22.110 --> 05:30.540
That you go back down and.

05:30.660 --> 05:35.890
So this is going to be fairly complicated.

05:36.790 --> 05:43.570
Hopefully we'll be able to follow what I'm doing essentially I'm going to go through all the Shield's

05:45.350 --> 05:45.630
and

05:51.550 --> 05:55.540
and get current shield that are at

06:01.710 --> 06:08.890
that and run to see if the alien actually intersects with the shield.

06:09.000 --> 06:09.420
OK.

06:09.450 --> 06:11.190
So if the alien

06:14.210 --> 06:33.700
if the Let's rename this something nicer when I call it alien position X you know session y.

06:33.720 --> 06:38.810
Notice that I don't need to have the same name as I have.

06:38.820 --> 06:44.860
So in this one it's called X and Y.

06:45.080 --> 06:46.650
This doesn't actually matter.

06:46.890 --> 06:50.820
Ok whatever it's named up there doesn't affect what's named here.

06:50.880 --> 06:51.360
OK what is.

06:51.370 --> 06:52.260
Use these names

06:54.820 --> 07:01.950
so essentially if the alien position

07:05.340 --> 07:19.140
X is less then the shield position X plus shield is right.

07:24.800 --> 07:33.670
And so if it's kind of like less then the dot x.

07:34.380 --> 07:38.100
So if it's less then the

07:40.590 --> 07:41.820
right edge.

07:41.820 --> 07:47.400
So if the alien position X is less than the right edge which is what this is saying the right edge of

07:47.400 --> 07:47.940
the shield

07:50.380 --> 08:16.310
and you know in position X plus the Yulian size dodge of the alien is greater than or equal to the shield

08:20.070 --> 08:22.650
position X can

08:27.130 --> 08:27.820
so

08:33.190 --> 08:45.300
saying if the left edge of the alien alien is less then the right Moat's most edge of the shield and

08:45.300 --> 08:56.870
the rightmost edge of the alien is greater than the leftmost edge shield.

08:58.520 --> 08:59.210
And

09:02.290 --> 09:15.430
the same thing but in the wider action section wants less than you session why US shield.

09:15.550 --> 09:16.330
Right.

09:16.420 --> 09:17.430
Right.

09:17.740 --> 09:19.660
And in

09:21.950 --> 09:33.520
wifeless sized ch ch it's greater than equal to shield.

09:34.160 --> 09:38.900
Why.

09:38.980 --> 09:44.960
So really all this is thing things as it intersects with the shield.

09:45.100 --> 09:55.740
It's also saying okay and if you're not understanding this maybe just posin kind of draw it out find

09:55.960 --> 10:01.560
it really helps and see how this is working OK.

10:02.740 --> 10:05.680
So to move on.

10:05.680 --> 10:07.590
So if we're colliding.

10:07.600 --> 10:07.940
So

10:11.000 --> 10:17.400
for colliding then we need to know kind of where we're colliding.

10:17.650 --> 10:22.070
So UI alien Zeeshan.

10:22.400 --> 10:29.060
Why is she you.

10:33.170 --> 10:33.370
Ch

10:36.740 --> 10:40.470
he said we're going to need this later.

10:44.600 --> 10:50.930
Sishen X explain this quite yet.

10:51.060 --> 10:55.510
Basically you want to go through the height of the in

10:58.310 --> 11:00.250
seised right.

11:04.530 --> 11:05.280
Plus

11:08.520 --> 11:16.390
in order to get the y position of the shields at that height.

11:16.700 --> 11:31.980
OK so if shield y position is greater than zero and the shield Y is less than shields.

11:32.740 --> 11:34.990
It's great height.

11:40.250 --> 11:52.410
That then we're going to go through each of the or each part of the width of the alien to see where

11:52.410 --> 11:58.050
we should where we should destroy the shields.

12:16.720 --> 12:23.620
So if the shield x is greater than or equal to zero

12:26.220 --> 12:31.070
and shield less than

12:34.650 --> 12:35.570
teach me

12:38.870 --> 12:39.930
k so

12:42.240 --> 12:44.220
shields right.

12:46.300 --> 12:47.570
Shield why.

12:47.590 --> 12:54.710
So this is the shield Why is really the index into the Spryte shield.

12:54.730 --> 13:00.310
X is also index into the Spryte So this is this indexing to the spray on the rose and this is Zendiks

13:00.510 --> 13:03.480
into the spray into the columns.

13:03.550 --> 13:07.690
So if we find it right.

13:08.180 --> 13:21.670
So essentially we're finding the position of where where we kind of are in the shield essentially.

13:21.980 --> 13:24.890
And then we're kind of looping through the height of the

13:27.890 --> 13:38.030
height of this alien and we're getting the position the actual index position of the sprites of the

13:38.070 --> 13:39.250
shield.

13:39.350 --> 13:47.910
K. and then if we're kind of within the Spryte vertically.

13:48.000 --> 13:53.140
What this is saying then we will go through this.

13:53.410 --> 14:01.390
The aliens bright horizontally and check to see if we're actually within the shields bright horizontally

14:01.590 --> 14:04.480
and if we are we'll set these positions.

14:04.510 --> 14:10.690
Shield wind shield acts to be to be empty.

14:10.810 --> 14:13.570
So kind of like it's the shield.

14:13.930 --> 14:14.700
You know it's

14:17.170 --> 14:29.960
so you know we can only know we can only intersect a shield or one ceiling can only intersect one shield

14:29.960 --> 14:39.440
so if we do actually go through the whole height of the alien error of the of the alien then we know

14:39.440 --> 14:40.490
we're kind of done.

14:40.490 --> 14:44.910
So we can just break off our.

14:45.160 --> 14:50.170
So we don't need to keep going through all the shields in this go if you're the one that we know we

14:50.170 --> 14:51.730
actually collided with.

14:53.170 --> 15:05.600
So know it was a little bit confusing but again try to maybe pause the video really kind of draw everything

15:05.600 --> 15:09.920
out to make sure you understand what's happening.

15:10.310 --> 15:15.750
This is always kind of the hardest part of teaching or showing people's things.

15:16.220 --> 15:24.840
You really have to see see a real kind of picture in your head of what this is really doing.

15:24.840 --> 15:26.430
OK.

15:26.960 --> 15:31.820
But let's run this.

15:32.660 --> 15:37.560
Actually you efforts that stopped is recycled and let's make it go way faster.

15:39.600 --> 15:41.370
So that's going to be here forever.

15:43.040 --> 15:47.300
That is going to make the move in time be fast basically as fast as possible.

15:47.650 --> 15:50.290
So it's going to go really quick.

15:50.440 --> 15:54.990
Check to see if we eat the shields when we go through.

15:55.510 --> 15:57.270
Shields are being eaten.

15:57.320 --> 15:58.310
They go.

15:59.320 --> 16:03.720
So it's working it's pretty good.

16:04.050 --> 16:05.130
So now.

16:05.340 --> 16:09.660
So if you don't remember why you are even doing this.

16:11.630 --> 16:16.820
Said if the aliens said somewhere in here really remember

16:25.220 --> 16:35.130
that somewhere in here that if the aliens kind of overlap the shields then the shields are destroyed.

16:35.460 --> 16:38.800
So that's that's very important.

16:40.000 --> 16:40.260
Yes.

16:40.350 --> 16:46.750
So here says when invaders are low enough to touch the base shelters they erased them as they pass.

16:46.840 --> 16:48.100
Kay.

16:48.320 --> 16:50.210
So that's what we're doing.

16:50.450 --> 16:54.260
This needs to kind of functions here.

16:55.150 --> 16:57.590
And destroy shields and collide.

16:57.820 --> 16:58.920
OK.

16:59.230 --> 17:07.040
So again if you're not quite understanding I know there's like three loops and it's all very confusing.

17:07.690 --> 17:13.340
But really all we're saying is hey are you intersecting with a shield.

17:13.370 --> 17:16.020
If you are find out where you're intersecting.

17:16.160 --> 17:17.070
OK.

17:17.180 --> 17:20.020
And that's what all of this does.

17:20.040 --> 17:20.940
OK.

17:21.080 --> 17:27.270
So find out where you are intersecting and wherever you're intersecting just make it to be empty.

17:27.460 --> 17:28.060
OK.

17:31.710 --> 17:37.640
So that's it for this in the next lecture.

17:37.990 --> 17:43.220
I want to start dropping some bombs on the player.

17:43.540 --> 17:44.870
We'll see you in the next lecture.
