1
00:00:00,210 --> 00:00:04,290
This going to be a quick bonus lesson adding in color to our pipes.

2
00:00:04,500 --> 00:00:10,770
So right now, by default, we're setting them both to be red and we can actually change that and create

3
00:00:10,770 --> 00:00:12,770
a function in order to accommodate that.

4
00:00:13,050 --> 00:00:14,660
So that function can be.

5
00:00:14,910 --> 00:00:19,280
And then what it will do is it will return back a random color and the color.

6
00:00:19,290 --> 00:00:22,110
There's a number of different ways with JavaScript to do color.

7
00:00:22,410 --> 00:00:24,720
So we know what color it needs are harsh.

8
00:00:24,990 --> 00:00:29,750
And if I use math random, I can return back a random value.

9
00:00:30,420 --> 00:00:35,120
So let's open up our console to see what this looks like in the console as we build it out.

10
00:00:35,550 --> 00:00:41,850
So if we do math random, we get this large random number and then we've got a few methods.

11
00:00:41,860 --> 00:00:48,330
We've got a string method where we can turn it into a base 16 string so we can turn it into that.

12
00:00:48,420 --> 00:00:50,880
And this, again, is going to be a random value.

13
00:00:51,150 --> 00:00:55,710
And we've got one more method that I want to make use of, and that's the sub string.

14
00:00:56,070 --> 00:00:59,790
And we want to only get six characters being returned back.

15
00:00:59,970 --> 00:01:06,720
So this is going to give us our random value and return back essentially a random color.

16
00:01:06,750 --> 00:01:10,310
So now instead of red and this actually color should be the same.

17
00:01:10,680 --> 00:01:17,610
So as we're coming in here, let's set we can call it pipe color so that both of them are colored the

18
00:01:17,610 --> 00:01:25,140
same and then updating the value of red to equal the pipe color and then this one as well to equal the

19
00:01:25,140 --> 00:01:25,800
pipe color.

20
00:01:26,700 --> 00:01:33,510
And now when we refresh it and we start the game, so try that one more time and you can see now the

21
00:01:33,510 --> 00:01:38,270
pipes are going to be of differing colors and we've got quite a bit of spacing between them.

22
00:01:38,790 --> 00:01:41,810
So we also want to adjust that as well to improve the gameplay.

23
00:01:42,330 --> 00:01:47,340
So see, now, every time they show up there, different colors and then everything else is still the

24
00:01:47,340 --> 00:01:47,570
same.

25
00:01:47,580 --> 00:01:49,690
If you collide with them, the game is over.

26
00:01:50,340 --> 00:01:56,520
So that's one of the additions and extensions you can do within the gameplay to improve the output for

27
00:01:56,520 --> 00:01:56,970
the player.

28
00:01:57,150 --> 00:01:58,320
So go ahead and add that in.

29
00:01:58,320 --> 00:01:59,370
Try to yourself.
