Need help with using multi-color LEDs and buttons

Hello, what Im trying to make is a simple game that uses 6 multi-color LEDs and 6 buttons. BUT before I connect 5 LEDs and 5 buttons, Im doing some experiment with using only 1 LED and 1 button. The game is...

  1. when LED turns on the RED color, the player needs to push the RED button and the lights turns off.
  2. Then LED turns on the BLUE color, the player needs to push the BLUE button and the lights turns off.
  3. (Actually, the color of LED) turns on randomly.

I need some help. Below is the code that I wrote and I`m stuck in the 'BUTTON' part. How can I solve?
Thanks.

int redLed = 9;
int greenLed = 10;
int blueLed = 11;
int BUTTON1 = 13;

int buttonstate1 = 0;

long randNumb;

void setup()
{
pinMode(redLed, OUTPUT);
pinMode(greenLed, OUTPUT);
pinMode(blueLed, OUTPUT);
pinMode(BUTTON1, INPUT);
}

void red()
{
analogWrite(redLed, 255);
analogWrite(greenLed, 0);
analogWrite(blueLed, 0);
}

void orange()
{
analogWrite(redLed, 255);
analogWrite(greenLed, 35);
analogWrite(blueLed, 255);
}

void yellow()
{
analogWrite(redLed, 255);
analogWrite(greenLed, 255);
analogWrite(blueLed, 0);
}

void green()
{
analogWrite(redLed, 0);
analogWrite(greenLed, 255);
analogWrite(blueLed, 0);
}

void blue()
{
analogWrite(redLed, 0);
analogWrite(greenLed, 0);
analogWrite(blueLed, 255);
}

void pink()
{
analogWrite(redLed, 255);
analogWrite(greenLed, 0);
analogWrite(blueLed, 162);
}

void loop()
{
buttonstate1 = digitalRead(BUTTON1);
randNumb = random(1, 6); // Generate a random number between 1 and 6

if(randNumb == 1){
red();
}
if(randNumb == 2){
orange();
}
if(randNumb == 3){
yellow();
}
if(randNumb == 4){
green();
}
if(randNumb == 5){
blue();
}
if(randNumb == 6){
pink();
}

//I think I need to do something with below

if(buttonstate1 == LOW) {
analogWrite(redLed, LOW);
analogWrite(greenLed, LOW);
analogWrite(blueLed, LOW);
} else {
(buttonstate1 == HIGH);
}

}

You haven't said what is supposed to happen if the user pushes, or doesn't push, the button.

Without knowing that, it's impossible to advise you how to implement that.

Thanks Peter,

I modified a bit, explaining what happen if the user pushes or doesn`t push the button,

  1. when LED turns on the RED color, the player needs to push the RED button and the lights turns off.
  2. Then LED turns on the BLUE color, the player needs to push the BLUE button and the lights turns off.
  3. (Actually, the color of LED) turns on randomly.

For example, RED button turns the RED light off, and GREEN button turns the GREEN light off. but I`m using RGB LED. that each LEDs turns on different colors randomly .

Forget the code, for a minute.

The loop() function is called in an infinite loop. As your code is written now, the LEDs are flashing colors completely independent of switch events. You apparently need some delay, don't you, so that the LED color(s) remain constant for some period of time. You need three switches to control each of the three colors.

Write out the rules of the game, first. It would appear that you are making them up as you go along. Once the rules are defined, then you can write the code from the computer's point of view. Then, add code that implements the player's input.

How will the game end? How will a win/lose decision be made?

You can't write code to implement a game until you know the rules, and we can't help you until we know the rules.