xxxxxxxxxx
29
let x = 10;
let y = 10;
function setup() {
createCanvas(300, 300);
}
function draw() {
++x;
background('green');
fill('yellow');
rect(x, y, 10, 10);
}
function keyPressed() {
if (key === 'ArrowRight') {
++x;
}
if (key === 'ArrowLeft') {
--x;
}
if (key === 'ArrowUp') {
--y;
}
if (key === 'ArrowDown') {
++y;
}
}