Before we bring the aliens on board, we need to take care of our start function, so click the start
button and now it should disappear.
We already have are checking to see if game over and by default game over is true.
So that means the game's not in play.
So let's do that as our first check and checking to see if player game over is true and if it is that
we know we can start our game because right now the game's not in play, essentially.
So what we want to do is we'll take that game over and start being true.
Let's set it to false so that we can't keep restarting until we want the player to be able to restart
selecting our button start object.
We're going to apply a style to it.
So we're not adding a class.
We could also add in a class.
So I just want to provide a little bit of variety of how to do this.
So this is actually updating its style properties as well.
We could have added in the class of height and that would hide it and do the same effect.
We need to also make sure that our player settings so we've got one for alien speed.
So just make sure that at five and if you are adjusting any the player parameters, make sure you readjust
them to the defaults at this stage.
So we're ready to set up the aliens and let's try out the start function.
So now we click it and all we really see happening is that the start option disappears and we can move.
So the next thing we want to do and that is to create our aliens.
So let's create a function we can call it set up aliens and then we're going to pass and how many aliens
we want to set up.
So make it completely dynamic and flexible in the numbers.
So creating a function in order to handle that is going to make things a whole lot easier and a whole
lot easier to create the aliens.
And we're going to probably need a few functions that we can break apart.
So it gives us more control.
So we've got the one that we've got the setup aliens.
We're passing in a number and this is how many aliens we want to create.
So again, we want to make this really dynamic and where we're going to be setting up the aliens.
So let's set up and let's calculate have a few calculations.
So using that container dim again, we've got a dynamic width for that.
So that can be changing at any time.
So we'll subtract off of it.
Two hundred so that we're not setting up the aliens right over on the right hand side.
So they're going to be more tuned to be on the left hand side and at Max, they're going to hit the
200 pick mark off the off the right hand column.
Also, let's set up an object and we can set up a row object.
So this is where we're going to position the aliens so we can pass in the X and Y object values.
And for this one, we can take that last column value.
And use that, so we also want to do is we want to find a modulus for the last column, so we've got
our last column and using this, we can get a modulus number for that.
And then what we want to do is divide it by two.
And then what we're going to do is we're going to constantly adjust these values as we add more aliens.
So basically, they're going to all stack across the top and we'll also adjust the Y value as we loop
through and create more aliens.
Let's also set up a temporary with for the aliens, so by default, we can set it up one hundred.
And so this also makes it more dynamic and we can adjust the width of the aliens that we're creating.
So we're actually ready to set up the different rows of them.
So let's create a loop.
And this is just just a regular for loop where we're looping through the number that we passed in.
And this is the number of aliens, so in here we have to have that function that's actually going to
create the aliens.
And we'll create one more function that's going to be the alien maker will pass in the role of object
information as well as our attempt with value.
So that, again, this is going to be fluctuating as we loop through.
So we also need to set up a function to handle that, and this is going to be our alien make her function.
So it's going to get in two parameters, going to get the role, and we can just call it the same size
to avoid confusion and save that.
And for now, it's not going to do anything, so we start the game and we don't see anything happening
quite yet, so just making sure that all of the functions are working so we want to do is we want to
take our Rolex value and add to it the temporary with.
And as we loop through, that will increase those values of where the aliens are located and we also
need to account for the Y value.
So this is going to be a little bit trickier than the real value.
So we can take the value of role and we can check to see if it's larger than our last column value minus
temp with.
So basically that's going to mean that we we can't make any more aliens on the current role.
So we need to take our role y value and add, let's say, 70 to it and then take our role X value and
equal that to whatever our starting position was.
And this was our original starting position of where the alien is going to be located.
So that's the Rolex value ro y value that we're resetting.
And I'm also going to move the maker down.
So that we can check to see if we can do the update of the positioning before we make the alien, so
we're passing this value in.
And for now, you can see the role value that's getting passed.
And so we to start game, you can see the value of roll and X is first, X is going to be at three.
Second one is at 100.
The second the next one is that two or three.
And then we're adding 70 to the Y position.
So we're increasing the Y position by 70.
So this is going to create them at three.
One hundred and Y is going to be 70.
And this should be before, so that's actually adding it to and once again, is this double check,
so this time it's 50 and 120 for the whip position.
So it looks like we're ready to start adding our aliens so we can make this fully dynamic.
So the aliens are going to be created on the fly using JavaScript and that's going to come up in the
next lesson.
So go ahead and add in the calculation in order to set up the aliens and make sure that we're passing
in the right X and Y coordinates, because this is where we're going to be positioning the aliens as
we construct them.
So that's all still to come in the next lesson.