Skip to content
This repository has been archived by the owner on Jul 11, 2019. It is now read-only.

David Tracy Changes #13

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions NOC_4_09_AdditiveBlending/NOC_4_09_AdditiveBlending.pde
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,26 @@

ParticleSystem ps;


PImage img;

void setup() {

size(800, 200, P2D);

// Create an alpha masked image to be applied as the particle's texture
img = loadImage("texture.png");

ps = new ParticleSystem(0, new PVector(width/2, 50));
smooth();

}

void draw() {

void draw() {
blendMode(ADD);
background(0);
ps.run();
for (int i = 0; i < 10; i++) {
ps.addParticle();
}
}

20 changes: 16 additions & 4 deletions NOC_4_09_AdditiveBlending/ParticleSystem.pde
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,25 @@ class ParticleSystem {

ArrayList<Particle> particles; // An arraylist for all the particles
PVector origin; // An origin point for where particles are birthed

PImage tex;

ParticleSystem(int num, PVector v) {
}
ParticleSystem(int num, PVector v) {
particles = new ArrayList(); // Initialize the arraylist
origin = v.get(); // Store the origin point
for (int i = 0; i < num; i++) {
particles.add(new Particle(origin)); // Add "num" amount of particles to the arraylist
}
}

void run() {
Iterator<Particle> it = particles.iterator();
while (it.hasNext()) {
Particle p = it.next();
p.run();
if (p.dead()) {
it.remove();
}
}
}

void addParticle() {
Expand All @@ -36,5 +48,5 @@ ParticleSystem(int num, PVector v) {
return false;
}
}

}