//--------------------------------------------------------------
void testApp::keyPressed(int key){
    if(key == 'c') {
		float r = ofRandom(4, 20);		// a random radius 4px - 20px
		circles.push_back(ofPtr<ofxBox2dCircle>(new ofxBox2dCircle));
		circles.back().get()->setPhysics(3.0, 0.53, 0.1);
		circles.back().get()->setup(box2d.getWorld(), mouseX, mouseY, r);
		
	}
	
	if(key == 'b') {
		float w = ofRandom(4, 20);
		float h = ofRandom(4, 20);
		boxes.push_back(ofPtr<ofxBox2dRect>(new ofxBox2dRect));
		boxes.back().get()->setPhysics(3.0, 0.53, 0.1);
		boxes.back().get()->setup(box2d.getWorld(), mouseX, mouseY, w, h);
	}
	
	if(key == 'z') {
        
		customParticles.push_back(ofPtr<CustomParticle>(new CustomParticle));
        CustomParticle * p = customParticles.back().get();
		float r = ofRandom(3, 10);		// a random radius 4px - 20px
		p->setPhysics(0.4, 0.53, 0.31);
		p->setup(box2d.getWorld(), mouseX, mouseY, r);
		p->color.r = ofRandom(20, 100);
		p->color.g = 0;
		p->color.b = ofRandom(150, 255);
	}
    
	if(key == 'f') bMouseForce = !bMouseForce;
	if(key == 't') ofToggleFullscreen();
}
Beispiel #2
0
//--------------------------------------------------------------
void testApp::keyPressed(int key) {

    if(key == 'c') {
        float r = ofRandom(4, 20);		// a random radius 4px - 20px
        ofxBox2dCircle circle;
        circle.setPhysics(3.0, 0.53, 0.1);
        circle.setup(box2d.getWorld(), mouseX, mouseY, r);
        circles.push_back(circle);
    }
    if(key == 'z') {
        float r = ofRandom(3, 10);		// a random radius 4px - 20px
        CustomParticle p;
        p.setPhysics(0.4, 0.53, 0.31);
        p.setup(box2d.getWorld(), mouseX, mouseY, r);
        p.color.r = ofRandom(20, 100);
        p.color.g = 0;
        p.color.b = ofRandom(150, 255);
        customParticles.push_back(p);
    }
    if(key == 'b') {
        float w = ofRandom(4, 20);
        float h = ofRandom(4, 20);
        ofxBox2dRect rect;
        rect.setPhysics(3.0, 0.53, 0.1);
        rect.setup(box2d.getWorld(), mouseX, mouseY, w, h);
        boxes.push_back(rect);
    }

    if(key == 's') bDrawLines = !bDrawLines;
    if(key == 'f') bMouseForce = !bMouseForce;
}
Beispiel #3
0
//--------------------------------------------------------------
void testApp::keyPressed(int key) {

    if(key == 'c') {
        float r = ofRandom(4, 20);		// a random radius 4px - 20px
        ofxBox2dCircle circle;
        circle.setPhysics(3.0, 0.53, 0.1);
        circle.setup(box2d.getWorld(), mouseX, mouseY, r);
        circles.push_back(circle);
    }
    if(key == 'z') {
        float r = ofRandom(3, 10);		// a random radius 4px - 20px
        CustomParticle p;
        p.setPhysics(0.4, 0.53, 0.31);
        p.setup(box2d.getWorld(), mouseX, mouseY, r);
        p.color.r = ofRandom(20, 100);
        p.color.g = 0;
        p.color.b = ofRandom(150, 255);
        customParticles.push_back(p);
    }

    // add some lines
    if(key == '0') {
        ofPoint p1(ofRandomWidth(), 20);
        ofPoint p2(p1.x+ofRandom(5, 120), ofRandom(20, 130));

        ofxBox2dLine line;
        line.setPhysics(1.0, 0.4, 0.3);;
        line.setup(box2d.getWorld(), p1, p2);
        lines.push_back(line);
    }

    if(key == '1') {
        ofxBox2dCircle circle;
        circle.setPhysics(1.0, 0.4, 0.3);;
        circle.setup(box2d.getWorld(), ofGetMouseX(), ofGetMouseY(), ofRandom(3, 10));
        circles.push_back(circle);
    }


    if(key == '2') {
        float w = ofRandom(4, 20);
        float h = ofRandom(4, 20);
        ofxBox2dRect rect;
        rect.setPhysics(3.0, 0.53, 0.1);
        rect.setup(box2d.getWorld(), mouseX, mouseY, w, h);
        boxes.push_back(rect);
    }


    if(key == 's') bDrawLines = !bDrawLines;
    if(key == 'f') bMouseForce = !bMouseForce;
    if(key == 't') ofToggleFullscreen();
}
Beispiel #4
0
//--------------------------------------------------------------
void box2dScene::addObject(){
    
    for(int i = 0; i < 600; i ++){
        customParticles.push_back(shared_ptr<CustomParticle>(new CustomParticle));
        CustomParticle * p = customParticles.back().get();
        //        float r = ofRandom(size-1, size);
        p->setPhysics(density,bounce,friction);
        p->setup(box2d.getWorld(),ofRandom(w),ofRandom(RM->getRectForScreen(SCREEN_LEFT).y, RM->getRectForScreen(SCREEN_LEFT).y + 300),scale);
        
        p->color = 180;
        
    }
    
}
//--------------------------------------------------------------
void testApp::keyPressed(int key) {
	
	
	if(key == 'z') {
		float r = ofRandom(3, 10);		// a random radius 4px - 20px
		CustomParticle p;
		p.setPhysics(0.4, 0.1, 0.9);
		p.setup(box2d.getWorld(), mouseX, mouseY, r);
		p.color.r = ofRandom(20, 100);
		p.color.g = 0;//ofRandom(0, 255);
		p.color.b = ofRandom(150, 255);
		customParticles.push_back(p);
	}	
	
	
	if(key == 's') bDrawLines = !bDrawLines;
	if(key == 'f') bMouseForce = !bMouseForce;
}
Beispiel #6
0
//--------------------------------------------------------------
void TuioKinect::draw()
{
	float height = (float)ofGetHeight();
	float width = (float)ofGetWidth() ; 
	
	ofSetColor(0,0,0,200) ; 
	
	//Additive blend mode
	glBlendFunc(GL_SRC_COLOR, GL_ONE);
	
	ofSetColor(255, 255, 255) ; 
	ofEnableSmoothing();
	
	for(int i=0; i< customParticles.size(); i++) 
	{
		customParticles[i].draw(0);
	}
	
	box2d.draw();
	box2d.drawGround() ;

	ofSetColor(255, 255, 255);
	std::list<TuioCursor*> alive_cursor_list = tuioServer->getTuioCursors();
	std::list<TuioCursor*>::iterator alive_cursor;
	
	for (alive_cursor=alive_cursor_list.begin(); alive_cursor!= alive_cursor_list.end(); alive_cursor++) 
	{
		TuioCursor *ac = (*alive_cursor);
		
		float absXSpeed = ac->getXSpeed() ;
		float absYSpeed = ac->getYSpeed() ;
		float xpos = ac->getX() * (float)ofGetWidth() ; 
		float ypos = ac->getY() * (float)ofGetHeight() ; 
		
		absXSpeed = ( absXSpeed < 0 ) ? absXSpeed * -1 : absXSpeed ; 
		absYSpeed = ( absYSpeed < 0 ) ? absYSpeed * -1 : absYSpeed ; 
			
		if ( absXSpeed > .30 || absYSpeed > .30 ) 
		{	
			int _size  = customParticles.size() ;
			if ( _size < 20 ) 
			{
				CustomParticle p;
				
				if ( _size % 2 == 0 ) 
				{
					p.changeIsFire(true);
				}
				else {
					p.changeIsFire(false) ; 
				}

				float r = ofRandom(.25f, 1.0f); //normalized diff
				p.setPhysics(4.0 * r, .2 * r, .45 * r );
				p.setup(box2d.getWorld(), xpos, ypos, (r*30) );
				p.setVelocity( ac->getXSpeed()*10 , ac->getYSpeed()*10 ) ; 
				customParticles.push_back(p);
			}
		}
		
		//Draw that path!
		drawTuioPath( ac->getPath() ) ; 
	}
	
	//Debug Text
	ofSetColor(255, 255, 255);
	char reportStr[1024];
	sprintf(reportStr, "set near threshold %i (press: + -)\nset far threshold %i (press: < >)\nnum blobs found %i, fps: %i", nearThreshold, farThreshold, (int)contourFinder.blobs.size(), (int)ofGetFrameRate());
	ofDrawBitmapString(reportStr, 20, 650);
	ofEnableAlphaBlending() ; 

	ofSetColor ( 10 , 10 , 10 ); 
	ofFill() ; 
	ofSetLineWidth( 2 ) ;
	ofRect(0, 0, 40, 40 ) ; 
		
	ofSetColor(255, 255, 255 ) ; 
	ofFill() ;

	grayImage.draw(5, 5, 192, 144 );
	contourFinder.draw(5, 5, 192, 144 );
	ofFill() ;
	ofDisableAlphaBlending() ; 
}
Beispiel #7
0
void testApp::setLevel(int lvl){
  ofLog()<<"NEW LEVEL" +ofToString(level)+" "+ofToString(lvl);
  switch(lvl){
    case 0:{
      customParticles.push_back(ofPtr<CustomParticle>(new CustomParticle(1, 0, 100)));
      CustomParticle * p = customParticles.back().get();
      
      float r = ofRandom(3, 10);		// a random radius 4px - 20px
      p->setPhysics(0.4, 0.53, 0.31);
      p->setup(box2d.getWorld(), (int)ofRandom(100,600), 400, p->width, p->height);
      
      
      SoundData * s = new SoundData();
      p->setData(s);
      SoundData * sd = (SoundData*)p->getData();
      sd->type = GUY;
      sd->bHit	= false;
      
      
    }
      break;
    case 1:{
      bullets.clear();
      apples.clear();
      customParticles.push_back(ofPtr<CustomParticle>(new CustomParticle(1, 1, 150)));
      CustomParticle * p = customParticles.back().get();
      
      float r = ofRandom(3, 10);		// a random radius 4px - 20px
      p->setPhysics(0.4, 0.53, 0.31);
      p->setup(box2d.getWorld(), (int)ofRandom(100,600), 300, p->width, p->height);
      
      
      SoundData * s = new SoundData();
      p->setData(s);
      SoundData * sd = (SoundData*)p->getData();
      sd->type = GUY;
      sd->bHit	= false;
    }
      
      break;
    case 2:{
      bullets.clear();
      apples.clear();
      customParticles.push_back(ofPtr<CustomParticle>(new CustomParticle(1, 2, 200)));
      CustomParticle * p = customParticles.back().get();
      
      float r = ofRandom(3, 10);		// a random radius 4px - 20px
      p->setPhysics(0.4, 0.53, 0.31);
      p->setup(box2d.getWorld(),(int)ofRandom(100,600), 400, p->width, p->height);
      
      
      SoundData * s = new SoundData();
     
      p->setData(s);
      SoundData * sd = (SoundData*)p->getData();
      sd->type = GUY;
      sd->bHit	= false;
    }
      
      break;
    case 3:{
      bullets.clear();
      apples.clear();
      customParticles.push_back(ofPtr<CustomParticle>(new CustomParticle(1, 3, 300)));
      CustomParticle * p = customParticles.back().get();
      
      float r = ofRandom(3, 10);		// a random radius 4px - 20px
      p->setPhysics(0.4, 0.53, 0.31);
      p->setup(box2d.getWorld(), mouseX, mouseY, p->width, p->height);
      
      
      SoundData * s = new SoundData();
     
      p->setData(s);
      
      SoundData * sd = (SoundData*)p->getData();
      sd->type = GUY;
      sd->bHit	= false;
    }
      break;
    case 4:{
      bullets.clear();
      apples.clear();
      edgeLine.addVertex(ofGetWidth(), 0);
      edgeLine.addVertex(ofGetWidth(), ofGetHeight()-30);
      
      
      
      edgeLine.setPhysics(0.0, 0.5, 0.5);
      edgeLine.create(box2d.getWorld());
      
      customParticles.push_back(ofPtr<CustomParticle>(new CustomParticle(1, 4, 350)));
      CustomParticle * p = customParticles.back().get();
      movePt.x=(int)ofRandom(100,600);
      movePt.y=(int)ofRandom(10,400);
      
      float r = ofRandom(3, 10);		// a random radius 4px - 20px
      p->setPhysics(0.1, 0.53, 0.31);
      p->setup(box2d.getWorld(), movePt.x, movePt.y, p->width, p->height);
      
      
      SoundData * s = new SoundData();
            p->setData(s);
   
      SoundData * sd = (SoundData*)p->getData();
      sd->type = BIGGUY;
      sd->bHit	= false;
    }
      break;

      
  }

  
}
Beispiel #8
0
//--------------------------------------------------------------
void testApp::update() {

	
	
	box2d.update();
  
  switch(mode){
    case START:{


    }
      break;
    case WON:{
      if(ofGetElapsedTimeMillis()-trans_time > 3000){
        mode=START;
        customParticles.clear();
        bullets.clear();
        apples.clear();
        level=0;
      }
     
    }
      break;
    case PLAY:
      if(ofGetElapsedTimeMillis()-sprite_timer >500){
        sprite_timer= ofGetElapsedTimeMillis();
        CustomParticle * p = customParticles[0].get();
        p->cur.loadImage("hero.gif");
        p->cur.resize(p->cur.getWidth()*0.05, p->cur.getHeight()*0.05);
        p->height= p->cur.getHeight();
        p->width = p->cur.getWidth();
      }
      //BOSS BATTLE
      if(level==4){
        CustomParticle * p = customParticles[1].get();
        
          if(p->getPosition().x > ofGetWidth()-20){
            p->setVelocity(-p->getVelocity().x, p->getVelocity().y);
          }
      
        idx++;
        if(idx%(int)ofRandom(50, 100) == 0){
          customParticles[1].get()->addAttractionPoint(movePt, -4.0f);
         
          movePt.x=(int)ofRandom(100,620);
          movePt.y=(int)ofRandom(10,400);
          
          customParticles[1].get()->addAttractionPoint(movePt, 10.0f);
        }
      }
      
      //BULLETS
      for(int i=0; i<bullets.size(); i++) {
        bullets[i].get()->age++;
        if(bullets[i].get()->age > 100){
          bullets.erase(bullets.begin()+i);
        }
      }
      //BAD BULLETS
      if(level > 1){
        int prob=20;
        if(level == 4) prob=30;
        if(ofRandom(1000)<prob){
          ofLog()<<"SHOOOOOOOT";
  //        shoot.play();
          apples.push_back(ofPtr<Bullet>(new Bullet(1)));
          Bullet * p = apples.back().get();
          
          p->setPhysics(0.4, 0.5, 0.31);
          p->setup(box2d.getWorld(), customParticles[1]->getPosition().x, customParticles[1]->getPosition().y-10, p->width, p->height);
          p->addForce(customParticles[1]->getVelocity(), 80);
          p->addForce(ofVec2f(0,1), 60);
          if(level > 2){
            p->addAttractionPoint(customParticles[0].get()->getPosition(), 50.0f);
          }
          
          SoundData * s = new SoundData();
         
          p->setData(s);
         
          SoundData * sd = (SoundData*)p->getData();
          sd->type = BADBULLET;
          sd->bHit	= false;
        }
      }
      
      for(int i=0; i<apples.size(); i++) {
        apples[i].get()->age++;
        if(apples[i].get()->age > 100){
          apples.erase(apples.begin()+i);
        }
      }
      
      for(int i=0; i<customParticles.size();i++){
        CustomParticle * p = customParticles[i].get();
        if(i==0){
          if(p->getPosition().x > ofGetWidth()-50){
            p->setVelocity(-p->getVelocity().x, p->getVelocity().y);
          }
        }
        SoundData * sd = (SoundData*)p->getData();
        if(sd->bHit){
          customParticles[i].get()->hurt(10);
        }
        if(p->hp < 0 && i!= 0){
          
          p->addForce(ofVec2f(3,-5), 40);

        }
        if(customParticles[0].get()->hp < 0){
          trans_time = ofGetElapsedTimeMillis();
          //win.play();
          ofLog()<<"LOST";
          mode=LOST;
        }
        
        if((customParticles.size()< 2 || customParticles[1].get()->hp < 0) &&ofGetElapsedTimeMillis()-trans_time > 500){
          if(level<4){
            ofLog()<<"LVLUP";
            level++;
            setLevel(level);
            trans_time=ofGetElapsedTimeMillis();
//          }else{
//            trans_time = ofGetElapsedTimeMillis();
//            win.play();
//            mode=WON;
          }
        }
        if(level==4 && customParticles[1].get()->hp<0){
          trans_time = ofGetElapsedTimeMillis();
          win.play();
          ofLog()<<"WON";
          mode=WON;
        }
      }
      break;
  }
    // remove shapes offscreen
    ofRemove(bullets, ofxBox2dBaseShape::shouldRemoveOffScreen);
//    ofRemove(bullets,bulletDies);
    ofRemove(customParticles, ofxBox2dBaseShape::shouldRemoveOffScreen);
    
}
Beispiel #9
0
//--------------------------------------------------------------
void testApp::draw(){

// MARK: DRAW KINECT POINT CLOUD    
//    int inc = 20;
//    for (int i = 0; i < kinect.pointCloud.size(); i+=inc) {
//        
//        float z = (kinect.pointCloud[i].z < 0.001) ? 1 : kinect.pointCloud[i].z;
//
//        float prox = (1.0 - z);
//        float sz = pow(prox, 3) * inc;
//        ofCircle(kinect.pointCloud[i].x * (float)ofGetWidth(), kinect.pointCloud[i].y * (float)ofGetHeight(), sz);
//
//        int limit_w = kinect.getOutputWidth();
//        if(i % limit_w == 0) {
//            i += inc * limit_w;
//        }
//    }
    
    
// MARK: DRAW BOX2D PARTICLES TO FBO
    fbo.begin();
    ofClear(0, 0, 0, 255);
    
    if(isFilterActive) {
        shader.begin();
        shader.setUniform1i("u_ratio", ledRatio);
    }
    
    for(int i = 0; i < b2dParticles.size(); i++) {
        CustomParticle p = b2dParticles[i];
        Data * customData = (Data*)p.getData();        
        
        
        if(kinect.pointCloud.size() > 0) {
//            int relativeX = ofMap(p.getPosition().x, 0, FBO_W, 0, kinect.getOutputWidth());            
            int relativeX = ofMap(p.getPosition().x, 0, FBO_W, 0, OUTPUT_SCREEN_W);
            relativeX = ofMap(relativeX, 0, OUTPUT_SCREEN_W, 0, kinect.getOutputWidth());
            int relativeY = ofMap(p.getPosition().y, 0, FBO_H, 0, kinect.getOutputHeight());
            
            int relativeKinectIndex = relativeX + (kinect.getOutputWidth() * relativeY);
            
            if(relativeKinectIndex < kinect.pointCloud.size()) {
                ofPoint kinectPoint = kinect.pointCloud[relativeKinectIndex];
                float z = (kinectPoint.z < 0.001) ? 1 : kinectPoint.z;
                float prox = 1.2 - z;
                
                float sz = 0;
                switch(customData->scope) {
                    case PERSONAL:
                        sz += personalMinParticleSize;
                        break;
                    case NEIGHBORHOOD:
                        sz += neighborhoodMinParticleSize;
                        break;
                    case CITY:
                        sz += cityMinParticleSize;
                        break;
                }                
                sz += prox * 80.0;

                float r = p.getRadius();
                
                // property = (target - property) / speed
                r += (sz - r) / 4.0f;
                
                p.setRadius(r);
            }
        }    

        p.draw();
    }
    
    if(isDebugingBox2d) { 
        ofEnableAlphaBlending();
        
        // DRAW JOINTS
        for(int j = 0; j < b2dJoints.size(); j++) {
            ofSetColor(255, 70);
            b2dJoints[j].draw();        
        }
        
        // DRAW ANCHORS
        ofSetColor(70);
        ofCircle(personalAnchorBottom.getPosition(), 4);
        ofCircle(personalAnchorTop.getPosition(), 4);
        ofCircle(personalAnchorLeft.getPosition(), 4);
        ofCircle(personalAnchorRight.getPosition(), 4);
        ofCircle(neighborhoodAnchorBottom.getPosition(), 4);
        ofCircle(neighborhoodAnchorTop.getPosition(), 4);
        ofCircle(neighborhoodAnchorLeft.getPosition(), 4);
        ofCircle(neighborhoodAnchorRight.getPosition(), 4);
        ofCircle(cityAnchorBottom.getPosition(), 4);
        ofCircle(cityAnchorTop.getPosition(), 4);
        ofCircle(cityAnchorLeft.getPosition(), 4);
        ofCircle(cityAnchorRight.getPosition(), 4);
    }

    if(isFilterActive) {        
        shader.end();
    }
    
    fbo.end();
    
    ofSetColor(255);
    fbo.draw(0,0);
// --------------------------------------------
    
// CHEAT: PILLARS MASK
    ofSetColor(25, 255);
    ofFill();
    ofRect(OUTPUT_SCREEN_W/3.0, 0, (FBO_W-OUTPUT_SCREEN_W)/2.0, FBO_H);
    ofRect(FBO_W - (OUTPUT_SCREEN_W/3.0) - (FBO_W-OUTPUT_SCREEN_W)/2.0, 0, (FBO_W-OUTPUT_SCREEN_W)/2.0, FBO_H);
// --------------------------------------------
    
    if(isGUIActive) {
        drawGUI();
    }
    
}
Beispiel #10
0
void testApp::addParticles(int scope, int type, int num, float density, float bounce, float friction) {    

    ofVec2f attract;
    switch(scope) {
        case PERSONAL: 
            attract.set(personalCenter.x, personalCenter.y);
            break;
        case NEIGHBORHOOD: 
            attract.set(neighborhoodCenter.x, neighborhoodCenter.y);
            break;
        case CITY: 
            attract.set(cityCenter.x, cityCenter.y);
            break;
    }
    
    int deltaX = 120;
    int typeY = 0;
    switch(type) {
        case NEGATIVE:
            typeY = attract.y + 100;
            break;
        case NEUTRAL:
            typeY = attract.y - 100;
            break;
        case POSITIVE:
            typeY = attract.y - 100;
            break;
    }

    for(int i = 0; i < num ; i++) {
        
    // MARK: create particle
        CustomParticle p;        
        
        //density, restitution/bounce, friction
        p.setPhysics(density, bounce, friction);

        float x = ofRandom(attract.x - deltaX, attract.x + deltaX);
        float y = typeY;
        
        switch(scope) {
            case PERSONAL:
                p.setup(box2d.getWorld(), x, y, personalMinParticleSize);
                break;
            case NEIGHBORHOOD:
                p.setup(box2d.getWorld(), x, y, neighborhoodMinParticleSize);
                break;
            case CITY:
                p.setup(box2d.getWorld(), x, y, cityMinParticleSize);
                break;                
        }
        p.setupTheCustomData(scope, type, attract.x, attract.y);
        
        
    // MARK: create joints        
		ofxBox2dJoint jointLeft;
        ofxBox2dJoint jointRight;
		
        float jointLength    = 100.0f; //50;
        float jointDamping   = 0.2f; //0.2;
        float jointFrequency = 1.0f; //1.0
        
        switch(scope) {
            case PERSONAL: 
                jointLeft.setup(box2d.getWorld(), personalAnchorLeft.body, p.body);		
                jointRight.setup(box2d.getWorld(), personalAnchorRight.body, p.body);
                if( type == NEGATIVE ) {
                    ofxBox2dJoint jointBottom;
                    jointBottom.setup(box2d.getWorld(), personalAnchorBottom.body, p.body);
                    jointBottom.setDamping(jointDamping);
                    jointBottom.setFrequency(jointFrequency);
                    jointBottom.setLength(jointLength);
                    b2dJoints.push_back(jointBottom);
                } else if( type == POSITIVE ) {
                    ofxBox2dJoint jointTop;
                    jointTop.setup(box2d.getWorld(), personalAnchorTop.body, p.body);
                    jointTop.setDamping(jointDamping);
                    jointTop.setFrequency(jointFrequency);
                    jointTop.setLength(jointLength);
                    b2dJoints.push_back(jointTop);
                }
                break;
            case NEIGHBORHOOD: 
                jointLeft.setup(box2d.getWorld(), neighborhoodAnchorLeft.body, p.body);		
                jointRight.setup(box2d.getWorld(), neighborhoodAnchorRight.body, p.body);		
                if( type == NEGATIVE ) {
                    ofxBox2dJoint jointBottom;
                    jointBottom.setup(box2d.getWorld(), neighborhoodAnchorBottom.body, p.body);
                    jointBottom.setDamping(jointDamping);
                    jointBottom.setFrequency(jointFrequency);
                    jointBottom.setLength(jointLength);
                    b2dJoints.push_back(jointBottom);
                } else if( type == POSITIVE ) {
                    ofxBox2dJoint jointTop;
                    jointTop.setup(box2d.getWorld(), neighborhoodAnchorTop.body, p.body);
                    jointTop.setDamping(jointDamping);
                    jointTop.setFrequency(jointFrequency);
                    jointTop.setLength(jointLength);
                    b2dJoints.push_back(jointTop);
                }
                break;
            case CITY: 
                jointLeft.setup(box2d.getWorld(), cityAnchorLeft.body, p.body);		
                jointRight.setup(box2d.getWorld(), cityAnchorRight.body, p.body);		
                if( type == NEGATIVE ) {
                    ofxBox2dJoint jointBottom;
                    jointBottom.setup(box2d.getWorld(), cityAnchorBottom.body, p.body);
                    jointBottom.setDamping(jointDamping);
                    jointBottom.setFrequency(jointFrequency);
                    jointBottom.setLength(jointLength);
                    b2dJoints.push_back(jointBottom);
                } else if( type == POSITIVE ) {
                    ofxBox2dJoint jointTop;
                    jointTop.setup(box2d.getWorld(), cityAnchorTop.body, p.body);
                    jointTop.setDamping(jointDamping);
                    jointTop.setFrequency(jointFrequency);
                    jointTop.setLength(jointLength);
                    b2dJoints.push_back(jointTop);
                }
                break;
        }
		
        jointLeft.setDamping(jointDamping);
        jointLeft.setFrequency(jointFrequency);
		jointLeft.setLength(jointLength);

        jointRight.setDamping(jointDamping);
        jointRight.setFrequency(jointFrequency);
		jointRight.setLength(jointLength);
        
        
    // MARK: add joints and particle to relative vectors
		b2dJoints.push_back(jointLeft);
		b2dJoints.push_back(jointRight);
        b2dParticles.push_back(p);
    }
    
}