This going to be a quick bonus lesson adding in color to our pipes.
So right now, by default, we're setting them both to be red and we can actually change that and create
a function in order to accommodate that.
So that function can be.
And then what it will do is it will return back a random color and the color.
There's a number of different ways with JavaScript to do color.
So we know what color it needs are harsh.
And if I use math random, I can return back a random value.
So let's open up our console to see what this looks like in the console as we build it out.
So if we do math random, we get this large random number and then we've got a few methods.
We've got a string method where we can turn it into a base 16 string so we can turn it into that.
And this, again, is going to be a random value.
And we've got one more method that I want to make use of, and that's the sub string.
And we want to only get six characters being returned back.
So this is going to give us our random value and return back essentially a random color.
So now instead of red and this actually color should be the same.
So as we're coming in here, let's set we can call it pipe color so that both of them are colored the
same and then updating the value of red to equal the pipe color and then this one as well to equal the
pipe color.
And now when we refresh it and we start the game, so try that one more time and you can see now the
pipes are going to be of differing colors and we've got quite a bit of spacing between them.
So we also want to adjust that as well to improve the gameplay.
So see, now, every time they show up there, different colors and then everything else is still the
same.
If you collide with them, the game is over.
So that's one of the additions and extensions you can do within the gameplay to improve the output for
the player.
So go ahead and add that in.
Try to yourself.