public Form1(String gameMode) { gameModes = gameMode; if (gameMode == "M3S") //if the gameMode is M3S then the user is playing suicide chess { suicide = true; } board = generation.GenerateBoard(); //Generate the board pictureBoxesB = new PictureBox[15]; int z = 330; int y = 60; if (gameMode == "M1B" || gameMode == "M2B") //if the gameMode is M1B or M2B then the game is timed { WhiteSeconds = gameMode == "M1B" ? 600 : 60; //and the time is set accordingly BlackSeconds = WhiteSeconds; timed = true; } foreach (PictureBox x in pictureBoxesB) //Generates the interface where taken black pieces are stored { PictureBox newPictureBox = new PictureBox { Size = new Size(25, 25), BackgroundImageLayout = ImageLayout.Stretch, }; newPictureBox.Location = new Point(z, y); z += 25; if (z > 505) { z = 330; y += 25; } pictureBoxesB[bPiecesTaken] = newPictureBox; Controls.Add(pictureBoxesB[bPiecesTaken]); bPiecesTaken++; } pictureBoxesW = new PictureBox[15]; z = 330; y = 215; bPiecesTaken = 0; foreach (PictureBox x in pictureBoxesW) //Generates the interface where taken white pieces { PictureBox newPictureBox = new PictureBox { Size = new Size(25, 25), BackgroundImageLayout = ImageLayout.Stretch, }; newPictureBox.Location = new Point(z, y); z += 25; if (z > 505) { z = 330; y += 25; } pictureBoxesW[bPiecesTaken] = newPictureBox; Controls.Add(pictureBoxesW[bPiecesTaken]); bPiecesTaken++; } foreach (Panel x in board) { x.MouseEnter += new EventHandler(panel_MouseEnter); x.MouseLeave += new EventHandler(panel_MouseLeave); x.MouseDown += new MouseEventHandler(panel_MouseDown); Controls.Add(x); } //Add the action events to the panels and then render the panels. bPiecesTaken = 0; InitializeComponent(); if (gameMode == "M1B" || gameMode == "M2B") //formats the time to display in minutes { label4.ForeColor = Color.Red; label3.Text = gameMode == "M1B" ? "10:00" : "01:00"; label4.Text = label3.Text; } timer1.Start(); //starts the timer }