//Written by Justin Todd. //The code is well commented and I would recommend it to any beginners just learning to program games with allegro #include #include"ttt.h" int GameBoard[MAX_SQUARES][MAX_SQUARES]; //Create the gameboard array void Change_Turn(){ //This function changes the turn. ex. If it was just player X's turn, make it 0's if(WhosTurn==PLAYER_X) WhosTurn=PLAYER_O; else WhosTurn=PLAYER_X; } int Check_Win(){ //Returns the winner for(x=PLAYER_X;x<=PLAYER_O;x++){ //CHECK ROWS FOR A LINE if((GameBoard[0][0]==x)&&(GameBoard[1][0]==x)&&(GameBoard[2][0]==x)) return x; if((GameBoard[0][1]==x)&&(GameBoard[1][1]==x)&&(GameBoard[2][1]==x)) return x; if((GameBoard[0][2]==x)&&(GameBoard[1][2]==x)&&(GameBoard[2][2]==x)) return x; //CHECK COLUMNS FOR A LINE if((GameBoard[0][0]==x)&&(GameBoard[0][1]==x)&&(GameBoard[0][2]==x)) return x; if((GameBoard[1][0]==x)&&(GameBoard[1][1]==x)&&(GameBoard[1][2]==x)) return x; if((GameBoard[2][0]==x)&&(GameBoard[2][1]==x)&&(GameBoard[2][2]==x)) return x; //CHECK '\' DIAGONAL FOR A LINE if((GameBoard[0][0]==x)&&(GameBoard[1][1]==x)&&(GameBoard[2][2]==x)) return x; //CHECK '/' DIAGONAL FOR A LINE if((GameBoard[0][2]==x)&&(GameBoard[1][1]==x)&&(GameBoard[2][0]==x)) return x; } return FALSE; //If nobody has won yet, return false } void Clear_GameBoard(){ for(x=0;x0)) Selected_H--; //Move the highlighted square to the left if inbounds if((key[KEY_RIGHT])&&(Selected_H0))Selected_V--; //Move the highlighted square to the up if inbounds if((key[KEY_DOWN])&&(Selected_V