I've been trying to create the game "Mastermind" and im trying that when I click the "Show" button, it will generate 3 colours from ROYGBIV.(Already done)
However now I need to do a statement where it will compare the random colours generated. This is part of the code
public partial class Form1 : Form
{
Color[] RandomColor = new Color[7] { Color.Red, Color.Orange, Color.Yellow, Color.Green, Color.Blue, Color.Indigo, Color.Violet };
Random r = new Random();
public Form1()
{
InitializeComponent();
}
private void btnShow_Click(object sender, EventArgs e)
{
btnShow.Text = "Hide";
for (int i = 0; i < RandomColor.Length; i++)
{
int RandomColorNum = r.Next(0, RandomColor.Length);
switch (i)
{
case 1: pnlNPC1.BackColor = RandomColor[RandomColorNum];
break;
case 2: pnlNPC2.BackColor = RandomColor[RandomColorNum];
break;
case 3: pnlNPC3.BackColor = RandomColor[RandomColorNum];
break;
}
}
pnlNPC1.Visible = true;
pnlNPC2.Visible = true;
pnlNPC3.Visible = true;
}
Thanks guys, and all the best!