Split-Screen Mouse click Interaction

Hi, I’m super new to programming and I’ve just been stuck on the same problem for the past few days and I couldn’t find anything on the forums that could help me out. I’m trying to split the screen in two, so that when you click with your mouse on one side, a circle or a square is made and if you click on the other side of the frame a different object is made, couldn’t work out how to segment the screen, think height and width have something to do with it. Any help would be much appreciated. Thank you so much!

Hi @JayT808s,

Welcome to the forum! :wink:

If you don’t know something in Processing a good place to start is to see the available variables and functions you can use in the reference:

Let’s summarize what you want to do:

I’m trying to split the screen in two, so that when you click with your mouse on one side, a circle or a square is made and if you click on the other side of the frame a different object is made

You can then check those links:

Hello @JayT808s !

To start, first try and draw two different coloured rectangles for the canvas of each half of the screen, ie.

void draw() {
  
  // draw background
  noStroke();
  
  // left half
  fill(0, 255, 0); // green
  rect(0, 0, width/2, height);
  
  // right half
  fill(0, 0, 255); // blue
  rect(?, ?, ?, ?);
  
}

Can you figure out what values to put in the rect() function to draw the right half?

1 Like