I'm have to basically remake a game for my final school project. The project is progressing well, but I'm only stuck on a part where I need the black tiles in the game to change color when clicked. The game I'm trying to remake is called "Piano Tiles". To shorten the story, watch this:
https://www.youtube.com/watch?v=4uZPiynHRsw[
^]
So how can I make the black tile(s) change its color when a user clicks on it?
*Note: I already setup the brushes and arrays to be ready for use.
I added 4 brushes that represent the colors of the game tiles:
Here are the variable names
Brush bsh_black, bsh_grey, bsh_white, bsh_red;
Brush bchanger1, bchanger2, bchanger3, bchanger4;
bsh_black = new SolidBrush(Color.Black);
bsh_grey = new SolidBrush(Color.Gray);
bsh_white = new SolidBrush(Color.White);
bsh_red = new SolidBrush(Color.Red);
bchanger1 = bsh_white;
bchanger2 = bsh_white;
bchanger3 = bsh_white;
bchanger4 = bsh_white;
Black - tile you have to press
Grey - When the black tile is pressed
White - The tile you *don't* press
Red - When the you do press the white tile.
Here's what I've tried so far for clicking on the graphic:
if (e.Y == yf1)
{
if (e.X == x2)
{
if (bchanger1 == bsh_black)
{
bchanger1 = bsh_grey;
Invalidate();
}
}
}
if (e.Y == yf1)
{
if (e.X == x4)
{
if (pat_assign == pat4)
{
if (bchanger4 == bsh_black)
{
bchanger4 = bsh_grey;
Invalidate();
}
}
}
}
//The "yf1" variable is the vertical location for the black tile(s). For the game, I decided to divide the form into four columns - where I had to make 4 variables that represent the 4 columns; "x1", "x2", "x3", and an "x4". These columns is where the tiles will run through. But for "prototype" purposes, I used the x4 as the temporary "dummy" variable.
So, in short, if where the user clicks is in the same location as the "yf1" variable and the "x4" variable, that should change that specific tile to a different color. Unfortunately, that didnt work.
P.S: sorry if I wasn't more clear about this earlier, I'm just a high school student.
**I am so sorry, I also forgot to ask how to detect that a graphic has been clicked on (in this case the tile).