A single particle
In this section, we will create a project that will model and draw one particle. It will be represented by our custom C++ class, Particle
.
The best C++ programming style suggests declaring and implementing each new class in separate .h
and .cpp
files (in our case, it should be Particles.h
and Particles.cpp
) because it improves readability and reusability of the code. But for simplicity, we will declare and implement all the classes of the example only in testApp.h
and testApp.cpp
files respectively.
Note
This is example 03-Particles/01-SingleParticle
.
The example is based on the emptyExample
project in openFrameworks. In the testApp.h
file, after the #include "ofMain.h"
line, add the following declaration of a Particle
class:
class Particle { public: Particle(); //Class constructor void setup(); //Start particle void update( float dt ); //Recalculate physics void draw(); //Draw particle ofPoint pos; //Position...