Hello All,
We have been playing with particle systems at my school and I have come up with this example below:
http://klaweht.com/blog/noc/particles/applet/
this is the source code zipped: http://klaweht.com/blog/noc/particles/Archive.zip
as you can see, it is so slow right now and the the reason for this is I am creating this circular shape in the run() method of ParticleSystem class which is below:
Code:
void run() {
for(int i = 0; i < 36; i++) {
origin = new Vector3D(cos(i)*40.0, sin(i)*40.0);
particles.add(new Particle(origin, new Vector3D(random(-2,2),random(-2,2)), new Vector3D(0,0),1));
}
for ( int i = particles.size()-1; i >= 0; i--) {
Particle p = (Particle) particles.get(i);
p.run();
if(p.dead()) {
particles.remove(i);
}
}
}
my guess would be taking it off from there and adding a class that would draw the circular shape. But I want to ask to you guys at first. what would be the good way of optimizing such a code? Lookup tables? I am clueless about them.
thanks in advance.