/**
 * Método principal invocado al comenzar cada turno.
 *
 * @return void
 */
void robotMain() {
	int movingTo = 0;

	debug drawAmmo();
	debug drawLife();

	if (getY() == 7 || getY() == 0 || getX() == 0 || getX() == 7) {
		wallReached = 1;
	}

	if (!wallReached) {
		movingTo = closestWallDir();

		debug printf("[Robot %d] moviendo a: %d\n", getpid(), movingTo);
		doMove(movingTo);
	} else {
	    if (look) {
	        look = 0;
    		wallerScan(); // escanea en la dirección opuesta
		} else {
		    look = 1;
		    wallerMove();
		}
	}
}
Exemple #2
0
void testApp::draw(){
	ofSetMinMagFilters(GL_NEAREST, GL_NEAREST);
		
	ofBackground(0);
	ofSetColor(255);
	
	if(playerCount == 0) {
		float rescale = ofMap(sin(ofGetElapsedTimef() * 5), -1, 1, .8, 1.2);
		ofSetColor(magenta);
		drawTitle("WAITING FOR PLAYER", rescale);
	} else if(playerCount == 1) {
		ofVec2f offset(ofRandomf(), ofRandomf());
		offset *= 5;
		ofSetColor(cyan);
		ofPushMatrix();
		ofTranslate(offset.x, offset.y);
		drawTitle("AWAITING CHALLENGER");
		ofPopMatrix();
	} else if(playerCount == 2) {
		for(int i = 0; i < projectiles.size(); i++) {
			projectiles[i].draw();
		}
		
		ofSetColor(255);
		for(int i = 0; i < players.size(); i++) {
			if(players[i].life > 0) {
				ofPushMatrix();
				ofTranslate((int) players[i].position.x, (int) players[i].position.y);
				ofScale(2, 2);
				if(players[i].position.x > ofGetWidth() / 2) {
					ofScale(-1, 1);
				}
				if(i == 0) {
					maskedDraw(ryu);
				} else {
					maskedDraw(ken);
				}
				ofPopMatrix();
			}
		}
	}
	
	int winner = 0;
	if(playerCount == 2) {
		bool done = false;
		for(int i = 0; i < players.size(); i++) {
			drawLife(i);
			if(players[i].life <= 0) {
				done = true;
			} else {
				winner = i;
			}
		}
		if(done && !lastDone) {
			youWin.play();
		}
		lastDone = done;
	}
	
	if(playerCount == 2 && lastDone) {
		bool flash = sin(2. * ofGetElapsedTimef() * TWO_PI) > 0;
		ofSetColor(flash ? yellow : 0);
		drawTitle("PLAYER " + ofToString(winner + 1) + " WINS");
	}
	
	if(panel.getValueB("debug")) {
		ofSetColor(255);
		for(int i = 0; i < players.size(); i++) {
			ofCircle(players[i].position, 32);
		}
	}
}
Exemple #3
0
void ACharacter::drawInformation(sf::RenderWindow& win)
{
	drawName(win);
	drawLife(win);
}