Skip to content

Instantly share code, notes, and snippets.

@mohsenheydari
Created January 8, 2019 01:19
Show Gist options
  • Save mohsenheydari/de9c4a7a8c67689e09d1e392e3237712 to your computer and use it in GitHub Desktop.
Save mohsenheydari/de9c4a7a8c67689e09d1e392e3237712 to your computer and use it in GitHub Desktop.
Draw Tic Tac Toe board cells based on array of states
drawCells(boardState){
boardState.forEach(function(el, i){
let x = (i % 3) * this.cellSize;
let y = Math.floor(i/3) * this.cellSize;
if(el === 1){
this.drawX(x, y);
} else if(el === 2){
this.drawO(x, y);
}
}, this);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment