Diagonal isn't much more difficult than horizontal or vertical. However, you're going to have a hell of a time finding four in a row if your board is only 3x3. :-)
To do a diagonal check, start at the first peice, and then go up and to the right one. If that is outside the grid, stop.
Then move down to the peice below, and go up and to the left, and then up and to the left, and stop because that is outside the grid.
Once you get to the bottom of the grid, do that diagonal line, and then step over one to the right along the bottom, and go up and to the left, etc, till you get outside the grid, and then step to the right again to do the next diagonal row until you get all the way to the right of the board, and then you're done.
That will do this diagonal: /
Now to do this diagonal: \
Do the same thing, but instead of going down the left side first go across the top, and then down the right side. And when stepping from square to square go down and to the left instead of up and to the right.
Of course if you are doing tic tac toe, then you only have to check the two middle diagonals, and that is really simple. You can't get three in a row any other way diagonally in tic tac toe.
To do a diagonal check, start at the first peice, and then go up and to the right one. If that is outside the grid, stop.
Then move down to the peice below, and go up and to the left, and then up and to the left, and stop because that is outside the grid.
Once you get to the bottom of the grid, do that diagonal line, and then step over one to the right along the bottom, and go up and to the left, etc, till you get outside the grid, and then step to the right again to do the next diagonal row until you get all the way to the right of the board, and then you're done.
That will do this diagonal: /
Now to do this diagonal: \
Do the same thing, but instead of going down the left side first go across the top, and then down the right side. And when stepping from square to square go down and to the left instead of up and to the right.
Of course if you are doing tic tac toe, then you only have to check the two middle diagonals, and that is really simple. You can't get three in a row any other way diagonally in tic tac toe.