void Menu::desenha() { pair<int, int> sizeScreen = EfeitoVisual::getInstance().getOrtho2D(); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); // Limpa a janela de visualização com a cor de fundo especificada glClear(GL_COLOR_BUFFER_BIT); //Desenha Linha Superior Y drawLine(sizeScreen.second - 40, 'y'); //Desenha Linha Inferior Y drawLine(40, 'y'); if (optMelhores) {//Tela Melhores Pontuações EfeitoVisual::getInstance().desenhaTitulo(600, 65); drawSquad(150, 550, "MELHORES PONTUACOES"); // 5 Valores - Passar 80 por parametro // 7 Valores - Passar 47 por parametro // 10 Valores - Passar 30 por Parametro drawBestScoresMenu(Score::getBestScore(7), 47); } else if (optOpcoes) {//Tela de Opções EfeitoVisual::getInstance().desenhaTitulo(600, 65); drawSquad(150, 550, "OPCOES"); drawOpcoesMenu(); } else if (optSair) { exit(1); } else {//Opções do Menu Inicial EfeitoVisual::getInstance().desenhaTitulo(1100, 0); char *options[4]; options[0] = "NOVO JOGO"; options[1] = "MELHORES PONTUACOES"; options[2] = "OPCOES"; options[3] = "SAIR"; drawOptionsMenu(options, 4, 450); //Desenha Avião TiroSimples *municao1 = new TiroSimples(360, 690, 0.002); TiroSimples *municao2 = new TiroSimples(560, 690, 0.002); Spitfire *spitfire = new Spitfire(460, 530, 0.045, nullptr); glPushMatrix(); //Movendo aviao do menu if (translacaoY < 190 && !limitX) { translacaoY += 4; if (translacaoY >= 190) { limitX = true; } } else if (limitX) { translacaoY -= 4; if (translacaoY <= 0) { limitX = false; } } //comenta daki glTranslatef(translacaoY, 0, 0); glPushMatrix(); glTranslatef(0, translacaoTiro2, 0); municao1->desenha(); municao2->desenha(); glPopMatrix(); spitfire->desenha(); glPopMatrix(); //ate aqui } glutSwapBuffers(); }
// doIntro - display the game intro and wait for menu selections // returns FALSE if user selects exit, TRUE otherwise short int doIntro(short int *gamespeed, short int *gamedifficulty) { short int selector = MENUSTART, done = FALSE, key, options = FALSE, selection = 0; short int speed = *gamespeed, difficulty = *gamedifficulty; // clear the screen ClrScr(); // draw the intro screen drawBorder(); drawLogo(); drawMenu(); drawCopyright(); drawSelector(selector); while (!done) { // wait for keypress while ((key = getKey()) == 0); if (key == KUP) { // move up the menu drawSelector(selector); if (selector == MENUSTART) { selector = MENUEND; } else { selector -= MENUSTEP; } drawSelector(selector); } else if (key == KDOWN) { // move down the menu drawSelector(selector); if (selector == MENUEND) { selector = MENUSTART; } else { selector += MENUSTEP; } drawSelector(selector); } else if (key == KLEFT) { if (options) { // if we are in the options menu selection = (selector - MENUSTART) / MENUSTEP; // set the speed option if (selection == START) { // same as speed option -- option 1 == SPEED drawSpeedOption(speed); if (speed == VERYSLOW) { speed = VERYFAST; } else { speed--; } drawSpeedOption(speed); // set the difficulty option } else if (selection == OPTIONS) { // same as difficulty option -- option 2 == DIFFICULTY drawDifficultyOption(difficulty); if (difficulty == EASY) { difficulty = HARD; } else { difficulty--; } drawDifficultyOption(difficulty); } } } else if (key == KENTER || key == KRIGHT) { // select menu option selection = (selector - MENUSTART) / MENUSTEP; if (options) { // if we're in the options menu // exit the options menu if (selection == QUIT) { // close options menu options = FALSE; // switch the options and main menus drawOptionsMenu(speed,difficulty); drawMenu(); // reset the selector drawSelector(selector); selector = MENUSTART; drawSelector(selector); } else if (selection == START) { // same as speed option -- option 1 == SPEED drawSpeedOption(speed); if (speed == VERYFAST) { speed = VERYSLOW; } else { speed++; } drawSpeedOption(speed); } else if (selection == OPTIONS) { // same as difficulty option -- option 2 == DIFFICULTY drawDifficultyOption(difficulty); if (difficulty == HARD) { difficulty = EASY; } else { difficulty++; } drawDifficultyOption(difficulty); } } else { // if we chose to start or exit, end the loop if (selection == START || selection == QUIT) { done = TRUE; } else { // enter the options menu options = TRUE; // switch the main and options menus drawMenu(); drawOptionsMenu(speed,difficulty); // reset the selector drawSelector(selector); selector = MENUSTART; drawSelector(selector); } } } else if (key == KESC) { // exit the options menu if (options) { // close options menu options = FALSE; // switch the options and main menus drawOptionsMenu(speed,difficulty); drawMenu(); // reset the selector drawSelector(selector); selector = MENUSTART; drawSelector(selector); } else { selection = QUIT; done = TRUE; } } // wait for keypress to dissipate delay(KEYDELAY); } // set the game options *gamespeed = speed; *gamedifficulty = difficulty; return (selection == START) ? TRUE : FALSE; }