Processing: how to split the screen?

I'm trying to create a multiplayer game with processing, but I can’t figure out how to split the screen into two to reflect the different situation of the players?

as in C #, we have Viewport leftViewport,rightViewport; to solve the problem.

thanks a lot

+4
source share
1 answer

When processing all drawing operations, such as rect, eclipse, etc., the PGraphics element is executed. You can create two new PGraphic objects using the renderer of your choice, draw them and add them to your main view:

 int w = 500; int h = 300; void setup() { size(w, h); leftViewport = createGraphics(w/2, h, P3D); rightViewport = createGraphics(w/2, h, P3D); } void draw(){ //draw something fancy on every viewports leftViewport.beginDraw(); leftViewport.background(102); leftViewport.stroke(255); leftViewport.line(40, 40, mouseX, mouseY); leftViewport.endDraw(); rightViewport.beginDraw(); rightViewport.background(102); rightViewport.stroke(255); rightViewport.line(40, 40, mouseX, mouseY); rightViewport.endDraw(); //add the two viewports to your main panel image(leftViewport, 0, 0); image(rightViewport, w/2, 0); } 
+4
source

All Articles