xxxxxxxxxx
float x, y;
void setup(){
size(500,500,P3D);
background(50,25,25);
noStroke();
x = width/2;
y = height;
}
void draw(){
lights();
fill(181,101,29);
translate(x,y)
box(15);
//controller
if(keyPressed){
if (keyCode ==UP){
//Move the block up
y-=5;
}
if (keyCode ==DOWN){
//Move the block up
y+=5;
}
if (keyCode ==LEFT){
//Move the block up
x-=5;
}
if (keyCode ==RIGHT){
//Move the block up
x+=5;
}
if(keyCode == UP || keyCode == DOWN){
x+= random(-2,2);
}
if(keyCode == LEFT || keyCode == RIGHT){
y+= random(-2,2);
}
if(key == ' '){
spawnLeaf();
}
}
}
void spawnLeaf(){
translate(random(-40,40), random(-40,40));
fill(20,204,120);
sphere(10);
}