处理:在下面的代码中,x=x+1是做什么的?

Processing: In the following code, what does x= x + 1 do?

当运行这段代码时,矩形'moves'从左到右。

void setup() {
  size(400, 400);
  stroke(255);
  background(192, 64, 0);
} 

int hoogte = 50;
int breedte = 50;
int x = 50;

void draw () {
  rect(x,100, breedte, hoogte);
  stroke(181);
  x = x + 1;
}

运行 代码的结果

请记住,draw() 函数每秒调用 60 次。

x = x + 1 行向 x 变量加一。由于您是根据 x 变量绘制矩形,因此矩形会随着时间的推移在屏幕上移动。

无耻的自我推销:here是Processing中讲解动画的教程