Beispiel #1
0
Scope::Scope(QObject* owner) :
		QObject(owner), GateFactory("Scope"), enabled(1) {
	Gate g(this, "Scope()");
	int count = 100;
	double scale = 1;
	// TODO Auto-generated constructor stub
	rings << DrawTools::drawArc(scale * 1, 0, M_PI * 2, count);
	rings << DrawTools::drawArc(scale * 0.9, 0, M_PI * 2, count);
	rings << DrawTools::drawArc(scale * 0.7, 0, M_PI * 2, count);
	rings << DrawTools::drawArc(scale * 0.3, 0, M_PI * 2, count);

	for (int i = 0; i < 360; ++i) {
		double angle = M_PI * 2 / 360 * i;
		if (i % 10 == 0) {
			spokes << DrawTools::drawRadialLine(scale * 0.2, scale * 1, angle);
		}
		ticks << DrawTools::drawRadialLine(scale * 1, scale * 1.03, angle);
	}

	for (int i = 0; i < 180; i += 9) {
		recordHit(i, 1024 * i / 180);
	}
}
Beispiel #2
0
void testApp::mouseReleased(int x, int y, int button) {
	switch (state) {
		case STATE_INTRO:
			// Play the "brains" sound here so it only happens the first time.
			if (!mute) {
				themeSound.stop();
				brainsSound.play();
			}
			setState(STATE_READY);
			break;
		case STATE_READY:
			setState(STATE_MISS);
			break;
		case STATE_ZOMBIE:
			if (hitZombie(mouseX, mouseY, false)) {
				setState(STATE_HIT);
				recordHit();
			}
			else {
				setState(STATE_MISS);
				recordMiss();
			}
			break;
		case STATE_MISS:
			recordMiss();
			break;
		case STATE_HIT:
			break;
		case STATE_SCORE:
			hits.clear();
			misses.clear();
			
			setState(STATE_READY);
			break;
	}
}
Beispiel #3
0
void testApp::update() {
	if (deadline > 0 && ofGetSystemTime() > deadline) {
		deadline = -1;
		
		switch (state) {
			case STATE_INTRO:
				break;
			case STATE_READY:
				setState(STATE_ZOMBIE);
				break;
			case STATE_ZOMBIE:
				setState(STATE_READY);
				break;
			case STATE_MISS:
				setState(STATE_READY);
				break;
			case STATE_HIT:
				setState(STATE_HIT_MESSAGE);
				break;
			case STATE_HIT_MESSAGE:
				if (hits.size() > 4) {
					setState(STATE_SCORE);
				}
				else {
					setState(STATE_READY);
				}
				break;
			case STATE_SCORE:
				break;
		}
	}
	else {
		switch (state) {
			case STATE_INTRO:
				break;
			case STATE_READY:
				break;
			case STATE_ZOMBIE:
				break;
			case STATE_MISS:
				break;
			case STATE_HIT:
				break;
			case STATE_HIT_MESSAGE:
				break;
			case STATE_SCORE:
				break;
		}
	}
	
    simpleHands = leap.getSimpleHands();
    
    if (leap.isFrameNew() && simpleHands.size()) {
        leap.setMappingX(-230, 230, -ofGetWidth()/2, ofGetWidth()/2);
		leap.setMappingY(90, 490, -ofGetHeight()/2, ofGetHeight()/2);
        leap.setMappingZ(-150, 150, -200, 200);
		
		hasFingers = false;
        for(int i = 0; i < simpleHands.size(); i++){
            for(int j = 0; j < simpleHands[i].fingers.size(); j++){
                int id = simpleHands[i].fingers[j].id;
				cout << leapPoint.y << endl;
				// pt.x range is ±700
				// pt.y doesn't matter
				// pt.z is a click when < -200
				leapPoint = simpleHands[i].fingers[j].pos;
				if (leapPoint.z < -200) {
					if (!fingerClicking) {
						cout << "Fingered!" << endl;
						switch (state) {
							case STATE_INTRO:
								setState(STATE_READY);
								break;
								
							case STATE_READY:
								break;
								
							case STATE_ZOMBIE:
								if (hitZombie(ofMap(leapPoint.x, calibrationMinX, calibrationMaxX, 0, screenWidth), ofMap(leapPoint.y, calibrationMinY, calibrationMaxY, 0, screenHeight), true)) {
									setState(STATE_HIT);
									recordHit();
								}
								else {
									setState(STATE_MISS);
									recordMiss();
								}
								break;
								
							case STATE_HIT:
								break;
								
							case STATE_HIT_MESSAGE:
								break;
								
							case STATE_MISS:
								break;
								
							case STATE_SCORE:
								hits.clear();
								misses.clear();
								
								setState(STATE_READY);
								break;
						}
						fingerClicking = true;
					}
				}
				else {
					fingerClicking = false;
				}
				
				hasFingers = true;
            }
        }
    }
	
	leap.markFrameAsOld();
}