Modify a text file: $/trees_3a.pde
$/trees_3a.pde
//// Trees float horizon; color sky= color( 110, 110, 250 ); color grass= color( 160, 255, 160 ); Tree t1, t2, t3; void setup() { size( 800, 600 ); horizon = height/3; t1 = new Tree(); t1.x = 600; t1.y = 180; t2 = new Tree(); t2.x = 240; t2.y = 400; t3 = new Tree(); } void draw() { background(sky); fill(grass); rect( 0,horizon, width,height-horizon ); t1.show(); t2.show(); t3.show(); } void keyPressed() { if(key == '1') { t1.jump(); } if(key == '2') { t2.jump(); } if(key == '3') { t3.jump(); } } //// OBJECTS //// class Tree { float x=100,y=100, w=100,h=150; color leaves= color( 150, 200, 150 ); color bark= color( 120, 90, 90 ); void show() { fill(bark); rect( x-20,y, 40,h ); fill(leaves); ellipse(x,y, w,w); } void jump() { x= random(100, width-100); y= random(horizon-120, height-200); } }