Skip to content

Commit

Permalink
wip : Single particle system
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick B committed Aug 28, 2024
1 parent 9094957 commit 3fdfbee
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 0 deletions.
14 changes: 14 additions & 0 deletions s03_particles/GraphicObject.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
abstract class GraphicObject {
PVector location;
PVector velocity;
PVector acceleration;

color fillColor = color (255);
color strokeColor = color (255);
float strokeWeight = 1;

abstract void update(int deltaTime);

abstract void display();

}
29 changes: 29 additions & 0 deletions s03_particles/Particle.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
class Particle {
PVector position;
PVector velocity;
PVector acceleration;

Particle() {
position = new PVector(width/2, height/2);
velocity = new PVector(random(-1, 1), random(-2, 0));
acceleration = new PVector(0, 0.05);
}

Particle(PVector l) {
position = l.copy();
velocity = new PVector(random(-1, 1), random(-2, 0));
acceleration = new PVector(0, 0.05);
}

void update() {
velocity.add(acceleration);
position.add(velocity);
acceleration.mult(0);
}

void display() {
stroke(0);
fill(175);
ellipse(position.x, position.y, 10, 10);
}
}
24 changes: 24 additions & 0 deletions s03_particles/s03_particles.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
int currentTime;
int previousTime;
int deltaTime;

void setup() {
size (800, 600);
}

void draw() {
currentTime = millis();
deltaTime = currentTime - previousTime;
previousTime = currentTime;

update(deltaTime);
display();
}

void update(int deltaTime) {

}

void display() {

}

0 comments on commit 3fdfbee

Please sign in to comment.