xxxxxxxxxx
51
/*
Inspired by the classic Windows Mystify screensaver
Based on code translation from Chris DeLeon's Programming in 5 minutes: remaking “Mystify Your Mind” Windows 95-style screensaver effect
https://www.youtube.com/watch?v=-X_A1Hqj-qA
*/
class mover {
constructor() {
this.xa = random(width);
this.ya = random(height);
this.xb = random(width);
this.yb = random(height);
this.xa_speed = random(-10, 10);
this.ya_speed = random(-10, 10);
this.xb_speed = random(-10, 10);
this.yb_speed = random(-10, 10);
}
}
function setup() {
createCanvas(windowWidth, windowHeight);
stroke(255);
strokeWeight(2);
}
function draw() {
background(0, 10);
line(x, x, x, x);
x.speed += x.speed;
if (x < 0 || x > width) x1a.speed *= -1;
line(x, x, x, x);
x.speed += x.speed;
if (x < 0 || x > width) x2a.speed *= -1;
}
function windowResized() {
resizeCanvas(windowWidth, windowHeight)
}