clone git@github.com:gojohnnygo/ttt.git
cd ttt
yarn install
yarn start
- FUN - Endless tic-tac-toe fun with friends
- EASY TO USE - Drop it into any React + Typescript project
- FLEXIBLE - Play traditional 3x3 tic-tac-toe up or up 20x20. The game engine is flexible and can handle different types of game play with just a little tweaking. Do you want the win condition to be different than the board size? No problem! Do you want to play Connect Four? Doable! Pull requests are welcome. :)
- Add the
ttt
folder to your project - Import and use the componet
import Board from './ttt/Board';
export default function App() {
<Board />
}
By default TTT comes with three controls:
- Resetting to default
- Incrementing board size (max 20x20)
- Decrementing board size (min 3x3)
If you want to implement your own controls, you can easily do so with Refs. Functions exposed to you are:
reset()
increment()
decrement()
import Board, {BoardRef} from './ttt/Board';
export default function App() {
const boardRef = useRef<BoardRef>(null);
return (
<div className="app">
<Board ref={boardRef}/>
<div>
<button onClick={() => boardRef.current?.reset()}>
Reset Default
</button>
<button
onClick={() => boardRef.current?.increment()}
>
Increase Board Size
</button>
<button
onClick={() => boardRef.current?.decrement()}
>
Decrease Board Size
</button>
</div>
</div>
);
}
This demo was bootstrapped with Create React App.