I would love some help on this code I am extremely stuck

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.


This is my code right now am I doing the var xCoor Correctly?

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() {

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