Jump to content

VB Color Matching Game - Need help w/ arrays, indecies, and buttons

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
3 replies to this topic

#1
napoleonrokz

napoleonrokz

    Newbie

  • Members
  • Pip
  • 3 posts
Hi I'm trying to do a color matching program. The game is going to have "grids" of buttons (Ex. 2x2 5x5 7x7). There will be a set number of colors the buttons can be. The buttons will start at a random assortment. The goal is to get all of them to all be the same color by clicking them. Each button clicked will change it's own color along with it's neighbor's colors.

It will look like this:

Ex. 2x2 - 3 colors

http://www.programmi...=1&d=1289686720

Right now I have the arrays set up. I'm having a problem figuring out how I'm going to associate them with each button correctly.

Public Class Form1

     Public arrColors() = {Color.Green, Color.Blue, Color.Black}

     Public arrIndecies(,) = {{0, 0}, {0, 0}}

End Class

If I could be shown how to get one button set up then I'm sure I could get this. Your help will be greatly appreciated.

Thank you for your time!

I'm using Visual Studio 2010 Express.

#2
Vswe

Vswe

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 9,552 posts
How do you create these buttons? At design time or run time?

#3
napoleonrokz

napoleonrokz

    Newbie

  • Members
  • Pip
  • 3 posts
I created them in design mode, if that's what you mean. You have to excuse me as I'm still a little new to Visual Basic.

It may also be important for me to say that I'm changing the color of the background to these buttons. So I know I need to be using the BackColor property.

#4
Vswe

Vswe

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 9,552 posts
You could add all buttons to a 2D array and add a Tag at each button telling its index so you can use that to find the neighbors. The solution isn't very pretty but other solutions would need very complicated code.