I managed to make trees pop up in random locations on the screen. But I have to change the scale based on the y position of the trees. As the tree pop up lower in the screen, it should be bigger and fewer compared to the trees that is on the top of the screen where the trees are smaller and more.
Preformatted text
void setup(){
size(1600,1000);
noStroke();
frameRate(10);
}
void draw(){
float x=random(width);
float y=random(height);
translate(x,y);
print(frameCount);
tree();
}
void trunk(){
fill(#673F34);
rectMode(CENTER);
rect(150,550,80,100);
}
void tree(){
body(40,50);
trunk();
decoration(25,50, random(10,20), random(10,20));
}
void body(int x, int y){
fill(0,255,0);
for (int n=0; n<4;n=n+1){
triangle(nx, 500-ny, 150,400-ny, 300-nx, 500-ny);
}
/
triangle(0,500,150,400,300,500);
triangle(x,500-y,150,400-y,300-x,500-y);
triangle(2x,500-2y,150,400-2y,300-2x,500-2y);
triangle(3x,500-3y, 150,400-3y,300-3x,500-3y);
*/
}
void decoration(int x, int y, float z, float k){
fill(255,0,0);
for (int n=-1; n<2; n+=1){
ellipse(150, 400-n*y,z,k);
}
/*ellipse(150,400-y,z,k);
ellipse(150,400,z,k);
ellipse(150,400+y,z,k);
/
for (int n=-1; n<2; n+=1){
ellipse(150-nx,400,z,k);
/ellipse(150-x,400,z,k);
ellipse(150,400,z,k);
ellipse(150+x,400,z,k);/
}
ellipse(150-2x,400+y,z,k);
ellipse(150+2x,400+y,z,k);
}