topical media & game development
graphic-processing-algorithm-Ch06-p130-p130.pde / pde
int numLeaves = 400; //number of leaves to draw
PImage myBackImage; //define an backgound image
Leaf[] myLeaf = new Leaf[numLeaves]; //define a Leaf object
void setup(){
myBackImage = loadImage("ground.jpg"); //load it
size(myBackImage.width,myBackImage.height); //size screen to the image
for(int i=0; i<numLeaves; i++){ //for all the number of leaves
myLeaf[i] = new Leaf(); //create a Leaf object
myLeaf[i].rate=int(random(2,20));
}
}
void draw(){
image(myBackImage, 0,0); //draw first the backgound
for(int i=0; i<numLeaves; i++)
myLeaf[i].draw(); //draw all the leaves
}
(C) Æliens
04/09/2009
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.