-- "
int size = 100;
int value = 0;
float xspeed = 10;
float yspeed = 15;
float zspeed = 15;
float xpos, ypos, zpos;
int xdirection = 1;
int ydirection = 1;
int zdirection = 1;
void setup() {
size(600,600);
framerate(30);
xpos = width/2;
ypos = height/2;
zpos = 0;
}
void loop() {
background(0,128,128); //background color
xpos = xpos - (random(xspeed) * random(xdirection));
ypos = ypos + (random(yspeed) * random(ydirection));
zpos = zpos + random(100);
if (xpos > width-size || xpos < 0) {
xdirection *= -1;
}
if (ypos > width-size || ypos < 0) {
ydirection *= -1;
}
if (zpos > width-size || zpos < 0) {
zdirection *= -1;
}
rotateX(0); //degree of x-axis rotation
rotateY(value); //degree of y-axis rotation
// rotateZ(0); //degree of z-axis rotation
fill(0,128,255,128); //color of the box
rect(xpos,ypos,size,size); //dimensions of the
box(x,y,z)
}
void mousePressed() {
value = value + 45;
if (value > 360) {
value = 0;
}
}
"