void Init()
{
	glClearColor(1.0,1.0,1.0,1.0);
	glEnable(GL_ALPHA);
	glEnable(GL_DEPTH_TEST);
	glEnable(GL_TEXTURE_2D);
	glEnable(GL_LIGHT0);
	glEnable(GL_LIGHT1);
	glEnable(GL_LIGHT2);
	glEnable(GL_LIGHTING);

	GLfloat lDiff[] = { 1.0f,1.0f,1.0f,1.0f };
	GLfloat lSpec[] = { 0.0f,0.0f,1.0f,1.0f };
	GLfloat lpos[] = { 0.0,2.5,0.0,1 };

	GLfloat lDiff1[] = { 1.0f,1.0f,1.0f,1.0f };
	GLfloat lSpec1[] = { 1.0f,0.0f,0.0f,1.0f };
	GLfloat lpos1[] = {0.0f,-2.5,1.0,1 };

	GLfloat lDiff2[] = { 1.0f,1.0f,1.0f,1.0f };
	GLfloat lSpec2[] = { 1.0f,0.0f,1.0f,1.0f };
	GLfloat lpos2[] = { 1.5f,0.0,1.0,1 };

	glLightfv(GL_LIGHT0, GL_DIFFUSE, lDiff);
	glLightfv(GL_LIGHT0, GL_SPECULAR, lSpec);
	glLightfv(GL_LIGHT0, GL_POSITION, lpos);

	glLightfv(GL_LIGHT1, GL_DIFFUSE, lDiff1);
	glLightfv(GL_LIGHT1, GL_SPECULAR, lSpec1);
	glLightfv(GL_LIGHT1, GL_POSITION, lpos1);

	glLightfv(GL_LIGHT2, GL_DIFFUSE, lDiff2);
	glLightfv(GL_LIGHT2, GL_SPECULAR, lSpec2);
	glLightfv(GL_LIGHT2, GL_POSITION, lpos2);
	

	tex1 = SOIL_load_OGL_texture(
		"tex1.png",
		SOIL_LOAD_AUTO,
		SOIL_CREATE_NEW_ID,
		SOIL_FLAG_POWER_OF_TWO
	);

	tex2 = SOIL_load_OGL_texture(
		"tex2.png",
		SOIL_LOAD_AUTO,
		SOIL_CREATE_NEW_ID,
		SOIL_FLAG_POWER_OF_TWO
	);


	tex3 = SOIL_load_OGL_texture(
		"tex3.png",
		SOIL_LOAD_AUTO,
		SOIL_CREATE_NEW_ID,
		SOIL_FLAG_POWER_OF_TWO | SOIL_FLAG_INVERT_Y 
	);

	tex4 = SOIL_load_OGL_texture(
		"pantalla2.png",
		SOIL_LOAD_AUTO,
		SOIL_CREATE_NEW_ID,
		SOIL_FLAG_POWER_OF_TWO
		);

	tex5 = SOIL_load_OGL_texture(
		"pantalla1.png",
		SOIL_LOAD_AUTO,
		SOIL_CREATE_NEW_ID,
		SOIL_FLAG_POWER_OF_TWO
		);

	tex6 = SOIL_load_OGL_texture(
		"pantalla3.png",
		SOIL_LOAD_AUTO,
		SOIL_CREATE_NEW_ID,
		SOIL_FLAG_POWER_OF_TWO
		);

	player.model = glmReadOBJ("ship.obj");
	asteroideModel = glmReadOBJ("Asteroid.obj");
	enemigoModel = glmReadOBJ("rtm_metroid_v2.obj");

	time_begin = glutGet(GLUT_ELAPSED_TIME);

	srand(time(NULL));

	powerups.push_back(Powerup(limites.right +3, random(limites.bottom,limites.top), 0, 70, time_begin + randomTime(tiempo_nivel - 5000)));
	powerups.push_back(Powerup(limites.right +3, random(limites.bottom, limites.top), 50, 0, time_begin + randomTime(tiempo_nivel - 5000)));

	asteroides.push_back(Asteroide(limites.right +3, random(limites.bottom, limites.top), time_begin + randomTime(tiempo_nivel - 5000),asteroideModel,0.3));
	asteroides.push_back(Asteroide(limites.right +3, random(limites.bottom, limites.top), time_begin + randomTime(tiempo_nivel - 5000), asteroideModel,0.4));
	asteroides.push_back(Asteroide(limites.right +3, random(limites.bottom, limites.top), time_begin + randomTime(tiempo_nivel - 5000), asteroideModel, 0.3));
	asteroides.push_back(Asteroide(limites.right +3, random(limites.bottom, limites.top), time_begin + randomTime(tiempo_nivel - 5000), asteroideModel, 0.5));
	asteroides.push_back(Asteroide(limites.right +3, random(limites.bottom, limites.top), time_begin + randomTime(tiempo_nivel - 5000), asteroideModel, 0.3));
	asteroides.push_back(Asteroide(limites.right +3, random(limites.bottom, limites.top), time_begin + randomTime(tiempo_nivel - 5000), asteroideModel, 0.4));

	enemigos.push_back(Enemigo(limites.right +3, random(limites.bottom, limites.top), time_begin + randomTime(tiempo_nivel-5000), enemigoModel));
	enemigos.push_back(Enemigo(limites.right +3, random(limites.bottom, limites.top), time_begin + randomTime(tiempo_nivel - 5000), enemigoModel));
	enemigos.push_back(Enemigo(limites.right +3, random(limites.bottom, limites.top), time_begin + randomTime(tiempo_nivel - 5000), enemigoModel));
	enemigos.push_back(Enemigo(limites.right +3, random(limites.bottom, limites.top), time_begin + randomTime(tiempo_nivel - 5000), enemigoModel));

	ammo_length = limites.right * 2;
	hp_length = limites.right * 2;

	time_fin = time_begin + tiempo_nivel;

	player.x = limites.left/2;
	player.y = 0;
	player.z = 1;

	glutReportErrors();
}
void NuevoNivel() {
	int prev_nivel = tiempo_nivel;
	tiempo_nivel += 20000;


	for (int n = 0;n < enemigos.size();n++) {
		enemigos[n].activo = true;
		enemigos[n].x = limites.right+1;
		enemigos[n].hp = 5;
		enemigos[n].material[0] = 1.0f;
		enemigos[n].material[1] = 1.0f;
		enemigos[n].material[2] = 1.0f;
		enemigos[n].material[3] = 1.0f;
		enemigos[n].disparos.clear();
		enemigos[n].ultimo_disparo = 0;
		enemigos[n].tiempo_disparo -= 20;
	}
	for (int n = 0;n < asteroides.size();n++) {
		asteroides[n].activo = true;
		asteroides[n].x = limites.right + 0.5;
		asteroides[n].hp = 5;
		asteroides[n].material[0] = 1.0f;
		asteroides[n].material[1] = 1.0f;
		asteroides[n].material[2] = 1.0f;
		asteroides[n].material[3] = 1.0f;
	}
	for (int n = 0;n < powerups.size();n++) {
		powerups[n].activo = true;
		powerups[n].x = limites.right + 0.5;
	}

	tex1 = SOIL_load_OGL_texture(
		"tex1.png",
		SOIL_LOAD_AUTO,
		SOIL_CREATE_NEW_ID,
		SOIL_FLAG_POWER_OF_TWO
	);

	tex2 = SOIL_load_OGL_texture(
		"tex2.png",
		SOIL_LOAD_AUTO,
		SOIL_CREATE_NEW_ID,
		SOIL_FLAG_POWER_OF_TWO
	);


	tex3 = SOIL_load_OGL_texture(
		"tex3.png",
		SOIL_LOAD_AUTO,
		SOIL_CREATE_NEW_ID,
		SOIL_FLAG_POWER_OF_TWO | SOIL_FLAG_INVERT_Y
	);

	tex4 = SOIL_load_OGL_texture(
		"pantalla2.png",
		SOIL_LOAD_AUTO,
		SOIL_CREATE_NEW_ID,
		SOIL_FLAG_POWER_OF_TWO
	);

	tex5 = SOIL_load_OGL_texture(
		"pantalla1.png",
		SOIL_LOAD_AUTO,
		SOIL_CREATE_NEW_ID,
		SOIL_FLAG_POWER_OF_TWO
	);

	tex6 = SOIL_load_OGL_texture(
		"pantalla3.png",
		SOIL_LOAD_AUTO,
		SOIL_CREATE_NEW_ID,
		SOIL_FLAG_POWER_OF_TWO
	);

	srand(time(NULL));

	powerups.push_back(Powerup(limites.right +3, random(limites.bottom, limites.top), 0, 70, prev_nivel + randomTime(15000)));
	powerups.push_back(Powerup(limites.right +3, random(limites.bottom, limites.top), 50, 0, prev_nivel + randomTime(15000)));

	asteroides.push_back(Asteroide(limites.right +3, random(limites.bottom, limites.top), prev_nivel + randomTime(15000), asteroideModel, 0.3));
	asteroides.push_back(Asteroide(limites.right +3, random(limites.bottom, limites.top), prev_nivel + randomTime(15000), asteroideModel, 0.4));
	asteroides.push_back(Asteroide(limites.right +3, random(limites.bottom, limites.top), prev_nivel + randomTime(15000), asteroideModel, 0.2));
	asteroides.push_back(Asteroide(limites.right +3, random(limites.bottom, limites.top), prev_nivel + randomTime(15000), asteroideModel, 0.2));
	asteroides.push_back(Asteroide(limites.right +3, random(limites.bottom, limites.top), prev_nivel + randomTime(15000), asteroideModel, 0.3));
	asteroides.push_back(Asteroide(limites.right +3, random(limites.bottom, limites.top), prev_nivel + randomTime(15000), asteroideModel, 0.5));
	asteroides.push_back(Asteroide(limites.right +3, random(limites.bottom, limites.top), prev_nivel + randomTime(15000), asteroideModel, 0.3));
	asteroides.push_back(Asteroide(limites.right +3, random(limites.bottom, limites.top), prev_nivel + randomTime(15000), asteroideModel, 0.4));

	enemigos.push_back(Enemigo(limites.right +3, random(limites.bottom, limites.top), prev_nivel + randomTime(15000), enemigoModel));
	enemigos.push_back(Enemigo(limites.right +3, random(limites.bottom, limites.top), prev_nivel + randomTime(15000), enemigoModel));
	enemigos.push_back(Enemigo(limites.right +3, random(limites.bottom, limites.top), prev_nivel + randomTime(15000), enemigoModel));
	enemigos.push_back(Enemigo(limites.right +3, random(limites.bottom, limites.top), prev_nivel + randomTime(15000), enemigoModel));
	
	player.hp = 100;
	player.municiones = 100;

	ammo_length = limites.right * 2;
	hp_length = limites.right * 2;

	time_begin = glutGet(GLUT_ELAPSED_TIME);
	time_fin = time_begin + tiempo_nivel;

	player.x = limites.left / 2;
	player.y = 0;
	player.z = 1;
	

}
Exemple #3
0
//pjemanager para enemigos
void PjeManager::addEnemigo(const std::string& nick) {
	map_Enemigo[nick] = Enemigo();
}