如何将变量重置为其完整值?

时间:2017-11-02 03:16:46

标签: processing modulo

我如何将y重新设置为完全值?模运算符在x上运行,因为变量从0开始并且一直增加到宽度,但是我无法弄清楚要写什么来将其重置为完全值。我不能使用超过2个声明的变量。谢谢你的帮助。

int y=height;
int x=0;

void setup()
{
    size(100,100);
    frameRate(30);
}

void draw()
{
    background(200);
    line(0,y,width,y); //bottom to top
    line(0,x,width,x); // top to bottom
    line(y,0,y,height); //left to right
    line(x,0,x,height); //right to left
    y=y-1;
    x = (x+1) % width;
}

1 个答案:

答案 0 :(得分:0)

您可以使用(l)stat()语句在变量达到某个值时重置该变量。像这样:

if

无耻的自我推销:我在Processing中编写了一个关于动画的教程,包括这种重置技术,可用here

相关问题