-
Book Overview & Buying
-
Table Of Contents
Mastering openFrameworks: Creative Coding Demystified
By :
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.
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...
Change the font size
Change margin width
Change background colour