WEBVTT

00:00.760 --> 00:06.880
It we have the aliens trying to actually start quieting them with the missile.

00:06.880 --> 00:09.130
A player can shoot.

00:09.240 --> 00:16.220
So I'm also going to make another fiction called Collision

00:19.530 --> 00:25.250
in notice that it's the same name as this exclusion.

00:26.190 --> 00:32.680
But we're going to have different parameters for this one.

00:32.700 --> 00:36.170
So in this one I'm going to take the player

00:38.870 --> 00:43.650
and we're just practicing with our overloading functions here.

00:44.260 --> 00:47.410
Player and I'm going take the alien swarm

00:50.290 --> 00:51.810
by reference

00:54.920 --> 01:05.600
and I'm also going to do the same trick I did before which is pass in the position the alien collision

01:07.530 --> 01:08.280
position

01:12.810 --> 01:15.850
in in the actual alians array.

01:19.460 --> 01:28.730
So overturned true if there is collision and it all sort of turn where or which alien collided with.

01:28.870 --> 01:29.970
OK.

01:29.990 --> 01:36.150
So is this we down here to implement it.

01:38.020 --> 01:38.910
And

01:43.220 --> 01:48.900
you're going to say alien collision

01:51.900 --> 01:58.190
in array x is not in play.

01:58.240 --> 02:02.780
It's just like before.

02:02.800 --> 02:08.170
So there's there's no no alien guy yet.

02:08.300 --> 02:09.400
OK.

02:11.270 --> 02:16.190
QUESTION It's a machine or a

02:23.320 --> 02:24.470
like so.

02:24.810 --> 02:25.320
OK.

02:25.660 --> 02:33.730
So we're just going to loop through all of the aliens that we have so

02:36.640 --> 02:40.200
this number in those

02:44.070 --> 02:56.210
group plus in this column zero calling is less than the number of alien columns.

02:58.100 --> 02:58.980
Plus plus

03:01.550 --> 03:13.850
that and we're going to get the position of the elite position is it aliens.

03:15.020 --> 03:24.630
Position X plus which column we're at and in ch

03:27.320 --> 03:35.540
size with was the aliens X padding right.

03:35.580 --> 03:40.900
So we have to include the expiating see each column.

03:40.970 --> 03:42.720
See.

03:42.910 --> 03:46.380
And so really why position

03:57.760 --> 03:58.910
row time.

03:58.980 --> 04:09.170
It's it's ch great signs right.

04:10.050 --> 04:11.530
Was alians

04:19.040 --> 04:19.650
OK.

04:19.660 --> 04:28.990
So essentially we're going to do the exact same thing with The Shield so we can say if there is one

04:28.990 --> 04:32.130
new wrinkle which is quite simple.

04:32.530 --> 04:45.040
If the row if the aliens at that row and column is alive so they have to be alive and

04:50.120 --> 04:52.050
in the player

04:54.790 --> 04:55.810
missile

04:58.210 --> 05:07.400
x is greater than the exposition and where each missile

05:09.540 --> 05:17.730
X is less then the exposition Plus it means as

05:22.520 --> 05:22.710
with

05:30.480 --> 05:38.370
Schertz it's correct there ain't.

05:38.500 --> 05:41.080
So basically this is saying

05:43.600 --> 05:49.940
is is the missile within the

05:53.550 --> 05:55.700
boundary the X boundary

05:58.310 --> 06:01.680
of the current you know.

06:02.230 --> 06:03.090
Right.

06:03.310 --> 06:10.430
SINGH And similarly we need to do the same for the height and

06:14.330 --> 06:26.580
where Dot missile Y is greater than is greater than 2 or greater than or equal to y position and flared.

06:26.900 --> 06:32.300
Missile dog Why is less than Y position.

06:32.700 --> 06:34.710
Woss aliens.

06:35.060 --> 06:40.190
Spryte so each.

