I have this snippet of p5.js code:
let x = 10;
let y = Math.floor(Math.random()*201);
let x2 = 190;
let y2 = 200 - Math.floor(Math.random()*201);
function setup() {
createCanvas(200, 200);
}
function draw() {
clear();
y = Math.floor(Math.random()*201);
y2 = 200 - Math.floor(Math.random()*201);
line(10, y, 190, y2);
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.9.0/p5.js"></script>
and I want to make it so that it runs once automatically, then again every time a button is pressed.
My main concern here is the "run only once" bit, so if anyone can help me out with that, it'd be great.