WEBVTT

00:00.590 --> 00:11.510
Now that we have the player moving and shooting crap from last time you left right and shoot shoot your

00:11.510 --> 00:17.460
missile and that we have that going let's start implementing the shield.

00:18.140 --> 00:30.980
So you won't have four shields so here have added.

00:31.640 --> 00:35.860
Add this number of shields and we have four OK.

00:35.980 --> 00:44.920
Just like Says appear in court here says debris sanctuary can be SOP's neath the forby shoe.

00:45.100 --> 00:47.100
And for.

00:47.800 --> 00:52.040
And here we're going to make our shields.

00:52.120 --> 00:53.570
It's going to be an array.

00:53.710 --> 00:54.690
Schewe.

00:57.120 --> 00:58.170
We have four

01:02.490 --> 01:04.130
K that.

01:04.490 --> 01:12.020
And just like within that game and the player we're going to have a shield.

01:13.540 --> 01:21.460
Shields like that in we're actually going to pass in the game and we're going to pass in the game cuz

01:21.460 --> 01:29.390
we need to know how wide the game is in Upper Pass in the shields.

01:29.410 --> 01:30.280
Soames

01:33.590 --> 01:46.080
in the numbers it's.

01:46.290 --> 01:53.620
So now shield that so now it's implement this

01:59.360 --> 02:01.050
this.

02:01.660 --> 02:09.460
So want to try to as evenly as possible space out the shields.

02:09.510 --> 02:09.930
OK.

02:09.930 --> 02:16.510
So to do this we're going to need some math and are also going to need a C string.

02:16.590 --> 02:19.140
And it's very kind of glue them here.

02:19.220 --> 02:21.180
Just take this out.

02:21.450 --> 02:26.120
And what's actually in the shoe.

02:26.160 --> 02:36.370
So we're going to need some padding essentially.

02:36.390 --> 02:43.690
So the first padding goes to the ceiling function.

02:45.130 --> 03:05.150
In Lopes of the games window size it's with minus number of shields times the shield is right we can

03:05.230 --> 03:11.760
have already made it so the shields break which is seven.

03:11.910 --> 03:16.680
And you don't have this this constant put this in here.

03:17.100 --> 03:18.350
OK.

03:18.450 --> 03:31.150
So this gives us how much space or how much with the shields the total amount of Shields take up minus

03:31.540 --> 03:36.660
the with the window.

03:36.820 --> 03:42.340
And we're going to divide that by.

03:42.420 --> 03:45.420
It's also going to be a float number.

03:45.820 --> 03:47.970
Shields plus one.

03:48.480 --> 03:49.620
OK.

03:50.770 --> 03:55.390
So really this is what this is saying is

03:58.050 --> 04:06.600
figure out how many or how much space you have left over after you kind of tracked all the shield widths

04:07.080 --> 04:08.840
from the width of the window.

04:10.460 --> 04:20.750
Divided by the number of kind of empty spaces between the shields which is always going to be the number

04:20.750 --> 04:25.800
of shields plus one and we're going take the ceiling of that K

04:28.600 --> 04:33.910
and that will be essentially be leftmost and rightmost

04:36.160 --> 04:38.530
Witz or pat.

04:38.860 --> 04:43.030
So we're going to do the same thing for kind of the in-between patting

04:45.550 --> 04:50.070
each and it's going to be the exact same thing except the floor.

04:50.080 --> 04:53.980
This is came

04:58.800 --> 05:01.780
land minus number.

05:02.010 --> 05:04.700
She'll it's.

05:04.760 --> 05:06.870
She'll separate CH

05:12.120 --> 05:14.370
over floats.

05:17.470 --> 05:18.230
Amber

05:21.820 --> 05:32.960
splits one and we're doing this because B it doesn't four times seven doesn't even divide eight.

05:33.170 --> 05:33.540
Right.

05:33.540 --> 05:37.960
Which is the width of our window.

05:38.150 --> 05:48.030
So now we're going to go through all the shields in space.

05:51.060 --> 06:00.010
Our shields plus get the current shield

06:06.860 --> 06:11.480
and we're going to set the position.

06:14.950 --> 06:20.120
First padding is just adding.

06:20.650 --> 06:22.690
So this is kind of the leftmost padding.

06:22.700 --> 06:28.200
Times are times plus times.

06:29.030 --> 06:31.010
This bright air of the shield

06:34.820 --> 06:44.610
with plus the X-Pac just like the padding between all the shields.

06:45.450 --> 06:48.480
And then for the y position

06:51.640 --> 07:02.740
it's going to be game window size height minus the player.

07:02.980 --> 07:13.800
Great height minus one so one above the players sprite minus the shield.

07:16.910 --> 07:17.290
CH

07:20.010 --> 07:21.280
Right.

07:22.090 --> 07:27.930
Minus 2 because we want to be kind of a little bit above the player.

07:28.070 --> 07:29.540
OK.

07:29.590 --> 07:36.690
And then we'll go through each row of the shield

07:48.130 --> 07:53.120
and we need to say shield to arch.

07:53.370 --> 07:54.220
Right.

07:56.050 --> 08:05.250
Row equals to new Shar she'll each.

08:05.830 --> 08:06.500
Plus One.

08:06.550 --> 08:15.500
So these are going to be just strings and an organic copy copy.

08:15.570 --> 08:19.140
Make sure you include the string here.

08:20.070 --> 08:30.830
And wrister copy these in the current shields sprite row with the shield right row

08:35.210 --> 08:38.400
in the shields bright.

