jeongwhanchoi / tic-tac-toe-lpc1768

The Tic-Tac-Toe game on ARM LPC 1768

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Tic-Tac-Toe

MIT LicenceGitHub code size in bytesGitHub repo size in bytes Imgbot

If you use this project, please reference the repository :)

Table of Contents

Tic-Tac-Toe Game lpc 1768 Project

What is the Tic-Tac-Toe game?

Tic-tac-toe is a paper-and-pencil game for two players, X and O, who take turns marking the spaces in a 3×3 grid. The player who succeeds in placing three of their marks in a horizontal, vertical, or diagonal row wins the game.

The following example game is won by the first player, X:

Flow Chart

flowchart

Above is a flow chart showing Tic-Tac-Toe's algorithm. We made a 1-D array with a size of 9 corresponding to the Tic-Tac-Toe board, and gave values from 1 to 9.

And if you press the keypad, O or X is entered in the corresponding position array and the number of turn increases. If these inputs are repeated over and over again, the game ends and the winner is output. If there is no winner and the number of turn reaches 9, the Tic-Tac-Toe board is full with O or X, so the game ends and a draw is output.

Interface

Game Display

Intro GUI

tttintro

Game GUI

tttgame

Game Play

tttox

  • printOX()
    • Output O or X in the corresponding cell ((x,y) coordinates)
    • The turn is output as the ASCII code value:
      • ASCII code of O is 79
      • ASCII code of X is 88
void printOX(int input, int x, int y, int *turn)		// print O and X at (x,y) coordinates
{
	if(array[input-1] == 79 || array[input-1] == 88 )		// if the array already has O or X (TO PREVENT DUPLICATE ENTRIES)
		{
			GLCD_displayStringLn(Line1, "*     TRY AGAIN    *");
			Delay(SEC_1);
		}
		else		// there are empty entries
			{
				array[input-1] = *turn;		// input O or X
				GLCD_displayChar(x, y, *turn);		// print O and X at (x,y) coordinates
				changeTurn(&*turn);
				count++;		// increment the count
			}
}

Player O Win Result

tttwin

  • if winFlag is not zero(0), display "Player O Win"

tttwinresult

The game end in a draw

  • if winFlag is zero, display "DRAW"

tttdrawresult

About

The Tic-Tac-Toe game on ARM LPC 1768

License:MIT License


Languages

Language:HTML 85.9%Language:C 14.1%