I can’t get the square to go with the coordinate. I don’t know why its not syncing.
Break the problem down into steps.
You know you have four cases.
So for the first step, determine which one of the four cases you have.
Then, once you know which case it is, draw a square in the right place.
It’s impossible to help you more without seeing your current code.
2 Likes
I think you’ve misunderstood the task.
The xCoor
and yCoor
values are NOT the position of the yellow square. They are a point that could be anywhere. Your job is to determine which quadrant the point (xCoor, yCoor)
is in, and then highlight that quadrant in yellow.
Your code should look like this:
var xCoor = random(400);
var yCoor = random(400); // Notice I have filled these in with a random value.
function setup() {
createCanvas(400,400);
background(0);
}
void draw() {
// Step 1: Determine which case is happening this time.
// TODO - Work out which quadrant the random point is in.
// Step 2: Draw a yellow square in the right place.
// TODO - Draw one of the four possible cases.
// NOTE: The correct position for the yellow square is NOT (xCoor, yCoor) !
}
1 Like