Sign in to follow this  

2d array

This topic is 2119 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am still working on my tic tac toe game using c#.I have done alot of research on how to use 2d arrays using c#.I am still confused on how to implement 2d arrays.here is some of the code I am working on.everything looks correct but for some reason I cant get to the drawline command or so it seems.I also stubbed out some code and it seems to work properly.
[source lang = "c#"]
int pX = e.X;
int pY = e.Y;
int row = 0, col = 0;
int[,] board = new int[3, 3];

if (pX >= 10 && pX <= 20 && pY >= 30 && pY <= 40)
{
board[row, col] = 1;
}
if (pX >= 80 && pX <= 90 && pY >= 30 && pY <= 40)
{
board[row, col+1] = 1;
}
if (pX >= 160 && pX <= 170 && pY >= 30 && pY <= 40)
{
board[row, col+2] = 1;
}
if (board[row,col] == 1 && board[row,col + 1] == 1 && board[row,col + 2] == 1)
{
Pen pn = new Pen(Color.Blue, 3);
g.DrawLine(pn, 0, 50, 200, 50);
}
[/source]

Share this post


Link to post
Share on other sites
sorry but I have mangled my code again.
here it is
int pX = e.X;
int pY = e.Y;
int row = 0, col = 0;
int[,] board = new int[3, 3];

if (pX >= 10 && pX <= 20 && pY >= 30 && pY <= 40)
{
board[row, col] = 1;
}
if (pX >= 80 && pX <= 90 && pY >= 30 && pY <= 40)
{
board[row, col+1] = 1;
}
if (pX >= 160 && pX <= 170 && pY >= 30 && pY <= 40)
{
board[row, col+2] = 1;
}
if (board[row,col] == 1 && board[row,col + 1] == 1 && board[row,col + 2] == 1)
{
Pen pn = new Pen(Color.Blue, 3);
g.DrawLine(pn, 0, 50, 200, 50);
}

Share this post


Link to post
Share on other sites

This topic is 2119 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this