/*draw board (DONE) Know when someone wins Find the OPEN spots on the board Who goes first Who's turn it is */ //var playerTurn = "playerX"; var playerTurn = "playerO"; var x0 = 50; var x1 = 150; var x2 = 250; var x3 = 350; var y0 = 50; var y1 = 150; var y2 = 250; var y3 = 350; strokeWeight(10); line(x0, y2, x3, y2); line(x0, y1, x3, y1); line(x2, y0, x2, y3); line(x1, y0, x1, y3); var swichTurn = function () { if ( playerTurn === "playerX") { playerTurn = "playerO"; } else { playerTurn = "playerX"; } }; mouseClicked = function() { if (mouseX < 150 && mouseY < 150) { if (playerTurn === "playerX"){ line(x1, y1, x0, y0); line(x0, y1, x1, y0); } else { ellipse( 100, 100, 60, 60); } } if (mouseX < 150 && mouseY > 250) { if (playerTurn === "playerX") { line(x0, y3, x1, y2); line(x1, y3, x0, y2); } else { ellipse( 100, 300, 60, 60); } } if (mouseX < 150 && mouseY < 250 && mouseY > 150 ) { if (playerTurn === "playerX") { line(x0, y2, x1, y1); line(x1, y2, x0, y1); } else { ellipse( 100, 200, 60, 60); } } if (mouseX > 250 && mouseY < 150) { if (playerTurn === "playerX") { line(x2, y1, x3, y0); line(x3, y1, x2, y0); } else { ellipse( 300, 100, 60, 60); } } if (mouseX > 250 && mouseY < 250 && mouseY > 150) { if (playerTurn === "playerX") { line(x2, y2, x3, y1); line(x3, y2, x2, y1); } else { ellipse( 300, 200, 60, 60); } } if (mouseX > 250 && mouseY > 250) { if (playerTurn === "playerX") { line(x2, y3, x3, y2); line(x3, y3, x2, y2); } else { ellipse( 300, 300, 60, 60); } } if (mouseX > 150 && mouseX < 250 && mouseY > 150 && mouseY < 250 ) { if (playerTurn === "playerX") { line(x1, y2, x2, y1); line(x2, y2, x1, y1); } else { ellipse( 200, 200, 60, 60); } } if (mouseX > 150 && mouseX < 250 && mouseY < 250 && mouseY < 150 ) { if ( playerTurn === "playerX") { line(x1, y1, x2, y0); line(x2, y1, x1, y0); } else { ellipse( 200, 100, 60, 60); } } if (mouseX > 150 && mouseX < 250 && mouseY > 250 && mouseY > 150) { if ( playerTurn === "playerX") { line(x1, y3, x2, y2); line(x2, y3, x1, y2); } else { ellipse( 200, 300, 60, 60); } } swichTurn(); };