06:40.470 --> 06:44.400
So this is saying is it within the Y boundary.

06:44.640 --> 07:02.820
So and if it is then we just say alien collision session in re X is a column alien collision position

07:02.920 --> 07:04.520
in or.

07:04.760 --> 07:19.410
Why is the row and were turned true that we hit and otherwise at the very end we say or turn false.

07:19.870 --> 07:22.270
So that's kind of it.

07:22.840 --> 07:26.190
And also just like before.

07:26.230 --> 07:30.770
We need to resolve the alien collision.

07:30.850 --> 07:34.210
So you're right.

07:34.220 --> 07:38.540
Claire is going to return the.

07:38.560 --> 07:42.790
So if you hit an alien you get some amount of points right.

07:42.820 --> 07:47.590
So we're actually going to return the amount of points that we got.

07:47.590 --> 08:02.460
So that'll be part of the resolution of the hit collision the aliens swarm.

08:02.590 --> 08:10.330
Going to be by reference because we might change the aliens here and it also return the position that

08:10.330 --> 08:11.080
was hit.

08:11.110 --> 08:15.040
So hit sition

08:17.600 --> 08:20.940
ray which probably passes by conc reference

08:23.210 --> 08:27.920
so.

08:28.040 --> 08:32.030
So it's copy that here.

08:34.960 --> 08:36.890
Implemented and will say

08:39.690 --> 08:43.080
aliens.

08:44.640 --> 08:50.630
Unions and the position in

08:53.340 --> 09:01.740
it's Ray y for the row and the hit position

09:04.050 --> 09:07.620
means re x.

09:07.680 --> 09:13.350
So we're going to go to the next the next state which is exploding

09:16.720 --> 09:20.010
so it was hit.

09:20.230 --> 09:20.890
You know it's

09:26.690 --> 09:29.300
so it was hit.

09:29.360 --> 09:35.430
Now it's exploding in the number of aliens we have left is also

09:41.190 --> 09:42.530
B minus minus Rake's.

09:42.540 --> 09:46.940
We have 1 1 1 hit.

09:48.030 --> 09:53.920
And now we'll need that explosion timer as well.

09:53.960 --> 10:05.330
So if we go up here I'm going to say this is actually going to be not in play.

10:05.330 --> 10:12.590
And the reason I'm going to do that is if if it's not in play that means that we don't have anything

10:12.590 --> 10:14.290
exploding.

10:15.310 --> 10:17.750
So I say if

10:20.250 --> 10:27.750
aliens dot explosion Taimur is not in play.

10:30.300 --> 10:34.070
Then we're going to send it to some amount.

10:34.140 --> 10:42.710
So aliens dot explosion timer it's going to be some amount and we don't have this yet.

10:42.840 --> 10:49.710
Really explosion time OK.

10:49.740 --> 10:56.310
So we're going to see some amount that we have to find but we will and second and then we're just going

10:56.310 --> 10:59.500
to check to see which row we hit.

10:59.610 --> 11:01.170
So if hit position

11:03.870 --> 11:13.090
in aliens radar why was first row in or around turn 30 points right.

11:17.580 --> 11:30.930
Is that correctly you know otherwise if it's greater than or equal to the first row and if it's less

11:30.930 --> 11:34.960
than the third then returned

11:38.760 --> 11:40.280
20 points right.

11:42.290 --> 11:44.810
Otherwise return

11:47.290 --> 11:47.760
10.

11:47.950 --> 11:48.540
OK.

11:48.640 --> 11:54.400
This is this will do the actual points stuff.

11:54.440 --> 11:55.100
OK.

11:55.580 --> 11:58.980
So we need this explosion time.

11:59.090 --> 12:04.960
So in here as you say

12:08.610 --> 12:13.640
earns say it just sits for day.

12:13.860 --> 12:15.120
Whatever that means.

12:15.160 --> 12:20.430
Or just can be kind of quick so now

