Exemplo n.º 1
0
int main() {
	setMode(MODE_4 | BG2_ENABLE);
	startGame();
	while(1) {
		if (KEY_DOWN_NOW(KEY_START) && state == 0) {			
			state = 1;
			numOfLives = 3;
			loadAvatar();
			fillPalette(GPalette_palette, 0, GPALETTE_PALETTE_SIZE);
			PALETTE[200] = BLACK;
			PALETTE[201] = WHITE;
			PALETTE[202] = RED;
			PALETTE[203] = GREEN;
			PALETTE[204] = BLUE;
			
			for (int i = 0; i < 5; i++) {
				homeFlags[i] = 0;
			}
		}
		if (state == 1) {
			drawBG();
			char liveStr[7];
		if (numOfLives >= 0) {
			sprintf(liveStr, "%d", numOfLives);
			drawString4(10, 147, "LIVES LEFT:  ", PALETTE[1]);
			drawString4(80, 147, liveStr, PALETTE[1]);
		}
			drawTrucks();
			drawCars();
			drawCrocodiles();
			drawWoods();
			drawFrog();
			collision();
			reset();
			delay(2);
			waitForVblank();
			flipPage();
		}
		if (state == 2) {
			while (1) {
				if (KEY_DOWN_NOW(KEY_START)) {
					state = 0;
					break;
				}
			}
		}
	}
	return 0;
}
Exemplo n.º 2
0
// Draw the track map according to the display mode
void cGrTrackMap::display(

	tCarElt *currentCar,
	tSituation *situation,
	int Winx,
	int Winy,
	int Winw,
	int Winh
)
{

	if (viewmode == TRACK_MAP_NONE) {
		return;
	}

	// Compute track map position.
	int x = Winx + Winw + map_x - (int) (map_size*track_x_ratio);
	int y = Winy + Winh + map_y - (int) (map_size*track_y_ratio);

	// Setup and display track map.
	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	glEnable(GL_TEXTURE_2D);
	glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
	glBindTexture(GL_TEXTURE_2D, mapTexture);

	// Draw track.
	if (viewmode & (TRACK_MAP_NORMAL | TRACK_MAP_NORMAL_WITH_OPPONENTS)) {
		drawTrackNormal(x, y);
	} else if (viewmode & (TRACK_MAP_PAN | TRACK_MAP_PAN_WITH_OPPONENTS)) {
		drawTrackPanning(Winx, Winy, Winw, Winh, currentCar, situation);
	} else if (viewmode & (TRACK_MAP_PAN_ALIGNED | TRACK_MAP_PAN_ALIGNED_WITH_OPPONENTS)) {
		drawTrackPanningAligned(Winx, Winy, Winw, Winh, currentCar, situation);
	}

	// Draw cars in normal map mode.
	if (viewmode & TRACK_MAP_NORMAL_WITH_OPPONENTS) {
		drawCars(currentCar, situation, x, y);
	}
	if (viewmode & (TRACK_MAP_NORMAL | TRACK_MAP_NORMAL_WITH_OPPONENTS)) {
		drawCar(currentCar, currentCarColor, x, y);
	}

}