void Display() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); prev_time = tiempo; tiempo = glutGet(GLUT_ELAPSED_TIME); if (pantInit) { pantallas(tex6); } else if (tiempo >= time_fin && noPerdido) { pantallas(tex4); glDisable(GL_LIGHTING); glDisable(GL_TEXTURE_2D); glColor3f(1.00, 0, 0); glRasterPos3f(limites.left + 0.25f, limites.top - 0.375f, 4); std::string scoreString = "Score: " + std::to_string(score); char *scoreString2 = new char[scoreString.length() + 1]; strcpy(scoreString2, scoreString.c_str()); for (int i = 0; scoreString2[i] != '\0'; i++) { glutBitmapCharacter(GLUT_BITMAP_HELVETICA_10, scoreString2[i]); } delete[] scoreString2; if (press_enter) { NuevoNivel(); } } else if (noPerdido){ if (tiempo >= time_fin / 2) { vel_asteroide = 0.001; } else if (tiempo >= time_fin * 7 / 10 && time_fin < 50000) { vel_asteroide = 0.003; } else if (tiempo >= time_fin * 7 / 10 && time_fin >= 50000) { vel_asteroide = 0.005; } glEnable(GL_TEXTURE_2D); Parallax(); glLoadIdentity(); glBindTexture(GL_TEXTURE_2D, 0); glBegin(GL_QUADS); glColor3f(0, 0, 1.0); glVertex3f(0, limites.top - 0.05f, 2); glVertex3f(0, limites.top - (limites.top / 10.0f), 2); glVertex3f(0 + ammo_length, limites.top - (limites.top / 10.0f), 2); glVertex3f(0 + ammo_length, limites.top - 0.05f, 2); glEnd(); glLoadIdentity(); glBindTexture(GL_TEXTURE_2D, 0); glBegin(GL_QUADS); glColor3f(1.00, 0, 0); glVertex3f(0, limites.bottom - 0.05f, 2); glVertex3f(0, limites.bottom - (limites.bottom / 10.0f), 2); glVertex3f(0 + hp_length, limites.bottom - (limites.bottom / 10.0f), 2); glVertex3f(0 + hp_length, limites.bottom - 0.05f, 2); glEnd(); glRasterPos3f(limites.left + 0.25f, limites.top - 0.375f, 3); std::string scoreString = "Score: " + std::to_string(score); char *scoreString2 = new char[scoreString.length()+1]; strcpy(scoreString2, scoreString.c_str()); for (int i = 0; scoreString2[i] != '\0'; i++) { glutBitmapCharacter(GLUT_BITMAP_HELVETICA_10, scoreString2[i]); } delete[] scoreString2; glEnable(GL_LIGHTING); for (int i = 0;i < powerups.size();i++) { if (powerups[i].activo) { if (tiempo - time_begin > powerups[i].appear) { powerups[i].mover(0.0006); powerups[i].mostrar(); player.calcularColision(powerups[i]); } } } glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); for (int i = 0;i < asteroides.size();i++) { if (asteroides[i].activo) { if (tiempo - time_begin > asteroides[i].appear) { asteroides[i].mover(vel_asteroide); asteroides[i].mostrar(); player.calcularColision(asteroides[i]); for (int n = 0;n < player.disparos.size();n++) { if (player.disparos[n].activo) { player.disparos[n].calcularColision(asteroides[i]); } } } } } for (int i = 0; i < enemigos.size(); i++) { if (enemigos[i].activo) { if (tiempo - time_begin > enemigos[i].appear) { enemigos[i].mover(vel_asteroide); enemigos[i].mostrar(); enemigos[i].disparar(tiempo - time_begin); player.calcularColision(enemigos[i]); for (int n = 0; n < player.disparos.size(); n++) { if (player.disparos[n].activo) { player.disparos[n].calcularColision(enemigos[i]); } } for (int n = 0; n < enemigos[i].disparos.size(); n++) { if (enemigos[i].disparos[n].activo) { player.calcularColision(enemigos[i].disparos[n]); } } } } } GLfloat lDiff2[] = { 1.0f,1.0f,1.0f,1.0f }; glLightfv(GL_LIGHT0, GL_DIFFUSE, lDiff2); glLightfv(GL_LIGHT1, GL_DIFFUSE, lDiff2); glLightfv(GL_LIGHT2, GL_DIFFUSE, lDiff2); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); GLfloat mat[] = { 1.0f,1.0f,1.0f,1.0f }; glMaterialfv(GL_FRONT, GL_SPECULAR, mat); glMaterialfv(GL_FRONT, GL_DIFFUSE, mat); player.rotx = 0; player.roty = 0; if (press_a) { player.rotx = -15; player.mover(-movx, 0); } if (press_d) { player.roty += 15; player.mover(movx, 0); } if (press_w) { player.roty = -25; player.mover(0, movy); } if (press_s) { player.roty += 25; player.mover(0, -movy); } if (press_space) { if (tiempo > shoot_time + shoot_wait) { //Puede disparar de nuevo shoot_time = tiempo; player.disparar(); } } //glDisable(GL_TEXTURE_2D); //glBindTexture(GL_TEXTURE_2D, 0); player.mostrar(); } else { glColor3f(1.00, 0, 0); glDisable(GL_LIGHTING); glDisable(GL_TEXTURE_2D); glRasterPos3f(limites.left + 0.25f, limites.top - 0.375f, 3); std::string scoreString = "Score: " + std::to_string(score); char *scoreString2 = new char[scoreString.length() + 1]; strcpy(scoreString2, scoreString.c_str()); for (int i = 0; scoreString2[i] != '\0'; i++) { glutBitmapCharacter(GLUT_BITMAP_HELVETICA_10, scoreString2[i]); } delete[] scoreString2; pantallas(tex5); if (press_enter) { Reiniciar(); noPerdido = true; } } glutSwapBuffers(); glutPostRedisplay(); }
IteradorTablaHash<C,V>::IteradorTablaHash(Array<Puntero<NodoLista<C,V>> buckets){ this->buckets = buckets; Reiniciar(); }