While loop question

Any variable declared outside draw() will retain the value it has between calls to draw (frames). So it’ll be 0 the first frame, and some value over width for every frame afterwards, because the loop keeps adding 20 to it until it is.

The x = 0 resets the value back to zero for the next frame, and so on.

1 Like