Created
December 7, 2011 11:53
-
-
Save roxlu/1442538 to your computer and use it in GitHub Desktop.
This file contains 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
#include "Particle.h" | |
// constructor function - executed directly! | |
Particle::Particle() { | |
velocity.set(1,2); | |
position.set(0,0); | |
mass = ofRandom(0.2,10); | |
forces.set(0.4,0.1); | |
} | |
void Particle::draw() { | |
// forces calculations | |
ofVec2f affect = forces / mass; | |
velocity = velocity + affect; | |
position = position + velocity; | |
forces.set(0,0); | |
// drawing | |
ofCircle(position.x,position.y,mass); | |
} | |
void Particle::addForce(ofVec2f force) { | |
forces = forces + force; | |
} | |
void Particle::setPosition(int x, int y) { | |
position.set(x,y); | |
velocity.set(0,0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment