rendered paste body#include <stdio.h>#include <conio.h>#include <stdlib.h>class cMenu{ private: int selectx,selecty; int qtd,score,var,rando; char opt [100][100]; char point; int enemyx, enemyy,enemyn; public: void moverBaixo(); void moverCima (); void startMapa(); void moverDireita(); void moverEsquerda(); cMenu(); void mostrarMatriz(); void executarMatriz(); void iniciaMatriz (); void inimigos(); void gameOver(); void Verify(); void insertInimigos();};void cMenu::Verify(){ int z,v,cont=0; if ((enemyx == selectx) && (enemyy == selecty)) gameOver(); for (z=0;z<qtd;z++) for (v=0;v<qtd;v++) if (opt[z][v]== '.') cont++; if (cont == 0) gameOver();} void cMenu::gameOver(){ system("cls"); mostrarMatriz(); printf ("\n\n\a\a\t\t\tGAME OVER!!\n\n"); system ("pause"); exit (0);}void cMenu::insertInimigos(){ int numofenemies=2, x;// for (x=0;x<3;x++) // inimigos(); inimigos(); }void cMenu::inimigos (){ int rando; // int qtdn=qtd; rando=rand()%17; if (rando >=0 && rando <=4 ) // --- RAND 0->4 { if (opt[enemyx][enemyy+1] != '*') { if (opt[enemyx][enemyy+1] == '|') enemyy=0; opt[enemyx][enemyy]= ' '; enemyy++; } } else { if ( rando >=5 && rando <=9 ) // --- RAND { if (opt[enemyx][enemyy-1] != '*') { if (opt[enemyx][enemyy-1] == '|') enemyy=qtd; opt[enemyx][enemyy]= ' '; enemyy--; } } else { if ( rando >=10 && rando <=13 ) // --- RAND { if (opt[enemyx-1][enemyy] != '*') { opt[enemyx][enemyy]= ' '; enemyx--; } } else { if (opt[enemyx+1][enemyy] != '*') { opt[enemyx][enemyy]= ' '; enemyx++; } } } } }void cMenu::moverDireita(){ if ( opt[selectx][selecty+1] != '*') { if (opt[selectx][selecty+1] == '.') score+=var; opt[selectx][selecty]=' '; selecty++; } if (opt[selectx][selecty+1] == '|') selecty=0; }void cMenu::moverCima(){ if ( opt[selectx-1][selecty] != '*') { if (opt[selectx-1][selecty] == '.') score+=var; opt[selectx][selecty]=' '; selectx--; }}void cMenu::moverBaixo(){ if ( opt[selectx+1][selecty] != '*') { if (opt[selectx+1][selecty] == '.') score+=var; opt[selectx][selecty]=' '; selectx++; }}void cMenu::moverEsquerda(){ if ( opt[selectx][selecty-1] != '*') { if (opt[selectx][selecty-1] =='.') score+=var; opt[selectx][selecty]=' '; selecty--; } if (opt[selectx][selecty-1] == '|') selecty=qtd; }void cMenu::executarMatriz(){ bool fim=true; while (fim) { Verify(); startMapa(); system ("cls"); mostrarMatriz(); switch (getch()) { case 'P'://P -> Mover Para Baixo moverBaixo(); break; case 'M'://M -> Mover Para Direita moverDireita(); break; case 'H'://H -> Mover Para Cima moverCima(); break; case 'K'://K Mover Para Esquerda moverEsquerda(); break; case 27: fim=false; } //inimigos(); insertInimigos(); }}void cMenu::iniciaMatriz(){ int x,y; for (x=0;x<qtd;x++) for (y=0;y<qtd;y++) opt[x][y]= '.'; //176 }void cMenu::startMapa(){int x,y; for (x=0;x<qtd;x++) { opt[0][x]= '*'; opt[x][0]= '*'; opt[qtd-1][x]='*'; opt[x][qtd-1]='*'; if (x==10) { opt[x][0]='|'; opt[x][20]='|'; } } //Tabuleiro PacMan 21x21 opt[2][2]='*'; opt[2][4]='*'; opt[2][5]='*'; opt[2][7]='*'; opt[2][8]='*'; opt[2][9]='*'; opt[2][10]='*'; opt[2][11]='*'; opt[2][12]='*'; opt[2][13]='*'; opt[2][15]='*'; opt[2][16]='*'; opt[2][18]='*'; opt[3][4]='*'; opt[3][5]='*'; opt[3][10]='*'; opt[3][15]='*'; opt[3][16]='*'; opt[4][4]='*'; opt[4][5]='*'; opt[4][6]='*'; opt[4][7]='*'; opt[4][10]='*'; opt[5][10]='*'; opt[6][10]='*'; opt[6][9]='*'; opt[6][11]='*'; opt[7][10]='*'; opt[7][9]='*'; opt[7][11]='*'; opt[7][12]='*'; opt[7][8]='*'; opt[4][15]='*'; opt[4][16]='*'; opt[4][14]='*'; opt[4][13]='*'; opt[5][15]='*'; opt[5][16]='*'; opt[5][4]='*'; opt[5][5]='*'; opt[5][2]='*'; opt[4][2]='*'; opt[4][18]='*'; opt[5][18]='*'; opt[6][18]='*'; opt[6][4]='*'; opt[6][16]='*'; opt[7][5]='*'; opt[7][4]='*'; opt[7][16]='*'; opt[7][15]='*'; opt[6][2]='*'; opt[7][2]='*'; opt[7][18]='*'; opt[13][2]='*'; opt[13][4]='*'; opt[13][5]='*'; opt[13][8]='*'; opt[13][9]='*'; opt[13][10]='*'; opt[13][11]='*'; opt[13][12]='*'; opt[13][15]='*'; opt[13][16]='*'; opt[13][18]='*'; opt[14][4]='*'; opt[14][2]='*'; opt[14][18]='*'; opt[14][9]='*'; opt[14][10]='*'; opt[14][11]='*'; opt[14][16]='*'; opt[15][5]='*'; opt[15][4]='*'; opt[15][10]='*'; opt[15][16]='*'; opt[15][15]='*'; opt[15][2]='*'; opt[15][18]='*'; opt[16][2]='*'; opt[16][4]='*'; opt[16][5]='*'; opt[16][6]='*'; opt[16][7]='*'; opt[16][10]='*'; opt[16][14]='*'; opt[16][13]='*'; opt[16][15]='*'; opt[16][16]='*'; opt[16][18]='*'; opt[17][2]='*'; opt[17][5]='*'; opt[17][4]='*'; opt[17][10]='*'; opt[17][16]='*'; opt[17][9]='*'; opt[17][11]='*'; opt[17][15]='*'; opt[17][18]='*'; opt[18][2]='*'; opt[18][4]='*'; opt[18][5]='*'; opt[18][10]='*'; opt[18][9]='*'; opt[18][8]='*'; opt[18][11]='*'; opt[18][12]='*'; opt[18][7]='*'; opt[18][16]='*'; opt[18][13]='*'; opt[18][15]='*'; opt[18][18]='*'; for (x=1,y=1;x<10;x++,y++) { opt[9][x]='*'; opt[11][y]='*'; } for (x=11,y=11;x<20;x++,y++) { opt[9][x]='*'; opt[11][y]='*';} }void cMenu::mostrarMatriz(){ int x,y; opt[selectx][selecty]=2; opt[enemyx][enemyy]=1; for (x=0;x<qtd;x++) { for (y=0;y<qtd;y++) printf ("%c", opt[x][y]); printf ("\n"); } printf (" \tScore: %i", score);}cMenu::cMenu (){ score=0; qtd=21; point=176; selectx=10; enemyx=12; enemyy=10; selecty=10; var=10;}int main (void){ cMenu a; a.iniciaMatriz (); a.executarMatriz ();}