08:38.560 --> 08:42.760
Is this so capias.

08:42.820 --> 08:48.120
It's going to look like it's really going to look like what you had here right.

08:48.340 --> 08:50.750
This very

08:53.380 --> 09:05.790
So just can't stop star shields brides of and then just the top say you need this Doubleback backslash

09:05.790 --> 09:10.510
to escape the single backslash they will need to draw.

09:10.950 --> 09:20.970
And this is just seven eyes and then I forward slash to back slashes and there's three or six one two

09:21.000 --> 09:24.990
three.

09:25.990 --> 09:28.410
And there's just three pieces here.

09:28.510 --> 09:30.190
OK.

09:30.760 --> 09:37.280
So now that should be it for the initialization of the shields.

09:37.540 --> 09:45.010
But since now we're doing some memory allocations we should be doing cleanup as well.

09:45.010 --> 09:48.000
Just make sure that can memory.

09:48.430 --> 09:54.440
So as a clean up shield it's shield

10:04.780 --> 10:09.250
and Woods really go through all the shields we have

10:11.720 --> 10:12.530
simple

10:16.590 --> 10:18.670
and current shield

10:25.100 --> 10:29.520
and go through all the rows of that shield

10:41.200 --> 10:45.880
and called the lead which array on the

10:48.830 --> 10:53.510
Spryte.

10:53.880 --> 10:57.080
So we'll need these two functions.

10:57.210 --> 11:07.020
Copy that one piece or their knit shield and shields

11:12.220 --> 11:15.130
so it's call and it shields

11:24.480 --> 11:28.200
now and again of course.

11:28.390 --> 11:34.400
Silly me.

11:34.640 --> 11:38.960
So this.

11:39.430 --> 11:39.840
OK.

11:40.000 --> 11:46.750
So now that we've kind of initialized shields we should clean up the shields later.

11:49.630 --> 11:49.990
It's

11:56.330 --> 11:57.320
like that.

11:57.840 --> 11:58.450
OK.

12:00.680 --> 12:04.250
And now we need to actually draw the shields.

12:04.280 --> 12:12.930
So in our draw game function will also pass the shoe.

12:12.970 --> 12:13.370
It's

12:23.510 --> 12:24.010
OK.

12:24.130 --> 12:25.200
It's at

12:30.890 --> 12:34.450
an drug game function.

12:36.900 --> 12:40.600
And just like we have dropped player we're actually going to make a new function

12:43.120 --> 12:45.320
called Trosch.

12:45.380 --> 12:45.610
It's

12:57.610 --> 12:58.020
not

13:01.150 --> 13:03.560
in or trust you.

13:03.570 --> 13:12.350
Is this and.

13:15.630 --> 13:22.880
This it's reference not comma.

13:23.060 --> 13:26.430
So our draw shields function will be usable.

13:30.160 --> 13:33.190
All you do is through all the shields that we have

13:35.780 --> 13:39.360
in.

13:39.510 --> 13:42.090
Draw her get current She shield

13:49.700 --> 13:53.080
so and we'll just say dross right.

13:54.990 --> 14:02.700
She'll position dot X and she'll opposition

14:05.200 --> 14:16.990
Y and when to cast this as cast to conc chars and shield Spryte.

14:17.200 --> 14:19.680
So otherwise a mess up it doesn't.

14:19.700 --> 14:23.020
And it should be but this is correct.

14:24.040 --> 14:27.230
And just the shields break it's

14:30.890 --> 14:31.940
OK.

14:33.020 --> 14:42.410
So now in our main function we're not passing the shields games.

14:42.560 --> 14:43.070
That's

14:46.970 --> 14:47.330
so

14:50.940 --> 14:53.820
so initialiser shields.

14:54.120 --> 15:03.800
We clean up the shields later on because we do use a memory alligations and we draw the game with the

15:03.800 --> 15:09.110
shields to show you side shields again.

15:09.110 --> 15:18.020
So again we're just all this is doing is really just spacing it out nicely if you want to kind of do

15:18.020 --> 15:21.880
that yourself some other way you can.

15:21.950 --> 15:30.720
This is a little bit confusing to you but just know that really is doing is evenly speccing the shields.

15:30.800 --> 15:33.080
OK that's that's kind of it.

15:33.290 --> 15:36.030
And if you run it now.

15:37.570 --> 15:55.190
Of course when she uses.

15:55.520 --> 15:56.730
Oh yeah.

15:57.230 --> 15:59.420
You don't need those.

15:59.960 --> 16:03.280
You don't want the in the Drashti cod do not want the reference.

16:03.310 --> 16:07.130
Actually that's redundant.

16:07.130 --> 16:07.460
So

16:10.190 --> 16:11.390
now if you're in it

16:18.740 --> 16:26.290
I don't see it yet because in our draw game we're not calling you.

16:26.350 --> 16:30.420
So here now draw shields.

16:32.220 --> 16:37.730
It's member she is that gay.

16:37.780 --> 16:39.160
So now you're

16:42.060 --> 16:43.960
Haresh.

16:44.690 --> 16:52.200
And if you try to like shoot kind of you know won't collide yet.

16:52.270 --> 16:52.690
Right.

16:54.210 --> 16:59.520
So but all of it's looking almost correct.

17:00.320 --> 17:06.880
Sides the fact that it doesn't kind of intersect yet is fine.

17:06.890 --> 17:16.080
So in the next lecture I want to actually be able to collide our missiles with the shields we've just

17:16.080 --> 17:16.500
drawn.
