xxxxxxxxxx
29
let x=0
let y=0
let speedX=1
let speedY=1
function setup() {
createCanvas(400, 400,WEBGL);
}
function draw() {
background(220);
push()
translate(x,y,0);
rotateX(frameCount*0.01)
rotateY(frameCount*0.01)
box(50)
pop()
x=x+speedX
y=y+speedY
if(x>width/2){speedX=-1}
if(x<-width/2){speedX=1}
if(y>height/2){speedY=-1}
if(y<-height/2){speedY=1}
}