const width = 400; const height = 400; const d = 1; let x, y; function setup() { createCanvas(width, height); background(255); x = width / 2; y = height / 2; stroke('#AA00FF'); strokeWeight(d); } function draw() { point(x, y); let r = ceil(random(0, 4)); if (r == 1) y -= d; else if (r == 2) y += d; else if (r == 3) x -= d; else x += d; } function mousePressed() { background(255); x = width / 2; y = height / 2; }