SOURCE

console 命令行工具 X clear

                    
>
console
let a=55;
let x=55;
let y=71;
let d=80;
let speedx = 20;
let speedy = 25;
let c=5;
let h=1
function setup() {
    createCanvas(500, 500);
    noStroke();
    colorMode(HSB,360,100,100);
    }
function draw(){
  if(c>155||c<=0){
    h=-h;
    }
    x += speedx;
    y += speedy;
    if((x > width-d/2) || (x < d/2)){
        speedx = - speedx;
    }
    if((y > width-d/2) || (y < d/2)){
        speedy = - speedy;
    }
    fill(c,55,90)
      triangle(x,y,x+10,y+60,x-30,y+50);
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.1.9/p5.min.js"></script>