Fleas! Openframeworks Final

This project is for my CC Lab final.  My goal was to create a particle system that had a story behind it.  I decided on creating a little pink dog that replaces the mouse and replaced the particles with little fleas swarming around the dog. There is also a second version where the dog is chasing the fleas and they are avoiding the pink dog.

Here is the code I changed:

ofApp.cpp: // Initializing the functions 

void ofApp::draw(){
//ofBackgroundGradient(ofColor(250,250,250),ofColor(150,150,150);
ofSetColor(200);
bgImg3.draw(-40, -40, 1200, 1200);

for(unsigned int i = 0; i < p.size(); i++){
p[i].draw();
}

ofSetColor(190);
if( currentMode == PARTICLE_MODE_NEAREST_POINTS ){
for(unsigned int i = 0; i < attractPoints.size(); i++){
ofNoFill();
ofDrawCircle(attractPointsWithMovement[i], 10);
ofFill();
ofDrawCircle(attractPointsWithMovement[i], 4);
}
}

ofSetColor(230);
ofDrawBitmapString(currentModeStr + “\n\nSpacebar to reset. \nKeys 1-4 to change mode.”, 10, 20);

// Replace cursor with image
ofHideCursor();
ofSetColor(255, 0, 255);
doggoImg.draw(mouseX, mouseY, 60, 60);
}

 

ofApp.h  // drawing the fleas and loading the images 

ofImage doggoImg;
ofImage bgImg;
ofImage bgImg2;
ofImage bgImg3;

 

demoParticle.cpp

void demoParticle::draw(){

if( mode == PARTICLE_MODE_ATTRACT ){
ofSetColor(255, 63, 180);
}
else if( mode == PARTICLE_MODE_REPEL ){
ofSetColor(208, 255, 63);
}
else if( mode == PARTICLE_MODE_NOISE ){
ofSetColor(99, 63, 255);
}
else if( mode == PARTICLE_MODE_NEAREST_POINTS ){
ofSetColor(103, 160, 237);
}

ofDrawCircle(pos.x, pos.y, scale * 5.0);

ofSetColor(0, 0, 0);
ofDrawCircle(pos.x, pos.y, scale * 4.0);

ofDrawLine(pos.x, pos.y, pos.x + 5, pos.y – 5);
ofDrawLine(pos.x, pos.y, pos.x + 7, pos.y);
ofDrawLine(pos.x, pos.y, pos.x + 5, pos.y + 5);
ofDrawLine(pos.x, pos.y, pos.x – 5, pos.y – 5);
ofDrawLine(pos.x, pos.y, pos.x – 7, pos.y);
ofDrawLine(pos.x, pos.y, pos.x – 5, pos.y + 5);

//ofDrawRectangle(pos.x, pos.y, scale * 4.0, scale * 4.0);

}

 

Leave a reply:

Your email address will not be published.

Site Footer