Created
October 13, 2017 19:25
-
-
Save jeffcrouse/13ab27ac64ce35df8b39bade23470578 to your computer and use it in GitHub Desktop.
Starting point code for Week 6
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 "ofApp.h" | |
#define NUM_PARTICLES 100 | |
float radius = 10; | |
ofPoint pos[NUM_PARTICLES]; | |
ofPoint vel[NUM_PARTICLES]; | |
//-------------------------------------------------------------- | |
void ofApp::setup(){ | |
for(int i=0; i<NUM_PARTICLES; i++) { | |
pos[i].x = ofRandom( radius, ofGetWidth()-radius ); | |
pos[i].y = ofRandom( radius, ofGetHeight()-radius ); | |
vel[i].x = ofRandom(-10, 10); | |
vel[i].y = ofRandom(-10, 10); | |
} | |
} | |
//-------------------------------------------------------------- | |
void ofApp::update(){ | |
for(int i=0; i<NUM_PARTICLES; i++) { | |
pos[i] += vel[i]; | |
if(pos[i].x > ofGetWidth()-radius) { | |
pos[i].x = ofGetWidth()-radius; | |
vel[i].x *= -1; | |
} | |
if(pos[i].y > ofGetHeight()-radius) { | |
pos[i].y = ofGetHeight()-radius; | |
vel[i].y *= -1; | |
} | |
if(pos[i].x < radius) { | |
pos[i].x = radius; | |
vel[i].x *= -1; | |
} | |
if(pos[i].y < radius) { | |
pos[i].y = radius; | |
vel[i].y *= -1; | |
} | |
} | |
} | |
//-------------------------------------------------------------- | |
void ofApp::draw(){ | |
ofSetColor(0); | |
for(int i=0; i<NUM_PARTICLES; i++) { | |
ofDrawCircle(pos[i], radius); | |
} | |
} | |
//-------------------------------------------------------------- | |
void ofApp::keyPressed(int key){ | |
} | |
//-------------------------------------------------------------- | |
void ofApp::keyReleased(int key){ | |
} | |
//-------------------------------------------------------------- | |
void ofApp::mouseMoved(int x, int y ){ | |
} | |
//-------------------------------------------------------------- | |
void ofApp::mouseDragged(int x, int y, int button){ | |
} | |
//-------------------------------------------------------------- | |
void ofApp::mousePressed(int x, int y, int button){ | |
} | |
//-------------------------------------------------------------- | |
void ofApp::mouseReleased(int x, int y, int button){ | |
} | |
//-------------------------------------------------------------- | |
void ofApp::mouseEntered(int x, int y){ | |
} | |
//-------------------------------------------------------------- | |
void ofApp::mouseExited(int x, int y){ | |
} | |
//-------------------------------------------------------------- | |
void ofApp::windowResized(int w, int h){ | |
} | |
//-------------------------------------------------------------- | |
void ofApp::gotMessage(ofMessage msg){ | |
} | |
//-------------------------------------------------------------- | |
void ofApp::dragEvent(ofDragInfo dragInfo){ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment