xxxxxxxxxx
33
let xstart, ystart;
let xspeed, yspeed;
let x, y;
let scl;
function setup() {
createCanvas(windowWidth, windowHeight);
xstart = 200;
ystart = 355;
scl = 0.5;
reset();
xspeed = 2;
yspeed = 3;
}
function reset() {
x = xstart;
y = ystart;
}
function draw() {
background(0);
x += xspeed * scl;
y += yspeed * scl;
stroke(255);
line(xstart, ystart, x, y);
if (x < 0 || x > width || y < 0 || y > height) {
reset();
}
}