SOURCE

console 命令行工具 X clear

                    
>
console
let x = 51;
let y = 51
let speed = 3;
let d = 50;
function setup() {
createCanvas(400, 500);
}
function draw() {
background(220);
x += speed
if((x > width-d/2) || (x < d/2)){
speed = - speed;
}
y += speed
if((y > width-d/2) || (y < d/2)){
speed = - speed;
}
ellipse(x, y, d, d);
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.1.9/p5.min.js"></script>