void Display() {

	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH);
	setupLights();
	setupCamera(); 
	drawBanana(30,cameraY+90,0);


	if (coins >= 5) {
		win = true;
		//sound for winning
	}
		
    if (cinematic)
		rotateCamera();
	glColor3f(1,1,1);
	Draw_Skybox(cameraX, cameraY, cameraZ, 400, 800, 400);
	if (Levels.size() > 0) {
		if (Levels[0].y <cameraY - 100) {
			printf("deleting level");
			Levels.erase(Levels.begin());
			//	for (int j = 0; j<Levels.size() - 1; j++) {
			//		Levels[j] = Levels[j + 1];
			//	}
			//	Levels.pop_back();
			if (Levels.size()>0) {
				Levels[0].levelBefore = NULL;
			}

		}
	}
	char result[10];
	sprintf(result, "%i", coins);
	//std::string name = "Score: ", result;
	displayText(50, cameraY + 110, 0, 1, 1, 1, result);

	if (!lost&!win) {
		createScene();
		character.drawCharacter();
		//std::string name = "Score: ";
	//	char numstr[2];
	///	result = name + numstr;
	}
	else {
		    if (lost)
			displayText(-20, cameraY + 100, 0, 1, 1, 1, "GAME OVER!");
		
			if (win)
				displayText(-20, cameraY + 100, 0, 1, 1, 1, "YOU WON :)");
			
	}
	
	glFlush();
}
void createScene(){
	for (int i = 0; i<Levels.size(); i++) {
		if (jump) {
			if (character.y - Levels[i].y >= 0
				&& character.y - Levels[i].y <= 25
				&& character.x <= Levels[i].xRight
				&& character.x >= Levels[i].xLeft
				) {
				character.level = (Levels[i]);
				character.y = Levels[i].y + 5;
				jumpEndY = character.y;
			}
		
		}
		if (character.y-Levels[i].y>=0 && character.y-Levels[i].y<=25)
		if (character.x>Levels[i].xRight || character.x<Levels[i].xLeft) {
			if (i != 0) {
				character.level = Levels[i-1];
				//character.y = character.level.y + 5;
				character.fall = true;
				

				//sound for falling
			}	
			
		}
	
		glColor3f(1,1,1);
		Levels[i].drawLevel();
		if (Levels[i].drawB){
			drawBanana(Levels[i].direction - 2, Levels[i].y + 1, 35);
		}
		
		if ((int)Levels[i].direction >= (int)character.x - 18 && (int)Levels[i].direction < (int)character.x - 10 && (int)Levels[i].y >= (int)character.y - 14 && (int)Levels[i].y < (int)character.y - 2){
			Levels[i].drawB = false;
			if (!Levels[i].counted){
				++coins;
				Levels[i].counted = true;
				
					PlaySound(NULL, 0, 0);
					PlaySound(TEXT("sounds\\banana.wav"), NULL, SND_FILENAME | SND_ASYNC);
			}
		}
	}
}
Exemple #3
0
int main()
{



	REG_DISPCNT = MODE3 | BG2_ENABLE;

	pl.y = 80;
	pl.oldy = pl.y;
	pl.x = 0;

	h2.x = 2;
	h2.oldx = h2.x;
	h2.y = 0;

	g.x = 219;


	for(int i = 0; i < 7; i++)
	{
    BAN[i].isbanana = 0;
    ENEMY[i].isenemy = 0;
    }

	while(!KEY_DOWN_NOW(BUTTON_START))
	{
		drawImageSpray(0,0,160,240,bg);
	}
	drawRect(0,0,160,240,WHITE);


gameon = 1;
	while(1)
	{
        if(gameon == 1) {
        drawBanana();
        drawEnemy();
        drawHeart();
        drawImageSpray(0,219,20,20,monkeyW);
		drawHollowRect(0,0,20,239,RED);
		drawRect(pl.oldy,0,20,20,WHITE);
		drawImageSpray(pl.y,0,20,20,monkey);



		pl.oldy= pl.y;
		h2.oldx = h2.x;

		if(KEY_DOWN_NOW(BUTTON_UP))
		{
			if(pl.y > 22)
			{
			pl.y = pl.y - 2;
			}
		}

		if(KEY_DOWN_NOW(BUTTON_DOWN))
		{
			if(pl.y <= 138)
			{
			pl.y = pl.y + 2;
			}
		}

		if(h2.x <= 0)
		{
            gameon = 0;
            gameover();

		}

		//if(h2.x >= 219)
		//{
           // gameon = 0;
		//}



	waitForVblank();
	colMonLog();
	colMonBan();
	colMonGoal();
	}
	}
}