1
00:00:00,180 --> 00:00:05,400
Before we bring the aliens on board, we need to take care of our start function, so click the start

2
00:00:05,400 --> 00:00:07,660
button and now it should disappear.

3
00:00:08,130 --> 00:00:13,230
We already have are checking to see if game over and by default game over is true.

4
00:00:13,380 --> 00:00:14,960
So that means the game's not in play.

5
00:00:15,240 --> 00:00:24,120
So let's do that as our first check and checking to see if player game over is true and if it is that

6
00:00:24,120 --> 00:00:28,680
we know we can start our game because right now the game's not in play, essentially.

7
00:00:29,280 --> 00:00:33,690
So what we want to do is we'll take that game over and start being true.

8
00:00:33,810 --> 00:00:39,360
Let's set it to false so that we can't keep restarting until we want the player to be able to restart

9
00:00:39,780 --> 00:00:42,200
selecting our button start object.

10
00:00:42,510 --> 00:00:44,340
We're going to apply a style to it.

11
00:00:44,340 --> 00:00:45,510
So we're not adding a class.

12
00:00:45,720 --> 00:00:47,500
We could also add in a class.

13
00:00:47,500 --> 00:00:50,610
So I just want to provide a little bit of variety of how to do this.

14
00:00:51,210 --> 00:00:54,500
So this is actually updating its style properties as well.

15
00:00:54,510 --> 00:00:58,560
We could have added in the class of height and that would hide it and do the same effect.

16
00:00:58,980 --> 00:01:04,410
We need to also make sure that our player settings so we've got one for alien speed.

17
00:01:04,650 --> 00:01:11,430
So just make sure that at five and if you are adjusting any the player parameters, make sure you readjust

18
00:01:11,430 --> 00:01:13,620
them to the defaults at this stage.

19
00:01:14,100 --> 00:01:18,420
So we're ready to set up the aliens and let's try out the start function.

20
00:01:18,690 --> 00:01:25,470
So now we click it and all we really see happening is that the start option disappears and we can move.

21
00:01:25,710 --> 00:01:30,090
So the next thing we want to do and that is to create our aliens.

22
00:01:30,360 --> 00:01:36,270
So let's create a function we can call it set up aliens and then we're going to pass and how many aliens

23
00:01:36,270 --> 00:01:36,990
we want to set up.

24
00:01:37,530 --> 00:01:41,430
So make it completely dynamic and flexible in the numbers.

25
00:01:41,700 --> 00:01:46,680
So creating a function in order to handle that is going to make things a whole lot easier and a whole

26
00:01:46,680 --> 00:01:48,330
lot easier to create the aliens.

27
00:01:48,330 --> 00:01:52,200
And we're going to probably need a few functions that we can break apart.

28
00:01:52,200 --> 00:01:53,610
So it gives us more control.

29
00:01:54,180 --> 00:01:56,940
So we've got the one that we've got the setup aliens.

30
00:01:57,240 --> 00:02:01,230
We're passing in a number and this is how many aliens we want to create.

31
00:02:02,040 --> 00:02:06,900
So again, we want to make this really dynamic and where we're going to be setting up the aliens.

32
00:02:07,260 --> 00:02:11,700
So let's set up and let's calculate have a few calculations.

33
00:02:11,940 --> 00:02:16,920
So using that container dim again, we've got a dynamic width for that.

34
00:02:16,920 --> 00:02:18,870
So that can be changing at any time.

35
00:02:19,500 --> 00:02:21,600
So we'll subtract off of it.

36
00:02:21,600 --> 00:02:26,850
Two hundred so that we're not setting up the aliens right over on the right hand side.

37
00:02:26,850 --> 00:02:31,590
So they're going to be more tuned to be on the left hand side and at Max, they're going to hit the

38
00:02:31,590 --> 00:02:34,500
200 pick mark off the off the right hand column.

39
00:02:34,830 --> 00:02:39,420
Also, let's set up an object and we can set up a row object.

40
00:02:39,750 --> 00:02:46,050
So this is where we're going to position the aliens so we can pass in the X and Y object values.

41
00:02:47,070 --> 00:02:51,330
And for this one, we can take that last column value.

42
00:02:52,310 --> 00:03:00,410
And use that, so we also want to do is we want to find a modulus for the last column, so we've got

43
00:03:00,410 --> 00:03:05,650
our last column and using this, we can get a modulus number for that.

44
00:03:05,780 --> 00:03:08,030
And then what we want to do is divide it by two.

45
00:03:08,120 --> 00:03:14,370
And then what we're going to do is we're going to constantly adjust these values as we add more aliens.

46
00:03:14,480 --> 00:03:21,200
So basically, they're going to all stack across the top and we'll also adjust the Y value as we loop

