SOURCE

console 命令行工具 X clear

                    
>
console
class ball{
    constructor(X,Y,D,Tspeedx,Tspeedy)
    {
    this.ballx=X
    this.bally=Y
    this.d=D
    this.ballspeedx=Tspeedx
    this.ballspeedy=Tspeedy
    this.angle=(0)
    }

translating(){
    push()
    translate(this.ballx,this.bally)
    this.ballx +=random(-Tspeedx,Tspeedx)
    this.bally +=random(-Tspeedy,Tspeedy)
    }

drawing(){
    fill(255)
    ellipise(0,0,D)
    pop()
}
}
let Tspeedx;
let Tspeey;
let rotatingSquareC;
function setup(){
    createCanvas(600,600);
    background(200);
    rectMode(CENTER);
    rotatingSquare = new RotatingSquare(300,300,30,80,5,0.2);
}
function draw(){
    rotatingSquare.translating();
    rotatingSquare.rotating();
    rotatingSquare.drawing();
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.1.9/p5.min.js"></script>