Now that we have the player moving and shooting crap from last time you left right and shoot shoot your
missile and that we have that going let's start implementing the shield.
So you won't have four shields so here have added.
Add this number of shields and we have four OK.
Just like Says appear in court here says debris sanctuary can be SOP's neath the forby shoe.
And for.
And here we're going to make our shields.
It's going to be an array.
Schewe.
We have four
K that.
And just like within that game and the player we're going to have a shield.
Shields like that in we're actually going to pass in the game and we're going to pass in the game cuz
we need to know how wide the game is in Upper Pass in the shields.
Soames
in the numbers it's.
So now shield that so now it's implement this
this.
So want to try to as evenly as possible space out the shields.
OK.
So to do this we're going to need some math and are also going to need a C string.
And it's very kind of glue them here.
Just take this out.
And what's actually in the shoe.
So we're going to need some padding essentially.
So the first padding goes to the ceiling function.
In Lopes of the games window size it's with minus number of shields times the shield is right we can
have already made it so the shields break which is seven.
And you don't have this this constant put this in here.
OK.
So this gives us how much space or how much with the shields the total amount of Shields take up minus
the with the window.
And we're going to divide that by.
It's also going to be a float number.
Shields plus one.
OK.
So really this is what this is saying is
figure out how many or how much space you have left over after you kind of tracked all the shield widths
from the width of the window.
Divided by the number of kind of empty spaces between the shields which is always going to be the number
of shields plus one and we're going take the ceiling of that K
and that will be essentially be leftmost and rightmost
Witz or pat.
So we're going to do the same thing for kind of the in-between patting
each and it's going to be the exact same thing except the floor.
This is came
land minus number.
She'll it's.
She'll separate CH
over floats.
Amber
splits one and we're doing this because B it doesn't four times seven doesn't even divide eight.
Right.
Which is the width of our window.
So now we're going to go through all the shields in space.
Our shields plus get the current shield
and we're going to set the position.
First padding is just adding.
So this is kind of the leftmost padding.
Times are times plus times.
This bright air of the shield
with plus the X-Pac just like the padding between all the shields.
And then for the y position
it's going to be game window size height minus the player.
Great height minus one so one above the players sprite minus the shield.
CH
Right.
Minus 2 because we want to be kind of a little bit above the player.
OK.
And then we'll go through each row of the shield
and we need to say shield to arch.
Right.
Row equals to new Shar she'll each.
Plus One.
So these are going to be just strings and an organic copy copy.
Make sure you include the string here.
And wrister copy these in the current shields sprite row with the shield right row
in the shields bright.
Is this so capias.
It's going to look like it's really going to look like what you had here right.
This very
So just can't stop star shields brides of and then just the top say you need this Doubleback backslash
to escape the single backslash they will need to draw.
And this is just seven eyes and then I forward slash to back slashes and there's three or six one two
three.
And there's just three pieces here.
OK.
So now that should be it for the initialization of the shields.
But since now we're doing some memory allocations we should be doing cleanup as well.
Just make sure that can memory.
So as a clean up shield it's shield
and Woods really go through all the shields we have
simple
and current shield
and go through all the rows of that shield
and called the lead which array on the
Spryte.
So we'll need these two functions.
Copy that one piece or their knit shield and shields
so it's call and it shields
now and again of course.
Silly me.
So this.
OK.
So now that we've kind of initialized shields we should clean up the shields later.
It's
like that.
OK.
And now we need to actually draw the shields.
So in our draw game function will also pass the shoe.
It's
OK.
It's at
an drug game function.
And just like we have dropped player we're actually going to make a new function
called Trosch.
It's
not
in or trust you.
Is this and.
This it's reference not comma.
So our draw shields function will be usable.
All you do is through all the shields that we have
in.
Draw her get current She shield
so and we'll just say dross right.
She'll position dot X and she'll opposition
Y and when to cast this as cast to conc chars and shield Spryte.
So otherwise a mess up it doesn't.
And it should be but this is correct.
And just the shields break it's
OK.
So now in our main function we're not passing the shields games.
That's
so
so initialiser shields.
We clean up the shields later on because we do use a memory alligations and we draw the game with the
shields to show you side shields again.
So again we're just all this is doing is really just spacing it out nicely if you want to kind of do
that yourself some other way you can.
This is a little bit confusing to you but just know that really is doing is evenly speccing the shields.
OK that's that's kind of it.
And if you run it now.
Of course when she uses.
Oh yeah.
You don't need those.
You don't want the in the Drashti cod do not want the reference.
Actually that's redundant.
So
now if you're in it
I don't see it yet because in our draw game we're not calling you.
So here now draw shields.
It's member she is that gay.
So now you're
Haresh.
And if you try to like shoot kind of you know won't collide yet.
Right.
So but all of it's looking almost correct.
Sides the fact that it doesn't kind of intersect yet is fine.
So in the next lecture I want to actually be able to collide our missiles with the shields we've just
drawn.