Exemplo n.º 1
0
//--------------------------------------------------------------
void testApp::draw(){
    //
    //    ofColor colorOne;
    //    ofColor colorTwo;
    //
    //    colorTwo.set (0, 20, 255);
    //    colorOne.set (0, 100, 255);
    //
    //    ofBackgroundGradient(colorOne, colorTwo);
    
    ofFill();
    
    ofSetColor(0,100,255, 255*0.05);
    ofGradientMode();
    ofRect( ofGetWindowRect() );
    
    //ofNoFill();
    ofFill();
    ofSetColor(245, 255, 0, 100);
    
	for (int i = 0; i < particles.size(); i++){
		particles[i].draw();
        particles[i].xenoToPoint(mouseX, mouseY);
        
	}
    
    for (int j = 0; j < particles2.size(); j++){
		particles2[j].draw2();
        particles2[j].xenoToPoint2(mouseX, mouseY);
        
	}
    
    
}
Exemplo n.º 2
0
	//--------------------------------------------------------------
	void mouseMoved(int x, int y){
		if ((dragged==false) && (!ofGetWindowRect().inside(x,y))) {
			// detect if mouse goes out of window
			ofxOscMessage ms;
			ms.setAddress("/out_of_window");
			sender.sendMessage(ms);
		}
	}
Exemplo n.º 3
0
//--------------------------------------------------------------
void testApp::draw() {
    ofFill();

    ofSetColor(0,0,0, 255*0.1);
    ofRect( ofGetWindowRect() );

    ofNoFill();

    for( int i=0; i<100; i++) {
        ofSetColor( 255, 255, 255, 255 * 0.2 );
        mParticleList[i].draw();
    }
}
            //--------------------------------------------------------------
            void Renderer::draw() {
                // TODO: fix sorting, if z-order is same, undefined behaviour
                sort(controls.begin(), controls.end(), PointerCompare());
                
                ofPushStyle();
//                ofLogNotice() << "Renderer::draw :" << controls.size();
                for(int i=0; i<controls.size(); i++) {
                    Control& control = *controls[i];
                    if(control.intersects(ofGetWindowRect())) control._draw();
//                    ofLogNotice() << "   " << control.getParameter().getPath() << " " << control.getParameter().getTypeName();
                }
//                ofLogNotice() << "/Renderer::draw \n";
                
                drawToolTip();
                
                ofPopStyle();
            }
