topical media & game development
graphic-processing-algorithm-Ch06-p144-p144.pde / pde
int nelements = 4;
MyElement [] e = new MyElement[nelements];
void setup(){
for(int i=0; i<nelements; i++){
e[i] = new MyElement(i, e);
e[i].xspeed = random(1);
e[i].yspeed = random(1);
}
}
void draw(){
background(200);
for(int i=0; i<nelements; i++){
e[i].collide();
e[i].move();
}
}
void mouseDragged(){
for(int i=0; i<nelements; i++)
if(dist(mouseX,mouseY,e[i].xpos,e[i].ypos)<20){
e[i].xspeed = mouseX-pmouseX;
e[i].yspeed = mouseY-pmouseY;
}
}
(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.