开发者

Processing: How to split screen?

I'm trying to create a multi-player game with Processing, but can't figure out how to split screen into two to display different situation of the players?

like in c#,we have 开发者_JAVA技巧Viewport leftViewport,rightViewport; to solve the problem.

Thanks a lot


In processing all drawing operations like rect, eclipse etc. are done on a PGraphics element. You could create two new PGraphic objects with the renderer of your choice, draw on 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);


}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