main () { char gameBoard[4][9]; genBoard(gameBoard); int playing = 1; printBoard(gameBoard); while (playing) { printf("White's Turn\n\n"); placePiece(gameBoard, WHITE); printBoard(gameBoard); if(playing) { printf("White's Turn\n\n"); rotateSquare(gameBoard); printBoard(gameBoard); if (playing) { printf("Black's Turn\n\n"); placePiece(gameBoard, BLACK); printBoard(gameBoard); if(playing) { printf("Black's Turn\n\n"); rotateSquare(gameBoard); printBoard(gameBoard); } } } } return 0; }
void rotateCC(char arr[4][9], int sector) { char nboard[4][9]; genBoard(nboard); int i, j, k; for(i=0;i<4;i++) { if (i != sector) { for(j=0;j<9;j++) { nboard[i][j]=arr[i][j]; } } } nboard[sector][0] = arr[sector][2]; nboard[sector][1] = arr[sector][5]; nboard[sector][2] = arr[sector][8]; nboard[sector][3] = arr[sector][1]; nboard[sector][4] = arr[sector][4]; nboard[sector][5] = arr[sector][7]; nboard[sector][6] = arr[sector][0]; nboard[sector][7] = arr[sector][3]; nboard[sector][8] = arr[sector][6]; for(k=0;k<9;k++) { arr[sector][k]=nboard[sector][k]; } }
void test(int width, int height){ b_color *board = genBoard(width,height); if(board==NULL){ printf("invalid arguments\n"); return; } initBoard(board,width,height); printBoard(board,width,height); free(board); }
int main() { initscr(); noecho(); genBoard(board); int ch; timeout(100); while (1) { ch = getch(); if (ch == 32) /* spacebar */ usleep(5); else usleep(10000); updateBoard(board); drawBoard(board); usleep(UPDATELENGTH); } endwin(); return 0; }