Particle::Particle(){ pos.set(ofRandomWidth(),ofRandomHeight(),ofRandomWidth()); // vel.set(ofRandom(-10,10),ofRandom(-10,10),ofRandom(-10,10)); vel.set(0); color = ofColor(ofRandom(150,255), ofRandom(50,200)); radius = ofVec2f(ofRandom(2,6)); }
//-------------------------------------------------------------- ofVec2f PACManUnit::getRangePos(int iside) { ofVec2f result_(0); switch(iside % 4) { case 0: { result_.x = ofRandomWidth(); result_.y = 0; } break; case 1: { result_.x = ofRandomWidth(); result_.y = ofGetHeight(); } break; case 2: { result_.x = 0; result_.y = ofRandomHeight(); } break; case 3: { result_.x = ofGetWidth(); result_.y = ofRandomHeight(); } break; } return result_; }
//-------------------------------------------------------------- void testApp::update(){ // apply steering force car1.seek( dest1 ); car2.seek( dest2 ); // apply repelling force if( car1.pos.distance( car2.pos ) < 200 ){ car1.color = ofColor(255,0,0); car2.color = ofColor(255,0,0); car1.addRepulsionForce( car2.pos ); car2.addRepulsionForce( car1.pos ); }else{ car1.color = ofColor(0,255,0); car2.color = ofColor(0,0,255); } // update physics car1.update(); car2.update(); if( car1.pos.distance(dest1) < 5){ dest1 = ofVec2f( ofRandomWidth(), ofRandomHeight() ); } if( car2.pos.distance(dest2) < 5){ dest2 = ofVec2f( ofRandomWidth(), ofRandomHeight() ); } }
void bag::setup() { //pos.set(); pos.set(ofRandomHeight(), ofRandomWidth()); pos.x = ofRandomWidth(); pos.y = ofRandomHeight(); size =3; }
//-------------------------------------------------------------- void testApp::setup(){ amplitude = 100; ofSetBackgroundAuto(false); period = 50; pointX, pointY = 0; targetX = ofGetWidth(); targetY = ofGetHeight(); easing = 0.01; ofBackground(0, 0, 0); ofSetFrameRate(30); yellowBall.x = ofRandomWidth(); yellowBall.y = ofRandomHeight(); yellowBall.vx = ofRandom(-10,10); yellowBall.vy = ofRandom(-10,10); whiteBall.x = ofRandomWidth(); whiteBall.y = ofRandomHeight(); whiteBall.vx = ofRandom(-10,10); whiteBall.vy = ofRandom(-10,10); redBall.x = ofRandomWidth(); redBall.y = ofRandomHeight(); redBall.vx = ofRandom(-30,10); redBall.vy = ofRandom(-30,10); greenBall.x = ofRandomWidth(); greenBall.y = ofRandomHeight(); greenBall.vx = ofRandom(-15,10); greenBall.vy = ofRandom(-15,10); grayBall.x = ofRandomWidth(); grayBall.y = ofRandomHeight(); grayBall.vx = ofRandom(-20,10); grayBall.vy = ofRandom(-20,10); purpleBall.x = ofRandomWidth(); purpleBall.y = ofRandomHeight(); purpleBall.vx = ofRandom(-75,10); purpleBall.vy = ofRandom(-75,10); orangeBall.x = ofRandomWidth(); orangeBall.y = ofRandomHeight(); orangeBall.vx = ofRandom(-20,10); orangeBall.vy = ofRandom(-20,10); blueBall.x = ofRandomWidth(); blueBall.y = ofRandomHeight(); blueBall.vx = ofRandom(-15,10); blueBall.vy = ofRandom(-15,10); }
mover::mover(){ location.set(ofRandomWidth(), ofRandomHeight()); velocity.set(0, 0); topSpeed = 6; size = (int) ofRandom(6,12); cor = ofRandom(255); }
//-------------------------------------------------------------- void testApp::setup(){ ofSetBackgroundAuto(FALSE); ofSetFrameRate(60); for (int i=0; i<200; i++) { P.push_back(ofPoint(ofRandomWidth(),ofRandomHeight())); } }
//-------------------------------------------------------------- void testApp::setup() { ofBackground(0, 0, 0); ofSetVerticalSync(true); // billboard particles for (int i=0; i<NUM_BILLBOARDS; i++) { pos[i].x = ofRandomWidth(); pos[i].y = ofRandomHeight(); vel[i].x = ofRandomf(); vel[i].y = ofRandomf(); home[i] = pos[i]; pointSizes[i] = ofNextPow2(ofRandom(2, 40)); rotations[i] = ofRandom(0, 360); } // set the vertex data vbo.setVertexData(pos, NUM_BILLBOARDS, GL_DYNAMIC_DRAW); shader.load("shaders/BillboardExample"); // yes its a fly! ofDisableArbTex(); texture.loadImage("images/fly.png"); }
//-------------------------------------------------------------- void testApp::setup(){ string host = Spacebrew::SPACEBREW_CLOUD; // "localhost"; string name = "snaxx & macs capsense trial"; string description = "It's amazing"; spacebrew.addSubscribe("meebVal1", "range");// just typing "boolean" also works spacebrew.addSubscribe("meebVal2", "range");// just typing "boolean" also works spacebrew.addSubscribe("meebVal3", "range");// just typing "boolean" also works spacebrew.connect( host, name, description ); Spacebrew::addListener(this, spacebrew); for(int i=0; i<10; i++){ Meeba meebOne; meebOne.radius = 50; meebOne.density = 100; meebOne.color.set(0, 255, 255); meebOne.shift.set(ofRandomWidth(), ofRandomHeight()); meebOne.speed = ofRandom(-2, 2); if(meebOne.speed == 0){ meebOne.speed = 2; } rainbow.push_back(meebOne); } }
//-------------------------------------------------------------- void testApp::setupLines() { // First of all, clear out the vectors (in case of reset). // First the lineLists inside the dancerList... for ( int i = 0; i < dancerList.size(); i++) { dancerList[ i ].lineList.clear(); } // ...then the dancerList itself. dancerList.clear(); // Maintenance ofSetVerticalSync( true ); ofSetFrameRate( 60 ); ofSetCircleResolution( 100 ); // May want to change this to a gradient or something else. ofBackground( 0 ); breath = 0; breathRad = 50; noiseBreath = true; // Create Dancers, feed in a pos and vel, and add them to the vector. for ( int i = 0; i < NUMDANCERS; i++ ) { Dancer instrument( ofVec2f( ofRandomWidth(), ofRandomHeight() ), ofVec2f( ofRandom( -0.5, 0.5 ), ofRandom( -0.5, 0.5 ) ) ); dancerList.push_back( instrument ); } }
//-------------------------------------------------------------- void testApp::setup(){ ofSetVerticalSync(true); ofSetFrameRate(60); ofBackground(150, 150, 150); ofEnableAlphaBlending(); for (int i = 0; i < 300; i++) { Particle myCar; ofSeedRandom(); ofPoint destination; setRandomDest(destination); destination = ofPoint( ofRandomWidth(), ofRandomHeight()); setRandomPos(); myCar.setInit(randPos); //setRandomColor(); //myCar.setColorCondition(randR, randG, randB); cars.push_back(myCar); dest.push_back(destination); } }
//------------------------------------------------------------------ void particleVoronoi::reset(){ //the unique val allows us to set properties slightly differently for each particle uniqueVal = ofRandom(-10000, 10000); isDouble = false; doubleIndex = 0; cellSize = 1.0; pos.x = ofRandomWidth(); pos.y = ofRandomHeight(); originPos=pos; vel.x = ofRandom(-0.9, 0.9); vel.y = ofRandom(-0.9, 0.9); frc = ofPoint(0,0,0); bassCounter=0; bassTap=false; soundPt.set(0, 0); scale = ofRandom(0.5, 1.0); //if( mode == PARTICLE_MODE_NOISE ){ // drag = ofRandom(0.97, 0.99); // vel.y = fabs(vel.y) * 3.0; //make the particles all be going down //}else{ drag = ofRandom(0.95, 0.998); //} }
void Food::setup() { food.loadImage("food.png"); food.resize(20, 20); pos.x = ofRandomWidth(); pos.y = ofRandomHeight(); }
void ofApp::createParticle() { Particle p; p.setup(); p.pos.set(ofRandomWidth(), ofRandomHeight()); p.color = img.getColor(p.pos.x,p.pos.y); particles.push_back(p); }
void Cascade::audioReceived(float *input, int length, int nChannels) { float lastSample = input[0]; for(int i = 1; i < length; i++) { float diff = input[i] - lastSample; if(ABS(diff)>clapThreshold) { magnitude = ABS(diff); lastClap = ofGetElapsedTimef(); clapPoint = ofPoint(ofRandomWidth(), ofRandomHeight()); clapping = true; #ifndef TARGET_OF_IPHONE //claps are touch downs for this one... ofxOscMessage m; m.setAddress( "/touchdown" ); m.addIntArg(mode); ReactickleApp::instance->sender.sendMessage(m); #endif return; } lastSample = input[i]; } }
//------------------------------------------------------------------ void demoParticle::reset(){ // the unique val allows us to set properties slightly differently for each particle // 给粒子一个随机的数字 uniqueVal = ofRandom(-10000, 10000); // 位置,速度,缩放度都是随机的 pos.x = ofRandomWidth(); pos.y = ofRandomHeight(); vel.x = ofRandom(-3.9, 3.9); vel.y = ofRandom(-3.9, 3.9); frc = ofPoint(0,0,0); scale = ofRandom(0.5, 1.0); if( mode == PARTICLE_MODE_NOISE ){ drag = ofRandom(0.97, 0.99); vel.y = fabs(vel.y) * 3.0; // make the particles all be going down // 让粒子都向下移动 }else{ drag = ofRandom(0.95, 0.998); } }
//-------------------------------------------------------------- void testApp::mousePressed(int x, int y, int button){ mouseDown = true; boltX = ofRandomWidth(); // bolt.setup(boltX, 0, mouseX, mouseY, 6, ofRandom(90, 110), 0.3); // bolt.parse(); }
//-------------------------------------------------------------- void ofApp::createParticle() { particle p; //create a particle and name it p p.setup(); //run setup p.pos.set(ofRandomWidth(), ofRandomHeight());//set randomly p.color = surf.getColor(p.pos.x,p.pos.y);//gets the color from the x and y pos particles.push_back(p);// push it back in the vector }
//-------------------------------------------------------------- void testApp::setup(){ ofSetFrameRate(60); Berkelium::init( Berkelium::FileString::empty() ); browser = new ofxBerkelium(WIDTH, HEIGHT, USE_TRANSPARENCY); browser->setListener(this); urls.push_back("http://www.jeffcrouse.info/how-tos/ofxberkelium"); urls.push_back("https://github.com/jefftimesten/ofxBerkelium"); urls.push_back("http://www.openframeworks.cc"); urls.push_back("http://berkelium.org/"); urls.push_back("http://www.cnn.com"); urls.push_back("http://vimeo.com/18532317"); urls.push_back("http://vimeo.com/18786679"); for(int i=0; i<10; i++) { particle p; p.pos.x = ofRandomWidth(); p.pos.y = ofRandomHeight(); p.vel.x = ofRandom(-10, 10); p.vel.y = ofRandom(-10, 10); p.rot.x = ofRandom(0, 360); p.rot.y = ofRandom(0, 360); p.rot.z = ofRandom(0, 360); p.scale = .02 + ofRandomf() * .1; particles.push_back( p ); } loadRandomURL=true; drawLog = false; }
//-------------------------------------------------------------- void testApp::setup(){ ofSeedRandom(); dest1 = ofVec2f( ofRandomWidth(), ofRandomHeight() ); dest2 = ofVec2f( ofRandomWidth(), ofRandomHeight() ); car1.setParams( ofGetWindowSize() / 2, ofVec2f(10, -5) ); car2.setParams( ofGetWindowSize() / 2, ofVec2f(10, 5) ); car1.color = ofColor(0,255,0); car2.color = ofColor(0,0,255); ofBackground(255); ofEnableAlphaBlending(); }
Thing::Thing() { max_vel = 10.0; mass = ofRandom(5.0, 10.5); bounce = .6; loc.x = ofRandomWidth(); loc.y = ofRandomHeight(); G = 0.9; }
Boid::Boid() { loc.set(ofRandomWidth(),ofRandomHeight()); vel.set(0,0); acc.set(0,0); r = 3.0; maxspeed = .5; maxforce = 0.1; }
void testApp::addParticle() { Particle part; part.pos = ofVec2f( ofRandomWidth(), ofRandomHeight() ); part.mass = mass; // part.psize = ofRandom(3,5); particleList.push_back( part ); }
//------------------------------------------------------------------ void demoParticle::reset(){ if( mode == PARTICLE_MODE_NOISE ){ //the unique val allows us to set properties slightly differently for each particle uniqueVal = ofRandom(-10000, 10000); pos.x = fishPosPrt.x; pos.y = fishPosPrt.y; vel.x = ofRandom(-2.0, 2.0); vel.y = ofRandom(-3.9); frc = ofPoint(0,0,0); scale = ofRandom(0.5, 1.0); drag = ofRandom(0.97, 0.99); vel.y = fabs(vel.y) * -6.0; //make the particles all be going up }else if (mode == PARTICLE_MODE_RAIN){ uniqueVal = ofRandom(-10000, 10000); pos.x = ofRandom(-100, ofGetWidth()); pos.y = ofRandom(200,-400); vel.x = 15; vel.y = ofRandom(14, 18); // frc = ofPoint(0,0,0); scale = 0.5; // drag = ofRandom(0.97, 0.99); }else{ //the unique val allows us to set properties slightly differently for each particle uniqueVal = ofRandom(-10000, 10000); pos.x = ofRandomWidth(); pos.y = ofRandomHeight(); while (pos.y > 300 && pos.y < 500) { pos.y = ofRandomHeight(); } vel.x = ofRandom(-3.9, 3.9); vel.y = ofRandom(-3.9, 3.9); frc = ofPoint(0,0,0); scale = ofRandom(0.5, 1.0); drag = ofRandom(0.95, 0.998); } }
//-------------------------------------------------------------- void testApp::setup(){ for(int i = 0 ; i < 10 ; i++) { Ball* ball = new Ball(ofRandomWidth(), ofRandomHeight() , ofGetWidth(),ofGetHeight()); balls.push_back(ball); delaunay.addPoint(ofPoint(ball->x,ball->y)); } delaunay.triangulate(); }
//-------------------------------------------------------------- void testApp::setup(){ manualTarget = ofPoint(ofGetWidth()/2, ofGetHeight()/2); for (int i=0; i<200; i++) { points.push_back(ofPoint(ofRandomWidth(), ofRandomHeight())); angles.push_back(0); speeds.push_back(0); } }
//-------------------------------------------------------------- void testApp::setup(){ ofSetVerticalSync( true ); ofBackground( 0 ); dest.set( ofRandomWidth(), ofRandomHeight() ); for (int i = 0; i < 1; i++) { addParticle(); } }
Boid::Boid() { loc.x = ofRandomWidth(); loc.y = ofRandomHeight(); vel = 0; acc = 0; r = 3.0; maxspeed = 4; maxforce = 0.1; }
void Predator::setup(){ predator.loadImage("predator.png"); predator.resize(60, 60); pos.x = ofRandomWidth(); pos.y = ofRandomHeight(); size = 7; speed = 4; }
Repeller::Repeller() { bDragging = false; bRollover = false; r = 20; g = 200; loc.x = ofRandomWidth(); loc.y = ofRandomHeight(); oldloc = loc; }