Hello everyone. I would like tome convert those particles into an image. I mean every single particle in one image that i have from a picture, any. i leave here the code till i tried it. THANKS for your time!!
//This is a paddle i have for the main code
ParticleSystem ps;
void setup() {
size(800, 600);
ps = new ParticleSystem();
}
void draw() {
background(255, 255);
ps.addParticle();
ps.run();
}
//This is the second paddle named Particles
class Particle {
PVector location, velocity, acceleration;
float lifespan;
float radio;
PImage pocoyo;
Particle() {
location = new PVector(width/2, 20);
velocity = new PVector(0, 0);
acceleration = new PVector(random(-0.01, 0.01), random(0.01, 0.1));
pocoyo = loadImage("pocoyo.jpg");
lifespan = 255;
radio = random(12);
}
boolean isDead() {
if (lifespan <= 0) {
return true;
} else {
return false;
}
}
void falling() {
location.add(velocity);
velocity.add(acceleration);
if (location.y >= width/2) {
lifespan = lifespan - 10;
}
}
void display() {
image(pocoyo, 0, 0, 20, 20);
fill(150, lifespan);
stroke(0);
strokeWeight(2);
ellipse(location.x, location.y, radio, radio);
}
}
//This is the Third and the last paddle named ParticleSystem
class ParticleSystem{
ArrayList particles;
ParticleSystem(){
particles = new ArrayList();
}
void addParticle(){
particles.add(new Particle());
}
void run(){
for(int i = 0; i < particles.size(); i++){
Particle p = particles.get(i);
p.display();
p.falling();
if(p.isDead()){
particles.remove(i);
}
}
}
}