47
00:03:21,200 --> 00:03:22,610
through and create more aliens.

48
00:03:25,740 --> 00:03:32,190
Let's also set up a temporary with for the aliens, so by default, we can set it up one hundred.

49
00:03:32,460 --> 00:03:37,260
And so this also makes it more dynamic and we can adjust the width of the aliens that we're creating.

50
00:03:37,860 --> 00:03:41,230
So we're actually ready to set up the different rows of them.

51
00:03:41,610 --> 00:03:43,260
So let's create a loop.

52
00:03:45,050 --> 00:03:51,590
And this is just just a regular for loop where we're looping through the number that we passed in.

53
00:03:54,680 --> 00:03:58,880
And this is the number of aliens, so in here we have to have that function that's actually going to

54
00:03:58,880 --> 00:03:59,750
create the aliens.

55
00:04:01,360 --> 00:04:07,180
And we'll create one more function that's going to be the alien maker will pass in the role of object

56
00:04:07,180 --> 00:04:11,240
information as well as our attempt with value.

57
00:04:11,500 --> 00:04:15,220
So that, again, this is going to be fluctuating as we loop through.

58
00:04:17,900 --> 00:04:24,490
So we also need to set up a function to handle that, and this is going to be our alien make her function.

59
00:04:25,970 --> 00:04:31,300
So it's going to get in two parameters, going to get the role, and we can just call it the same size

60
00:04:31,340 --> 00:04:34,070
to avoid confusion and save that.

61
00:04:36,660 --> 00:04:41,880
And for now, it's not going to do anything, so we start the game and we don't see anything happening

62
00:04:41,880 --> 00:04:47,460
quite yet, so just making sure that all of the functions are working so we want to do is we want to

63
00:04:47,730 --> 00:04:53,580
take our Rolex value and add to it the temporary with.

64
00:04:55,560 --> 00:05:01,890
And as we loop through, that will increase those values of where the aliens are located and we also

65
00:05:01,890 --> 00:05:03,960
need to account for the Y value.

66
00:05:04,260 --> 00:05:07,370
So this is going to be a little bit trickier than the real value.

67
00:05:07,650 --> 00:05:16,350
So we can take the value of role and we can check to see if it's larger than our last column value minus

68
00:05:16,350 --> 00:05:17,110
temp with.

69
00:05:17,580 --> 00:05:23,300
So basically that's going to mean that we we can't make any more aliens on the current role.

70
00:05:23,460 --> 00:05:34,890
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

71
00:05:34,890 --> 00:05:37,920
equal that to whatever our starting position was.

72
00:05:38,130 --> 00:05:42,150
And this was our original starting position of where the alien is going to be located.

73
00:05:44,880 --> 00:05:49,020
So that's the Rolex value ro y value that we're resetting.

74
00:05:50,440 --> 00:05:53,590
And I'm also going to move the maker down.

75
00:05:55,350 --> 00:06:02,700
So that we can check to see if we can do the update of the positioning before we make the alien, so

76
00:06:02,700 --> 00:06:04,770
we're passing this value in.

77
00:06:05,070 --> 00:06:09,510
And for now, you can see the role value that's getting passed.

78
00:06:09,510 --> 00:06:16,770
And so we to start game, you can see the value of roll and X is first, X is going to be at three.

79
00:06:16,950 --> 00:06:18,510
Second one is at 100.

80
00:06:18,660 --> 00:06:21,270
The second the next one is that two or three.

81
00:06:21,420 --> 00:06:25,470
And then we're adding 70 to the Y position.

82
00:06:25,860 --> 00:06:28,330
So we're increasing the Y position by 70.

83
00:06:28,530 --> 00:06:30,780
So this is going to create them at three.

84
00:06:30,780 --> 00:06:34,020
One hundred and Y is going to be 70.

85
00:06:38,170 --> 00:06:44,190
And this should be before, so that's actually adding it to and once again, is this double check,

86
00:06:44,200 --> 00:06:47,370
so this time it's 50 and 120 for the whip position.

87
00:06:47,710 --> 00:06:52,750
So it looks like we're ready to start adding our aliens so we can make this fully dynamic.

88
00:06:52,930 --> 00:06:57,100
So the aliens are going to be created on the fly using JavaScript and that's going to come up in the

89
00:06:57,100 --> 00:06:58,020
next lesson.

90
00:06:58,300 --> 00:07:03,850
So go ahead and add in the calculation in order to set up the aliens and make sure that we're passing

91
00:07:03,850 --> 00:07:09,010
in the right X and Y coordinates, because this is where we're going to be positioning the aliens as

92
00:07:09,010 --> 00:07:09,860
we construct them.

93
00:07:09,880 --> 00:07:11,770
So that's all still to come in the next lesson.
