xxxxxxxxxx
47
// Baseline x-position ratio
let inset = 0.51;
// x-position of mover
let x;
// y-position of mover
let y = 80;
function setup() {
createCanvas(400, 800);
// Initialize the mover
x = inset * width;
}
function draw() {
background(220);
stroke('red');
strokeWeight(10);
// Move for the first 20 frames or until
// you get to 20% of the canvas width
if (x > 0.2 * width && frameCount < 20) {
// Update x
x = x - 10;
y = y + 0.1;
}
// Wait until after 4 seconds and move for another second
else if(frameCount > 240 && frameCount < 300) {
x = x + 1;
y = y - 0.1;
}
// Print x,y position to the console below
// console.log("POSITION", x, y);
// Moving point
point(x, y);
// Everyone else
point(inset * width, 160);
point(inset * width, 240);
// This point is at 1/2 of the standard inset
point(0.5 * inset * width, 320);
point(inset * width, 400);
point(inset * width, 480);
point(inset * width, 540);
}