#include "ofApp.h" void ofApp::setup() { } void ofApp::update() { for (int i = 0; i < location.size(); i++) { location[i] += velocity[i]; if (location[i].x < 0 || location[i].x > ofGetWidth()) { velocity[i].x *= -1; } if (location[i].y < 0 || location[i].y > ofGetHeight()) { velocity[i].y *= -1; } if (location[i].z < -500 || location[i].z > 500) { velocity[i].z *= -1; } } } void ofApp::draw() { for (int i = 0; i < location.size(); i++) { ofDrawCircle(location[i], 5); } ofDrawBitmapStringHighlight( "Num = " + ofToString(location.size()), 20, 20); ofDrawBitmapStringHighlight( "FPS = " + ofToString(ofGetFrameRate()), 20, 40); } void ofApp::mouseDragged(int x, int y, int button) { glm::vec3 loc = glm::vec3(x, y, 0); location.push_back(loc); glm::vec3 vel = glm::vec3(ofRandom(-2, 2), ofRandom(-2, 2), ofRandom(-10, 10)); velocity.push_back(vel); if (location.size() > NUM) { location.erase(location.begin()); velocity.erase(velocity.begin()); } }