sclass AnimatedLine > Animation { int maxSpeed = 1; int y, speed; void start { y = random(h); newSpeed(); } void newSpeed { speed = random_incl(-maxSpeed, maxSpeed); } void paint { fillRect(g, 0, 0, w, h, Color.white); drawLine(g, 0, y, w, y, Color.black); } void nextFrame { if (oneIn(20)) newSpeed(); y = clamp(y+speed, 0, h-1); } }