12:24.770 --> 12:32.450
now that we have the collision and solve collision we're going to say a d h.

12:35.210 --> 12:37.710
It's going to make an update.

12:37.870 --> 12:39.270
It's function.

12:45.080 --> 12:47.570
In here somewhere.

12:50.730 --> 12:51.710
I say

12:54.670 --> 12:55.300
cool

12:59.930 --> 13:05.890
Well actually just put it in the update function for now.

13:07.010 --> 13:24.000
So in a big game will say if you we need you in the position where you in collision point or say if

13:24.360 --> 13:27.220
the is

13:29.910 --> 13:41.230
vision where and the aliens and the player in an.

13:41.940 --> 13:43.140
So if there was a collision

13:45.700 --> 13:49.730
and of course we're going to need to add in

13:52.340 --> 13:57.140
aliens into the game here.

13:58.980 --> 14:05.100
Say alien swarm means like this

14:07.580 --> 14:08.340
game.

14:08.540 --> 14:09.790
Aliens.

14:13.870 --> 14:14.660
Also.

14:14.860 --> 14:25.650
It's here.

14:25.830 --> 14:35.620
So so if there was then we will reset the missile again because it hit something.

14:37.120 --> 14:49.270
And we'll also say that we're not score plus equals resolve the alien collision you know.

14:49.330 --> 14:59.950
And this is where you know collision point.

14:59.970 --> 15:02.780
So if we run this

15:05.770 --> 15:12.400
and we hit an alien it doesn't quite work yet.

15:17.290 --> 15:22.690
But at least it's dead for now.

15:22.690 --> 15:29.800
So and the reason why we don't it's not working is because or at least we kind of don't see it anymore

15:30.370 --> 15:35.350
because we're setting it into these exploding state.

15:35.350 --> 15:37.300
So we go back.

15:37.370 --> 15:37.580
It's

15:40.330 --> 15:44.610
an if we go to

15:47.370 --> 15:52.590
this function where he said it to the exploding state but we don't ever draw the exploding state for

15:52.590 --> 15:53.800
example.

15:54.210 --> 16:07.410
So let's actually make the exploding state for our aliens conc char star alien explosion

16:10.090 --> 16:12.620
and you be as creative as you like.

16:12.620 --> 16:17.510
I'm just going to say.

16:19.860 --> 16:32.890
This in re that CH like that for the top and the bottom like this.

16:39.120 --> 16:42.080
So that's the alien explosion Spryte.

16:42.090 --> 16:49.260
So let's actually draw the alien explosion inside of here.

16:50.950 --> 16:52.990
Inside of the draw

16:57.690 --> 17:16.060
draw the you know it's so in here we're going to say else if aliens dot aliens zero and call them is

17:16.060 --> 17:19.630
equal to a -- exploding

17:24.420 --> 17:26.670
then I will say draw Spryte

17:29.040 --> 17:39.640
exposition y position in this explosion and aliens dot is right sized right.

17:43.020 --> 17:47.140
So do that for each one here.

17:47.200 --> 18:02.040
Else if you aliens dot millions and see him.

18:02.880 --> 18:03.870
Let's row

18:08.800 --> 18:10.290
to exploding

18:16.750 --> 18:18.770
in sync here.

18:57.170 --> 19:04.090
OK so now if you run this should see the explosion.

19:04.290 --> 19:11.190
See and actually go through each one and actually explode it.

19:11.260 --> 19:14.200
There you go.

19:14.350 --> 19:22.150
We don't have so they don't disappear yet because our explosion timer that we set over here

19:24.870 --> 19:33.980
is the explosion timer that we set right here isn't being updated in any way.

19:34.290 --> 19:42.750
OK so I'm going to save this for the next lecture and in the next lecture we'll actually have them move

19:42.750 --> 19:48.650
around and if they do get killed they'll actually disappear.

19:48.810 --> 19:50.860
OK so I'll see you in the next lecture.