Exemplo n.º 5
0
//--------------------------------------------------------------
void testApp::setup(){
	
	ofSetVerticalSync(true);
	
//    ofSetBackgroundAuto(false);
    ofBackground(0);
	ofSetCircleResolution(100);
	ofEnableAlphaBlending();
    
    ofFill();
	ofSetRectMode( OF_RECTMODE_CORNER );
    ofSetColor(0,0,0,255);
    ofRect( ofGetWindowRect() );
    
    rotation.x = 0;
    rotation.y = 0;
    rotation.z = 0;
    
    mySound.loadSound("whitney.mp3", true);
    mySound.play();
}
Exemplo n.º 6
0
//--------------------------------------------------------------
void testApp::draw(){
	
    
    
    ofFill();
    
    ofSetColor(0, 0, 0, 2);
    ofRect( ofGetWindowRect() );
    
    ofSetColor(ofRandom(0,255),ofRandom(0,155),ofRandom(0,155));
    for (int i=0; i < particleList.size(); i++){
        particleList[i].draw();
    }
	
    ofNoFill();
	
	ofBeginShape();
	for (int i = 0; i < particleList.size(); i++){
		ofVertex(particleList[i].pos.x, particleList[i].pos.y);
	}
	ofEndShape();
}
Exemplo n.º 7
0
//--------------------------------------------------------------
void ofApp::setup(){
    ofEnableSmoothing();
    ofBackground(0);
    
    // voronoi
    voronoi.setBounds(ofGetWindowRect());
    
    // add random 5 points
    for (int i = 0; i < 5; i++) {
        ofPoint instantPoint(ofRandom(0, ofGetWidth()), ofRandom(0, ofGetHeight()));
        
        // delaunay
        triangulation.addPoint(instantPoint);
        
        // voronoi
        voronoi.addPoint(instantPoint);
    }
    
    // delaunay
    triangulation.triangulate();
    
    // voronoi
    voronoi.generate();
    
    // sound
    player.load("beat.mp3");
    player.play();
    
    // gui
    panel.setup();
    panel.add(showDelaunayBackground.set("showDelaunayBackground", true));
    panel.add(showDelaunayWireframe.set("showDelaunayWireframe", true));
    panel.add(showDelaunayVertices.set("showDelaunayVertices", true));
    panel.add(showDelaunayCenter.set("showDelaunayCenter", true));
    panel.add(showVoronoi.set("showVoronoi", true));
    
    showGui = true;
}
Exemplo n.º 8
0
void hlct::Game::setup(const ofRectangle& rect){
    
    this->resize(rect);
    setupInfoScreens(rect);
    
    background.setup(rect, imgPack.background->getPixels());
    
    helmets.clear();
    
    state = GAME_STATE_TITLE;
    
    ofRectangle stageRect(rect.getTopLeft(), rect.getWidth(), rect.getHeight());
    
    gameStartTimer.setDuration(HLCT_USER_POSE_DURATION);
    gameStartTimer.setCurve(LINEAR);
    
    gameTimer.setRepeatType(PLAY_ONCE);
    gameTimer.setRepeatTimes(0);
    gameTimer.setCurve(LINEAR);
    
    gameEndTimer.setDuration(HLCT_GAME_END_TO_TITLE_DURATION);
    gameEndTimer.setCurve(LINEAR);
    
    livesDisplay.setup(imgPack, HLCT_LIVES);
    
    params.setName("Game");
    
    ofParameterGroup stageParams;
    stageParams.setName("Stage");
    stageParams.add(bDebug.set("Debug Mode", false));
    stageParams.add(stagePos.set("Top Left", ofVec2f(HLCT_CLAMP_STAGE, 40), ofVec2f::zero(), ofGetWindowRect().getBottomRight()));
    stageParams.add(stageWidth.set("Width", ofGetWidth() - HLCT_CLAMP_STAGE * 2, ofGetWidth()/2, ofGetWidth()*2));
    stageParams.add(stageHeight.set("Height", ofGetHeight() - 200, ofGetHeight()/2, ofGetHeight()*2));
    stageParams.add(dropX.set("Drop Left", 0, 0, ofGetWidth()/2));
    stageParams.add(dropWidth.set("Drop Width", 0, 0, ofGetWidth()));
    stageParams.add(loadingBarOffsetBottom.set("Loadingbar Offset", 120, -500, 500));
    
    ofParameterGroup alignParams;
    alignParams.setName("Scaling and Alignment");
    alignParams.add(scaleHero.set("Hero Scale", .5f, HLCT_HERO_SCALE_MIN, HLCT_HERO_SCALE_MAX));
    alignParams.add(scaleBait.set("Dropping Scale", .3f, HLCT_BAIT_SCALE_MIN, HLCT_BAIT_SCALE_MAX));
    alignParams.add(scaleBaitWin.set("Win Scale", .3f, HLCT_BAIT_SCALE_MIN, HLCT_BAIT_SCALE_MAX));
    alignParams.add(offsetBaitWin.set("Win Offset", 70, HLCT_BAIT_WIN_OFFSET_MIN, HLCT_BAIT_WIN_OFFSET_MAX));
    alignParams.add(diffBaitWin.set("Win Diff", .05f, HLCT_BAIT_WIN_DIFF_MIN, HLCT_BAIT_WIN_DIFF_MAX));
    alignParams.add(scaleLive.set("Live Scale", .75f, HLCT_LIVE_SCALE_MIN, HLCT_LIVE_SCALE_MAX));
    
    ofParameterGroup gameParams;
    gameParams.setName("Game Settings");
    gameParams.add(bStart.set("New", false));
    gameParams.add(endTime.set("Duration", 50, HLCT_MIN_DURATION, HLCT_MAX_DURATION));
    gameParams.add(currentTimeStr.set("Curent Time", "0"));
    gameParams.add(bPaused.set("Paused", false));
    
    params.add(stageParams);
    params.add(alignParams);
    params.add(gameParams);
    params.add(score.set("Score", 0, 0, HLCT_MAX_CATCH));
    
    params.add(bUserExists.set("User Exists", false));
    params.add(bUserPosing.set("User Posing", false));
    useOsc.set("Use Osc", true);
    bAddHelmet.set("Add Helmet", false);
    helmetSection.set("Helmet Section", 0, 0, HLCT_HELMET_SECTION_COUNT);
    
    scaleHero.addListener(this, &Game::handleScaleHero);
    scaleBait.addListener(this, &Game::handleScaleBait);
    scaleBaitWin.addListener(this, &Game::handleScaleBaitWin);
    bUserExists.addListener(this, &Game::handleUserExists);
    bUserPosing.addListener(this, &Game::handlePosing);
    bStart.addListener(this, &Game::handleGameStart);
    bAddHelmet.addListener(this, &Game::handleAddHelmet);
    
    receiver.setup(HLCT_OSC_PORT);
}
Exemplo n.º 9
0
void testApp::updateParticleSystem(ofxParticleSystem *ps, ofVec2f gravitationCenter, ofVec2f leftHand, ofVec2f rightHand, HandState leftHandState, HandState rightHandState) {
	float dt = min(ofGetLastFrameTime(), 1.0 / 10.0);
	ps->attractTo(gravitationCenter, gravAcc, 1, false);
	ps->gravitateTo(gravitationCenter, gravAcc, 1, 150.0, false);
	//ps->attractTo(ofPoint(ofGetWidth() / 2, ofGetHeight() / 2), gravAcc, 1, false);
	//ps->gravitateTo(ofPoint(ofGetWidth() / 2, ofGetHeight() / 2), gravAcc, 1, 150.0, false);
	ps->rotateAround(ofPoint(ofGetWidth() / 2, ofGetHeight() / 2), rotAcc, 10.0, false);
	//ps->rotateAround(gravitationCenter, rotAcc, 10.0, false);
	ps->applyVectorField(vectorField.getPixels(), vectorField.getWidth(), vectorField.getHeight(), vectorField.getNumChannels(), ofGetWindowRect(), fieldMult);
	if (leftHandState == HandState_Closed) {
		ps->gravitateTo(ofPoint(leftHand.x, leftHand.y), gravAcc, 1, 10.0, false);
	}

	if (rightHandState == HandState_Closed) {
		ps->gravitateTo(ofPoint(rightHand.x, rightHand.y), gravAcc, 1, 10.0, false);
	}

	ps->update(dt, drag);

	if (gravitationCenter.x > 0 && gravitationCenter.y > 0) {
		if (isLeftEmitterEnabled)
			ps->addParticles(leftEmitter);
		if (isRightEmitterEnabled)
			ps->addParticles(rightEmitter);
		if (isTopEmitterEnabled)
			ps->addParticles(topEmitter);
		if (isBottomEmitterEnabled)
			ps->addParticles(botEmitter);


		ofVec2f mouseVelLeft(leftHand.x - pmouseXLeft, leftHand.y - pmouseYLeft);
		mouseVelLeft *= 20.0;
		if (leftHandState == HandState_Open) {
			leftHandEmitter.setPosition(ofVec3f(leftHand.x, leftHand.y), ofVec3f(leftHand.x, leftHand.y));
			leftHandEmitter.posSpread = ofVec3f(10.0, 10.0, 0.0);
			leftHandEmitter.setVelocity(pmouseVelLeft, mouseVelLeft);
			ps->addParticles(leftHandEmitter);
		}
		pmouseXLeft = leftHand.x;
		pmouseYLeft = leftHand.y;
		pmouseVelLeft = mouseVelLeft;


		ofVec2f mouseVelRight(rightHand.x - pmouseXRight, rightHand.y - pmouseYRight);
		mouseVelRight *= 20.0;
		if (rightHandState == HandState_Open) {
			rightHandEmitter.setPosition(ofVec3f(rightHand.x, rightHand.y), ofVec3f(rightHand.x, rightHand.y));
			rightHandEmitter.posSpread = ofVec3f(10.0, 10.0, 0.0);
			rightHandEmitter.setVelocity(pmouseVelRight, mouseVelRight);
			ps->addParticles(rightHandEmitter);
		}
		pmouseXRight = rightHand.x;
		pmouseYRight = rightHand.y;
		pmouseVelRight = mouseVelRight;
	}
}