【发布时间】:2015-02-23 03:09:17
【问题描述】:
有人可以帮我写代码吗?一旦它从右侧移开,我试图让正方形再次出现在窗口的左侧。我几乎拥有它,但是一旦它离开右侧,它就会突然出现在左侧。我需要帮助使它在屏幕左侧平滑显示。
这是我的代码。
float x = 0;
void setup() {
size(200,200);
}
void draw() {
background(255);
drawRect();
if(x > width+5) {
x = 0;
}
}
void drawRect() {
fill(0);
for (int i = 0; i<width; i+=15){
rect(x +i*2,100,20,20);
}
x = x + 1;
}
【问题讨论】:
标签: if-statement processing void rect