Last active
April 16, 2018 13:10
-
-
Save brendandawes/8273dd418c8886e244afcff2a9c5d5aa to your computer and use it in GitHub Desktop.
Processing:Particle Class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Node { | |
private PVector vel; | |
private PVector loc; | |
private PVector acc; | |
Node () { | |
vel = PVector.random2D(); | |
loc = new PVector(random(width), random(height)); | |
acc = PVector.random2D(); | |
} | |
void update(){ | |
vel.add(acc); | |
loc.add(vel); | |
acc.mult(0); | |
} | |
void applyForce(PVector force){ | |
acc.add(force); | |
} | |
void checkEdges(){ | |
if (loc.x >= width || loc.x <= 0) { | |
vel.x *=-1; | |
} | |
if (loc.y > height || loc.y < 0) { | |
vel.y *=-1; | |
} | |
} | |
void draw(){ | |
strokeWeight(10); | |
stroke(0); | |
point(loc.x, loc.y); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment