That we have the players shooting moving and they shields as well and can climb missiles with the shields
that start working on the aliens.
So just like we hand with the game player and shields we're going also need to initialise the aliens.
So you actually use your remember the you have a struct called Alien swarm.
So we need to initialize this struct.
So I actually make one swarm
aliens like that.
And let's actually say that.
Aliens
and it's going to take the games as well as the aliens.
So it's clear this turn nothing in it's going to take the game like constant or fruit's and take the
aliens
reference.
It's actually defined this
and define it right after after this
care.
So how would we initialize the alien.
So really we need to set them all to be alive.
If you remember in the alien structure.
We actually said we need to set all the aliens state and we'll need to give it the initial position
and we'll need to use separate size.
All that stuff.
So it's started that.
So first of all that actually set them all to be alive.
So for each row row row is less than a number.
Alien rose
in true cost plus
and remarry we'd find this four.
There's five rows of aliens and 11 columns.
So now let's go through each column
let's remember.
You mean columns plus plus.
And we'll just set them all to be
row column.
So this is the state.
Now they're all alive.
What sets say the direction they're going.
And let's make them go to the right first.
And you have the number of aliens left.
And just how many aliens there are initially.
It's just the number of alien rows and the number in columns
in one set of things.
The animation zero for now we're not going to deal with it in this lecture the size
straight sized with.
We have
we have any constants for this.
Add one or get some so alien.
Right.
Is for right because there's all it there will be actual sprites which we haven't actually made yet.
Yulian spirit
aliens right.
Right.
This to
you mean.
Right.
All right signs start right.
All right.
OK.
So just say the number of bombs.
They zero.
Initialization and let's set the position is it's position so the exposition essentially we want them
to be in the very middle of the screen.
So we're going to say
D-Md..
Size dot with Minus the number of alien columns are eight times the aliens.
Each sprite sized
And so this is how much space the aliens take up minus the actual width of the window and all of this
over to
see see if this is good enough.
And for the aliens dot position why I say the game dot window sized height
Minus the number 18 columns.
Minus well
minus the number.
Alien Rose times the Erian.
Right.
Or say aliens.
Spryte right.
In minus the
alien RWS minus one minus three last game dog level.
So not going to explain this quite yet but we'll see.
Second.
We're also going to say the aliens
line is number.
Columns which is 11 minus game level 1 is.
And so are you aliens dot split end timers.
Now this might change.
We'll see we'll probably make it a revision for this in a second.
Once we actually get everything to be drawing properly.
So let's now let's actually define the sprites of the elite.
It's so x dot each an essay contest Shaar star are going to you do the alien 30 point sprite first.
And if you remember year somewhere thirty point aliens look like this.
OK.
So let's do that.
So it looks like Ford slash two O's and two backslashes.
OK to escape the backslash.
So that's the first part.
And ex-parte is like that.
OK.
And next part is same as the first
in forward slash pack slash coach and another backslash coach and then two backslashes.
There's the first alien
class char you know in the 20 point sprite.
In they're going to look like this.
Space and then the kind of rate freezing angle and the left facing angle brackets.
And then
a solid line two backslashes one forward slash in other recline an vertical line.
This
and Ford slash two spaces actually backslashes.
The pointing point Spryte cuts Chaar star really in ten point separate
so
forward slash to kind of dashes.
And then two back slashes first and then forward slash two spaces two backslashes
and then kind of the same as the first one.
In an angle two spaces angle that connects.
Now we have the sprites for the aliens.
So now let's
actually call
the.
Let's actually implement the Tirah functions for the aliens.
And so in
and we'll say draw game drug games also going to take the aliens now we need to change dreich game to
the aliens.
Such an alien swarm reference it says
US here it's means warm
it's
an now should make a function to actually draw the aliens like we had.
We have a player in shields so let's admit that it's actually clear that Boyd draw aliens
and really it's just going to swarm
reference
capias
and in drug game or you can call it
draw aliens
in this way down here are going to draw.
So now for the drawing essentially need to draw one row of the thirty point aliens.
Or as I say draw one row of the early church you know it's and the next thing we need to do is draw
one row or two rows three of the one point you know it's
and drawn two rows.
Ten point which is
K.
So it's going to be kind of broken up into three different of methods or functions sort of.
So start with the easy one for us is go through all the columns
columns.
It's less than the number of alien columns.
Plus
and we need to get the position things in X equals to aliens.
Position X was column times the aliens dot sprites with
an inch.
Why.
Because x and y position.
This will just be the position of you.
So remember this aliens opposition is the kind of global position of the entire block of alle aliens.
OK so now we should actually we should check if aliens dot the aliens of the first row.
And of current column if they are alive.
Right then we should draw.
Right.
Exposition y position the alien thirty's bright this aliens dot us
that's bright stopped right.
So now it's draw the 20 point is this is all we really have to do for now at least for the three points.
Now we basically need to do the same thing but now we need to draw two rows of these.
So for in our schools zero our is less than is going to make constant comments in each
number of twenty point in roads like this is to
so sure you don't have magic numbers in here.
OK.
So our bus rubbish call it row makes more sense in terms of readability gōde.
And then we'll do the same columns again.
So and now we need to figure out the proper positioning of everything so the exposition will be the
aliens dot position dot X loss column times the aliens the arch sprite sized
and y in stodge position Y plus the row times the aliens dot sized height or sprits size height.
And plus that number of
so and another constant.
Well we're having other conc here and this is going to signify how many rows we have of these three
as well.
Now explain exactly why I'm doing second.
Is that
and times aliens.
Sprits not right.
So essentially what this is saying is
you know this is basically the same thing as here.
So just be after the next bright and this is saying depending on the row like B after the Spryte above
you say so.
So there's one kind of row of sprites above the twenty point aliens right.
This thirty point alians row.
So you have to be kind of below that essentially.
So then we'll just do the exact same thing.
And instead of
instead of zero here we need to say that number of 30 points you mean Rose plus the current row that
you're on.
So it starts at the second row right.
So it's already one rope above you and we go until there's no more rows.
This this type of Balian.
So now the last one
will kind of run it and see how everything looks.
The last one is essentially the same thing.
So I'm going to need another Constance
number 10.
All right.
And it's also to.
So again both through the number of rows for it.
Polls pass through columns in
your column it's
and again the exposition will be essentially the same
and for the y position it'll be a little bit more complicated.
It's going to be alians dot position dot y.
It's our times or road Times
aliens dot right sized height.
And like before then plus the number of thirty point
eighteen Rose times.
Ariens each
sprite sized tight and plus the number of twenty point you time is
right size dot height.
So this is saying like B after the first three rows essentially and and similarly to bar we have to
see aliens dot aliens of number of 30 point
alien RWS plus number of 20 point
Rose plus Roe.
OK.
So again start here.
Started this number of rows because we have two before us.
And then add the current row that were on and same thing as above.
And again the column then was checked to see if this guy is alive.
And if he is we will there should be 20 points right.
Is this
in 10 points right.
So as long as they are alive drop them.
Otherwise dont.
So now that we have all this.
So this is a pretty big function right.
And hopefully it sort of makes sense.
The some changes there is that we have to do
but for the most part I think were good so as to check the aliens.
Yes drug game aliens in dry out aliens is empowerment.
So see what happens.
Its run it
so all was good right.
They look a little too bunched together right.
Theres no kind of padding between them in either the x or y directions.
So let's actually start giving them some padding as well.
So let's Is this an index invaders dot each we should give the aliens some padding.
So we say aliens X padding is one in aliens y patting It's also on.
So let's add some padding into everything so initialize
in the exposition you want to say number of aliens and alien columns times times.
But watch this be
Plus the padding
because we're going to have that amount of padding in in the extraction.
And similarly with the y position we need to say
after the aliens.
I like this aliens spatting that.
And actually and get this wrong this many times this
because it is because there is since there's five alien Rose there should be four rows of padding between
them.
So I miss the four.
So that is OK.
So now it's actually put some padding between the aliens themselves.
So the first road I don't think needs any padding.
OK the next two rows do and in here I was going to say add
Union spatting
aliens expanding right there.
And with the height as well we're going to add the aliens wipe out like that.
K so it's going to do paddings here and also you need the alien paddings hears all
it needs to be in both spots and are to do the same for the next one.
OK so if you're right there's no.
We've got some padding for the first row.
Should be columns times that was the you know it's
expanding
this and you're right it
now we have all the aliens drawing.
And of course it can't hit them yet.
It can't go through
so we're going to actually do some collisions with the aliens in the next lecture.