Hi Everyone,
I’m new to Processing and can’t figure out a couple things about the code below.
-
When I execute the code, it draws either one line or no line at all. Maybe one out of every 4 or 5 runs actually draws a line. Why is that?
-
Why does it only draw one line (or none), despite the fact that x is incrementing? The code “x = x + 20;” is right before “line (0,800,x,0);”.
I’m sure I’m missing something really basic. Can someone please explain?
Thanks!
int time = 0;
int x = 20;
void setup()
{
size (1200, 800);
noSmooth();
background(255);
}
void draw()
{
while (x < 1200)
{
if ( millis() > time )
{
time = millis() + 500;
x = x + 20;
line (0,800,x,0);
println(x);
}
}
}