Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9059665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T15:02:10+00:00 2026-06-16T15:02:10+00:00

I’m creating a small game just like the game Reversi/Othello I have managed to

  • 0

I’m creating a small game just like the game Reversi/Othello I have managed to created a 2×3 board with buttons.

The buttons change colour ones you click on them but I’m having trouble to detect if there is a white colour in between 2 black colours and if so change that white colour into black.. I hope this make sense. the buttons are in a 2D array. Any suggestions that could help me do this would be much appreciated.

The image:

enter image description here
Here is my code:

![namespace reversitest
{
    public partial class Form1 : Form
    {

        private Button\[,\] squares;
        public Form1()
        {
            InitializeComponent();

            squares = new Button\[3, 2\];
            squares = new Button\[,\] {{button1,  button2,  button3},
                {button4,  button5,  button6,}};
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            foreach (Button sqrr in squares)
            {
                sqrr.Click += new System.EventHandler(this.DrawCharacter);
            }
        }
        int _turn = 0;
        private void DrawCharacter(object sender, EventArgs e)
        {
            Button sqrr = (Button)sender;
            int col = 0;

            if (sqrr.BackColor.Equals(Color.Black) || sqrr.BackColor.Equals(Color.White))
            {
                MessageBox.Show("Move Not Allowed!");
            }
            else 
            {
               for ( int i = 0; i < squares.GetLongLength(1); ++i)
               {

                  // check othere squares and change color
                   if (i < 2)
                   {
                       for (int f = 0; f < 3; ++f)
                       {
                           var ss = squares\[i, f\];
                           if (ss.BackColor.Equals(Color.Black))
                           {

                               MessageBox.Show("we have a black");

                               //ss = squares\[i, f+1\];
                               ss.BackColor = Color.Black;

                           }
                           else
                           {
                               MessageBox.Show("no black");
                           } 
                       }

                   }

                       if (_turn == 0)
                       {
                           _turn = 1;
                           sqrr.BackColor = Color.Black;


                       }
                       else
                       {
                           _turn = 0;
                           sqrr.BackColor = Color.White;


                       } 

               }


            }


        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T15:02:11+00:00Added an answer on June 16, 2026 at 3:02 pm

    First name your buttons with the array index. It will help you to find the button.
    For example according to you picture button1 name would be btn_1_1.

    Then inside your button click event first get the button name and then identify the button positioned.

            Button b = sender as Button;
            string[] btnData = b.Name.Split('_');
            int x = int.Parse(btnData[1]);
            int y = int.Parse(btnData[2]);
    
            //check for possible combinations 
            int top = y - 2;
            int botton = y + 2;
    
            int left = x - 2;
            int right = x + 2;
    
            if (top >= 0 && squares[top, y].Background == Color.Black)
            {
                squares[top+1, y].Background = Color.Black;
            }  
            ...  
            ...   
    

    Continue like that. If you need more detail please free to ask.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have just tried to save a simple *.rtf file with some websites and
I have a small JavaScript validation script that validates inputs based on Regex. I
I have an array which has BIG numbers and small numbers in it. I
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I used javascript for loading a picture on my website depending on which small
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.