I am designing a 8x8 2d array checkers game. How can I select a character to print the hyphen '-' on the top and bottom of the character and by moving the hyphen to select the character I want. Let's say the character 'x' is selected, I can move the hyphen '-' to select the 'x' that I want.
But my code is not working, I really need help. I had attached the sample below.
Code:
int gameboard(char board[8][8])
{
int x, y;
for(x=0; x<8; x++)
{
for(y=0; y<8; y++)
{
printf("=---=");
}
printf("\n\n");
for(y=0;y<8;y++)
{
printf("| %c |",board[x][y]);
}
printf("\n\n");
}
for(x=0;x<8;x++)
{
printf("=---=");
}
}
void character(char board[8][8]){
int x,y;
for(x=0;x<8;x++){
for(y=0;y<8;y++){
if(x<3){
if(x%2 == 0){
if(x%2 == 0){
board[x][y] = 'O';
}
if(y%2==1){
board[x][y]= ' ';
}
}
if(x%2 == 1){
if(y%2 == 0){
board[x][y] = ' ';
}
if(y%2 ==1){
board[x][y]= 'O';
}
}
}
if((x==3) || (x==4)){
board[x][y] = ' ';
}
if(x>4)
{
if(x%2 == 0){
if(y%2 == 0){
board[x][y] = 'X';
}
if(y%2 ==1){
board[x][y]= ' ';
}
}
if(x%2 == 1){
if(y%2 == 0){
board[x][y] = ' ';
}
if(y%2 ==1){
board[x][y]= 'X';
}
}
for (x = 0; x < 8; x++) {
for (y = 0; y < 8; y++) {
if (x == 5 && y == 1) {
board[x-1][y] = '-';
board[x+1][y] = '-';
}
}
}
}
}
}
}
This is what is want.[sample]