Exemple #1
0
void Player::findStormTargets(ObjectManager* manager) {
    // The getObjectsInRange function returns a vector of GameObjects within the
    // specified range that are still in use. Make sure to delete this vector
    // when done with it.
    std::vector<GameObject*>* enemies =
            manager->getObjectsInRange(ObjectManager::ENEMY, x, y, STORM_RANGE);

    // Iterate over the list of current enemies and add them to the list of
    // valid storm targets as applicable. The list of storm targets must be kept
    // in nondecreasing order by player distance to enemy in this process so
    // that the closest enemies are targeted by storm, and not just enemies that
    // happen to be in range.
    for (unsigned int i = 0; i < enemies->size(); i++)
        insertEnemy(dynamic_cast<Enemy*> (enemies->at(i)));

    delete enemies;
}
Exemple #2
0
// RENDERING DEL SISTEMA SOLARE
void solarScene(void){

	

	// ogni volta che disegno incremento il numero dei frame
	g_frames++;
    
	// Do all your OpenGL rendering here
	
 	
	// cancelliamo il  buffer video e lo z buffer
	glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	/* ------------------------------------------------------------------------- */
  	// attiva il viewport principale
  	glViewport( 0, 0, width, height); 
        
    	glMatrixMode(GL_MODELVIEW); 
    	glLoadIdentity();

    	glPushMatrix();

        g_camera.look();    // chiama la gluLookAt con i parametri opportuni
    
        // posizionando la luce dopo la telecamera la luce risulta fissa nel mondo 
        glLightfv(GL_LIGHT0, GL_POSITION, g_light0_pos);
        glLightfv(GL_LIGHT1, GL_POSITION, g_light1_pos);
        glLightfv(GL_LIGHT2, GL_POSITION, g_light2_pos);
	
	glDisable(GL_CULL_FACE);
	
	// texture dello sfondo
	{
		GLUquadric* a = gluNewQuadric();
		glPushAttrib(GL_ALL_ATTRIB_BITS);
		glEnable(GL_TEXTURE_2D);
		Point3 poscam = g_camera.getPos();
		glPushMatrix();
			glTranslatef(poscam.x, poscam.y, poscam.z);
			gluQuadricOrientation(a, GLU_INSIDE);
			glBindTexture(GL_TEXTURE_2D, g_textureSfondo[0]);
			gluQuadricTexture(a, GL_TRUE);						
			gluSphere(a, 900, 24, 24);
		glPopMatrix();
		glDisable(GL_TEXTURE_2D);
		glPopAttrib();
	}
	glEnable(GL_CULL_FACE);
	
	/* PIANETI */
	drawPlanet(posPlanet[0], radius[0], g_texturePlanet[0]);	//	mercury
	drawPlanet(posPlanet[1], radius[1], g_texturePlanet[1]);	//	venus
	drawPlanet(posPlanet[2], radius[2], g_texturePlanet[2]);	//	earth
	drawPlanet(posPlanet[3], radius[3], g_texturePlanet[3]);	//	mars
	drawPlanet(posPlanet[4], radius[4], g_texturePlanet[4]);	//	jupiter
	drawPlanet(posPlanet[5], radius[5], g_texturePlanet[5]);	//	saturn
	drawPlanet(posPlanet[6], radius[6], g_texturePlanet[6]);	//	uranus
	drawPlanet(posPlanet[7], radius[7], g_texturePlanet[7]);	//	neptune
	drawPlanet(posPlanet[8], radius[8], g_texturePlanet[8]);	//	pluto


	/* SATELLITI */
	drawSatellite(&satellite[0], 'y', 0.00012, g_textureSatellite[0]);	// moon
	//drawShield(satellite[0].pos, satellite[0].rad+1);
	drawSatellite(&satellite[1], 'z', 0.00024, g_textureSatellite[1]);	// io
	drawSatellite(&satellite[2], 'y', 0.00012, g_textureSatellite[2]);	// europa
	
	/* ANELLI DI SATURNO */
	drawRing(posPlanet[5], 85, 120);				//	anello saturno

	// HENRY 
	//	gestione dei nemici: posizione, movimenti, inseguimenti
	//	FILE:		enemy_police.c
	insertEnemy();
	insertPolice();
	
	//ALBERTO
	// 	disegno di tutte le collisioni se attivate
	//	FILE		explosion.c
	insertExplosion();
		
	//ALBERTO LASER
	//	disegno di tutti i laser e controllo collisioni
	//	FILE		shooting.c
	hitEnemy=laserHitEnemy();
	hitPolice=laserHitPolice();
	insertRemoveLaser();
	// se siamo stati colpiti dal laser nemico si decrementa la vita
	shooted();
	// inseriamo il super-sparo
	insertSuperShoot();
		
    glPopMatrix();
}