It we have the aliens trying to actually start quieting them with the missile.
A player can shoot.
So I'm also going to make another fiction called Collision
in notice that it's the same name as this exclusion.
But we're going to have different parameters for this one.
So in this one I'm going to take the player
and we're just practicing with our overloading functions here.
Player and I'm going take the alien swarm
by reference
and I'm also going to do the same trick I did before which is pass in the position the alien collision
position
in in the actual alians array.
So overturned true if there is collision and it all sort of turn where or which alien collided with.
OK.
So is this we down here to implement it.
And
you're going to say alien collision
in array x is not in play.
It's just like before.
So there's there's no no alien guy yet.
OK.
QUESTION It's a machine or a
like so.
OK.
So we're just going to loop through all of the aliens that we have so
this number in those
group plus in this column zero calling is less than the number of alien columns.
Plus plus
that and we're going to get the position of the elite position is it aliens.
Position X plus which column we're at and in ch
size with was the aliens X padding right.
So we have to include the expiating see each column.
See.
And so really why position
row time.
It's it's ch great signs right.
Was alians
OK.
So essentially we're going to do the exact same thing with The Shield so we can say if there is one
new wrinkle which is quite simple.
If the row if the aliens at that row and column is alive so they have to be alive and
in the player
missile
x is greater than the exposition and where each missile
X is less then the exposition Plus it means as
with
Schertz it's correct there ain't.
So basically this is saying
is is the missile within the
boundary the X boundary
of the current you know.
Right.
SINGH And similarly we need to do the same for the height and
where Dot missile Y is greater than is greater than 2 or greater than or equal to y position and flared.
Missile dog Why is less than Y position.
Woss aliens.
Spryte so each.
So this is saying is it within the Y boundary.
So and if it is then we just say alien collision session in re X is a column alien collision position
in or.
Why is the row and were turned true that we hit and otherwise at the very end we say or turn false.
So that's kind of it.
And also just like before.
We need to resolve the alien collision.
So you're right.
Claire is going to return the.
So if you hit an alien you get some amount of points right.
So we're actually going to return the amount of points that we got.
So that'll be part of the resolution of the hit collision the aliens swarm.
Going to be by reference because we might change the aliens here and it also return the position that
was hit.
So hit sition
ray which probably passes by conc reference
so.
So it's copy that here.
Implemented and will say
aliens.
Unions and the position in
it's Ray y for the row and the hit position
means re x.
So we're going to go to the next the next state which is exploding
so it was hit.
You know it's
so it was hit.
Now it's exploding in the number of aliens we have left is also
B minus minus Rake's.
We have 1 1 1 hit.
And now we'll need that explosion timer as well.
So if we go up here I'm going to say this is actually going to be not in play.
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
exploding.
So I say if
aliens dot explosion Taimur is not in play.
Then we're going to send it to some amount.
So aliens dot explosion timer it's going to be some amount and we don't have this yet.
Really explosion time OK.
So we're going to see some amount that we have to find but we will and second and then we're just going
to check to see which row we hit.
So if hit position
in aliens radar why was first row in or around turn 30 points right.
Is that correctly you know otherwise if it's greater than or equal to the first row and if it's less
than the third then returned
20 points right.
Otherwise return
10.
OK.
This is this will do the actual points stuff.
OK.
So we need this explosion time.
So in here as you say
earns say it just sits for day.
Whatever that means.
Or just can be kind of quick so now
now that we have the collision and solve collision we're going to say a d h.
It's going to make an update.
It's function.
In here somewhere.
I say
cool
Well actually just put it in the update function for now.
So in a big game will say if you we need you in the position where you in collision point or say if
the is
vision where and the aliens and the player in an.
So if there was a collision
and of course we're going to need to add in
aliens into the game here.
Say alien swarm means like this
game.
Aliens.
Also.
It's here.
So so if there was then we will reset the missile again because it hit something.
And we'll also say that we're not score plus equals resolve the alien collision you know.
And this is where you know collision point.
So if we run this
and we hit an alien it doesn't quite work yet.
But at least it's dead for now.
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
because we're setting it into these exploding state.
So we go back.
It's
an if we go to
this function where he said it to the exploding state but we don't ever draw the exploding state for
example.
So let's actually make the exploding state for our aliens conc char star alien explosion
and you be as creative as you like.
I'm just going to say.
This in re that CH like that for the top and the bottom like this.
So that's the alien explosion Spryte.
So let's actually draw the alien explosion inside of here.
Inside of the draw
draw the you know it's so in here we're going to say else if aliens dot aliens zero and call them is
equal to a -- exploding
then I will say draw Spryte
exposition y position in this explosion and aliens dot is right sized right.
So do that for each one here.
Else if you aliens dot millions and see him.
Let's row
to exploding
in sync here.
OK so now if you run this should see the explosion.
See and actually go through each one and actually explode it.
There you go.
We don't have so they don't disappear yet because our explosion timer that we set over here
is the explosion timer that we set right here isn't being updated in any way.
OK so I'm going to save this for the next lecture and in the next lecture we'll actually have them move
around and if they do get killed they'll actually disappear.
OK so I'll see you in the next lecture.