Still working on the tic tac toe, I have almost done the whole coding. Right now I am working on the random picking of players. When even the console.log is working, there is no response from the system. Would like to ask where the problem is? Thanks!
You have a noLoop() in draw(), that’s why nothing happens.
That’s not how you want to handle your turn.
Your draw needs to keep drawing the game, but what needs to be drawn needs to change over time.
For example in the following code, the canvas is constantly drawn. When the mouse is clicked, a new ellipse is created and then displayed in the for loop of the draw() function.
let ellipses = [];
function setup() {
createCanvas(400, 400);
ellipses.push(createVector(20, 20));
}
function draw() {
background(20);
noStroke();
fill(220);
for (let i = 0; i < ellipses.length; i++) {
let x = ellipses[i].x;
let y = ellipses[i].y;
ellipse(x, y, 10, 10);
}
}
function mouseClicked() {
ellipses.push(createVector(mouseX, mouseY));
}
Thanks! Then I kinda get it. Does it mean that when it is in function setup( ), the p = random(players) apply to every turn of the game, instead of only applying to first turn when it is in function draw( )?