1
edit
Changes
no edit summary
<source lang="JavaScript">
/*
Andor Salga
FSOSS 2010
*/
import processing.opengl.*;
/*
A single particle
*/
class Particle{
private PVector position; private PVector velocity; float age; float lifeTime; // opacity (add me!) // size (add me!)
private float age;
private float lifeTime;
// !!! color Add me!
// !!! size Add me!
Particle(){
}
void reset(){
position = new PVector(0, 0, 0); velocity = new PVector(0, 0, 0); age = 0.0f; lifeTime = 0.0f;
}
void setLifeTime(float l){lifeTime = l;}
// !!! Pass in elapsed time
void update(){
age += 0.1; //!!! fix me velocity.y += 0.1; // !!! fix me
position.add(velocity);
// !!! update color
// !!! update size
}
void draw(){
strokeWeight(510); stroke(128, 0, 0, 50);
point(position.x, position.y, position.z);
}
int NUM_PARTICLES = 500;
/*
Class that manages the particles
*/
class ParticleSystem{
ArrayList p;
p = new ArrayList();
for(int i = 0; i < NUM_PARTICLES; i++){
}
}
particle.setPosition( new PVector(mouseX, mouseY, 0));
particle.setVelocity( new PVector( random(0,2), random(0,2) , 0 ) );
particle.setLifeTime(random(1,15));
}
void setup(){
size(500,500,OPENGL);
psys = new ParticleSystem();
}
void draw(){
background(0);
psys.update();
psys.draw();
}
</source>
[http://studio.sketchpad.cc/MAMxiAxlxH EtmcGMo6zi Run me]