处理:如何分屏?

发布于 2024-11-28 20:09:12 字数 114 浏览 2 评论 0原文

我正在尝试使用处理创建多人游戏,但不知道如何将屏幕分成两部分以显示玩家的不同情况?

就像在 c# 中一样,我们有 视口左视口,右视口; 来解决问题。

多谢

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
Viewport leftViewport,rightViewport;
to solve the problem.

Thanks a lot

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

谁的新欢旧爱 2024-12-05 20:09:12

在处理所有绘图操作(如 rect、eclipse 等)时,都是在 PGraphics 元素上完成的。您可以使用您选择的渲染器创建两个新的 PGraphic 对象,在它们上绘制并将它们添加到您的主视图中:

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);


}

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);


}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文