Advertisement
Guest User

Untitled

a guest
Nov 17th, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 29.65 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3. #include <ctype.h>
  4. #include <conio.h>
  5. #include <vector>
  6. #include <ctime>
  7. #define ARRIBA    72
  8. #define IZQUIERDA 75
  9. #define ABAJO     80
  10. #define DERECHA   77
  11. #define ALTO 2
  12. #define ANCHO 5
  13. int vidas = 3;
  14. int puntos = 0;
  15. int tiempo;
  16. int tiempoenS;
  17.  
  18. /**/
  19. #define ALEATORIO(NUM1, NUM2) rand() % (NUM2 - NUM1 + 1) + NUM1;
  20. using namespace std;
  21. using namespace System;
  22. enum Color { NEGRO, ROJO, AZUL, BLANCO, VERDE, AMARILLO, MORADO };
  23. void CambiarColorFondo(Color c) {
  24.     switch (c)
  25.     {
  26.     case NEGRO:     Console::BackgroundColor = ConsoleColor::Black; break;
  27.     case ROJO:      Console::BackgroundColor = ConsoleColor::Red; break;
  28.     case AZUL:      Console::BackgroundColor = ConsoleColor::Blue; break;
  29.     case BLANCO:    Console::BackgroundColor = ConsoleColor::White; break;
  30.     case VERDE:     Console::BackgroundColor = ConsoleColor::Green; break;
  31.     case AMARILLO:  Console::BackgroundColor = ConsoleColor::Yellow; break;
  32.     case MORADO:    Console::BackgroundColor = ConsoleColor::Magenta; break;
  33.     }
  34. }
  35. void CambiarColorLetra(Color c) {
  36.     switch (c) {
  37.     case NEGRO:     Console::ForegroundColor = ConsoleColor::Black; break;
  38.     case ROJO:      Console::ForegroundColor = ConsoleColor::Red; break;
  39.     case AZUL:      Console::ForegroundColor = ConsoleColor::Blue; break;
  40.     case BLANCO:    Console::ForegroundColor = ConsoleColor::White; break;
  41.     case VERDE:     Console::ForegroundColor = ConsoleColor::Green; break;
  42.     case AMARILLO:  Console::ForegroundColor = ConsoleColor::Yellow; break;
  43.     case MORADO:    Console::ForegroundColor = ConsoleColor::Magenta; break;
  44.     }
  45. }
  46.  
  47.  
  48. typedef struct abeja {
  49.     short x;
  50.     short y;
  51.     int pasos;
  52.     short dx;
  53.     short dy;
  54.     short retraso;
  55.     char imagen[3][4];
  56.     abeja(short a = 20, short b = 20, short c = 0) {
  57.         x = a;
  58.         y = b;
  59.         pasos = c;
  60.         dx = 1;
  61.         dy = 1;
  62.         retraso = 0;
  63.         imagen[0][0] = ' ';
  64.         imagen[0][1] = char(92);
  65.         imagen[0][2] = '/';
  66.         imagen[0][3] = ' ';
  67.         imagen[1][0] = '(';
  68.         imagen[1][1] = char(248);
  69.         imagen[1][2] = ')';
  70.         imagen[1][3] = ')';
  71.         imagen[2][0] = ' ';
  72.         imagen[2][1] = char(39);
  73.         imagen[2][2] = char(39);
  74.         imagen[2][3] = ' ';
  75.     }
  76.     ~abeja() {
  77.         borrar();
  78.     }
  79.     void animar() {
  80.         if (retraso == 1000) {
  81.             borrar();
  82.             mover();
  83.             restriccion();
  84.             dibujar();
  85.             retraso = 0;
  86.         }
  87.         retraso++;
  88.     }
  89.     void dibujar() {
  90.         for (int i = 0; i < 3; i++) {
  91.             Console::SetCursorPosition(x, y + i);
  92.             for (int j = 0; j < 4; j++) {
  93.                 if (i == 0) {
  94.                     CambiarColorLetra(AZUL);
  95.                 }
  96.                 else if (i == 1 && j == 1) {
  97.                     CambiarColorLetra(ROJO);
  98.                 }
  99.                 else if (i == 1 && j > 1 || i == 1 && j == 0) {
  100.                     CambiarColorLetra(AMARILLO);
  101.                 }
  102.                 else if (i == 2) {
  103.                     CambiarColorLetra(ROJO);
  104.                 }
  105.                 cout << imagen[i][j];
  106.             }
  107.         }
  108.     }
  109.     void borrar() {
  110.         for (int i = 0; i < 3; i++) {
  111.             Console::SetCursorPosition(x, y + i);
  112.             for (int j = 0; j < 4; j++) {
  113.                 cout << ' ';
  114.             }
  115.         }
  116.     }
  117.     void mover() {
  118.         if (y == 30 ) dy *= -1;
  119.         if (x == 50 ) dx *= -1;
  120.         if (y == 10 ) dy *= -1;
  121.         if (x == 10 )dx *= -1;
  122.         x += dx;
  123.         y += dy;
  124.     }
  125.     void restriccion() {
  126.         if (x == -1) {
  127.             x = 0;
  128.         }
  129.         else if (y == -1) {
  130.             y = 0;
  131.         }
  132.     }
  133.  
  134. };
  135.  
  136. typedef struct personaje {
  137.     short x;
  138.     short y;
  139.     int pasos;
  140.     char imagen[ALTO][ANCHO];
  141.     personaje(short a = 50, short b = 35, short c = 0) {
  142.         x = a;
  143.         y = b;
  144.         pasos = c;
  145.         imagen[0][0] = ' ';
  146.         imagen[0][1] = ':';
  147.         imagen[0][2] = '^';
  148.         imagen[0][3] = ':';
  149.         imagen[0][4] = ' ';
  150.         imagen[1][0] = ':';
  151.         imagen[1][1] = '^';
  152.         imagen[1][2] = ':';
  153.         imagen[1][3] = '^';
  154.         imagen[1][4] = ':';
  155.     }
  156.  
  157.     void animar(char direccion) {
  158.         borrar();
  159.         mover(direccion);
  160.         restriccion();
  161.         dibujar();
  162.     }
  163.     void dibujar() {
  164.  
  165.         for (int i = 0; i < ALTO; i++) {
  166.             Console::SetCursorPosition(x, y + i);
  167.             for (int j = 0; j < ANCHO; j++) {
  168.                 if (j == 1 && i == 0 || j == 3 && i == 0 || j == 0 && i == 1 || j == 2 && i == 1 || j == 4 && i == 1) {
  169.                     CambiarColorLetra(ROJO);
  170.                 }
  171.                 else {
  172.                     CambiarColorLetra(BLANCO);
  173.                 }
  174.                 cout << imagen[i][j];
  175.             }
  176.         }
  177.     }
  178.     void borrar() {
  179.         for (int i = 0; i < ALTO; i++) {
  180.             Console::SetCursorPosition(x, y + i);
  181.             for (int j = 0; j < ANCHO; j++) {
  182.                 cout << ' ';
  183.             }
  184.         }
  185.     }
  186.     void mover(char direccion) {
  187.         switch (toupper(direccion)) {
  188.         case IZQUIERDA: x -= 6; pasos++; break;
  189.         case DERECHA: x += 6; pasos++; break;
  190.         }
  191.     }
  192.     void restriccion() {
  193.         if (x < 0) {
  194.             x = 0;
  195.         }
  196.         else if (x>115) {
  197.             x = 115;
  198.         }
  199.     }
  200.  
  201. };
  202. typedef struct comandante {
  203.     int vc = 2;
  204.     short x;
  205.     short y;
  206.     int pasos;
  207.     short dx;
  208.     short dy;
  209.     short retraso;
  210.     int xbala;
  211.     int ybala;
  212.     int dybala;
  213.     short retraso1 = 0;
  214.     int disparar;
  215.     char imagen[3][6];
  216.     comandante(short a = 5, short b = 5, short c = 0) {
  217.         x = a;
  218.         y = b;
  219.         pasos = c;
  220.         dx = 1;
  221.         dy = 1;
  222.         retraso = 0;
  223.         xbala = x;
  224.         ybala = y;
  225.         dybala = 1;
  226.         imagen[0][0] = ' ';
  227.         imagen[0][1] = ' ';
  228.         imagen[0][2] = '*';
  229.         imagen[0][3] = '*';
  230.         imagen[0][4] = ' ';
  231.         imagen[0][5] = ' ';
  232.         imagen[1][0] = ' ';
  233.         imagen[1][1] = ' ';
  234.         imagen[1][2] = '*';
  235.         imagen[1][3] = '*';
  236.         imagen[1][4] = ' ';
  237.         imagen[1][5] = ' ';
  238.         imagen[2][0] = '{';
  239.         imagen[2][1] = '¨';
  240.         imagen[2][2] = ' ';
  241.         imagen[2][3] = ' ';
  242.         imagen[2][4] = '¨';
  243.         imagen[2][5] = '}';
  244.     }
  245.     ~comandante() {
  246.         borrar();
  247.         Console::SetCursorPosition(xbala, ybala);
  248.         cout << " ";
  249.     }
  250.     void animar(personaje* personajeA) {
  251.  
  252.         if (retraso == 1000) {
  253.  
  254.             eliminarNave(personajeA);
  255.             borrar();
  256.             mover();
  257.             restriccion();
  258.             if (vc == 1) {
  259.                 dibujar2();
  260.             }
  261.             if (vc == 2) {
  262.                 dibujar();
  263.             }
  264.             animarBala();
  265.             if (ybala == 45) {
  266.                 borrarBala();
  267.             }
  268.             retraso = 0;
  269.         }
  270.         retraso++;
  271.     }
  272.     void dibujar() {
  273.         for (int i = 0; i < 3; i++) {
  274.             Console::SetCursorPosition(x, y + i);
  275.             for (int j = 0; j < 6; j++) {
  276.                 if (i < 2) {
  277.                     CambiarColorLetra(AZUL);
  278.  
  279.                 }
  280.                 else {
  281.                     CambiarColorLetra(AMARILLO);
  282.                 }
  283.                 cout << imagen[i][j];
  284.             }
  285.         }
  286.     }
  287.     void borrar() {
  288.         for (int i = 0; i < 3; i++) {
  289.             Console::SetCursorPosition(x, y + i);
  290.             for (int j = 0; j < 6; j++) {
  291.                 cout << ' ';
  292.             }
  293.         }
  294.     }
  295.     void mover() {
  296.         if (x == 20 || x == 90) {
  297.             dx *= -1;
  298.         }
  299.         x += dx;
  300.     }
  301.     void dibujar2() {
  302.         for (int i = 0; i < 3; i++) {
  303.             Console::SetCursorPosition(x, y + i);
  304.             for (int j = 0; j < 6; j++) {
  305.                 if (i < 2) {
  306.                     CambiarColorLetra(MORADO);
  307.  
  308.                 }
  309.                 else {
  310.                     CambiarColorLetra(AMARILLO);
  311.                 }
  312.                 cout << imagen[i][j];
  313.             }
  314.         }
  315.     }
  316.     void restriccion() {
  317.         if (x == -1) {
  318.             x = 0;
  319.         }
  320.         else if (x == 120) {
  321.             x = 119;
  322.         }
  323.         else if (y == -1) {
  324.             y = 0;
  325.         }
  326.         else if (y == 35) {
  327.             y = 34;
  328.         }
  329.     }
  330.     void crearBala() {
  331.         Console::SetCursorPosition(xbala, ybala);
  332.         cout << "*";
  333.     }
  334.     void borrarBala() {
  335.         Console::SetCursorPosition(xbala, ybala);
  336.         cout << " ";
  337.     }
  338.     void animarBala() {
  339.        
  340.         borrarBala();
  341.         if (ybala == 45) {
  342.             disparar = ALEATORIO(30, 60);
  343.         }
  344.         if (ybala == 45) {
  345.             borrarBala();
  346.         }
  347.         if (ybala < 45) {
  348.             ybala += dybala;
  349.         }
  350.         if (x == disparar) {
  351.             xbala = x + 3;
  352.             ybala = y + 3;
  353.            
  354.         }
  355.         if (!(xbala == 5)) {
  356.             crearBala();
  357.         }
  358.        
  359.  
  360.  
  361.  
  362.  
  363.     }
  364.     void eliminarNave(personaje* &personajeA) {
  365.         if (xbala == personajeA->x + 1 && ybala == personajeA->y || xbala == personajeA->x + 2 && ybala == personajeA->y || xbala == personajeA->x + 3 && ybala == personajeA->y || xbala == personajeA->x + 4 && ybala == personajeA->y || xbala == personajeA->x + 5 && ybala == personajeA->y) {
  366.             vidas--;
  367.  
  368.         }
  369.         if (xbala < personajeA->x + 1 && ybala < personajeA->y || xbala < personajeA->x + 2 && ybala < personajeA->y || xbala < personajeA->x + 3 && ybala < personajeA->y || xbala < personajeA->x + 4 && ybala < personajeA->y || xbala < personajeA->x + 5 && ybala < personajeA->y) {
  370.  
  371.             borrarBala();
  372.         }
  373.     }
  374. };
  375. typedef struct mariposa {
  376.     short x;
  377.     short y;
  378.     int pasos;
  379.     short dx;
  380.     short dy;
  381.     short retraso;
  382.     char imagen[2][6];
  383.     mariposa(short a = 70, short b = 20, short c = 0) {
  384.         x = a;
  385.         y = b;
  386.         pasos = c;
  387.         dx = 1;
  388.         dy = 1;
  389.         retraso = 0;
  390.         imagen[0][0] = ' ';
  391.         imagen[0][1] = char(92);
  392.         imagen[0][2] = char(92);
  393.         imagen[0][3] = '/';
  394.         imagen[0][4] = '/';
  395.         imagen[0][5] = ' ';
  396.         imagen[1][0] = ' ';
  397.         imagen[1][1] = ' ';
  398.         imagen[1][2] = char(39);
  399.         imagen[1][3] = char(39);
  400.         imagen[1][4] = ' ';
  401.         imagen[1][5] = ' ';
  402.     }
  403.     ~mariposa() {
  404.         borrar();
  405.     }
  406.     void animar() {
  407.         if (retraso == 1000) {
  408.             borrar();
  409.             mover();
  410.             restriccion();
  411.             dibujar();
  412.             retraso = 0;
  413.         }
  414.         retraso++;
  415.     }
  416.     void dibujar() {
  417.         for (int i = 0; i < 2; i++) {
  418.             Console::SetCursorPosition(x, y + i);
  419.             for (int j = 0; j < 6; j++) {
  420.                 if (i == 0) {
  421.                     CambiarColorLetra(ROJO);
  422.                 }
  423.                 else {
  424.                     CambiarColorLetra(AZUL);
  425.                 }
  426.                 cout << imagen[i][j];
  427.             }
  428.         }
  429.     }
  430.  
  431.     void borrar() {
  432.         for (int i = 0; i < 2; i++) {
  433.             Console::SetCursorPosition(x, y + i);
  434.             for (int j = 0; j < 6; j++) {
  435.                 cout << ' ';
  436.             }
  437.         }
  438.     }
  439.     void mover() {
  440.         if (y == 30) dy *= -1;
  441.         if (x == 100) dx *= -1;
  442.         if (y == 10) dy *= -1;
  443.         if (x == 60)dx *= -1;
  444.         x += dx;
  445.         y += dy;
  446.     }
  447.     void restriccion() {
  448.         if (x == -1) {
  449.             x = 0;
  450.         }
  451.         else if (y == -1) {
  452.             y = 0;
  453.         }
  454.     }
  455. };
  456. typedef struct bala {
  457.     short x;
  458.     short y;
  459.     bala(short a = 2, short b = 3) {
  460.         x = a;
  461.         y = b;
  462.     }
  463.     void animar(vector<comandante*> &comandanteA, vector<abeja*> &abejaA, vector<mariposa*> &mariposaA, int &cantE) {
  464.         Console::SetCursorPosition(x, y);
  465.         cout << " ";
  466.         if (y > 0) {
  467.             y--;
  468.         }
  469.         Console::SetCursorPosition(x, y);
  470.         cout << "*";
  471.         colision(comandanteA, abejaA, mariposaA, cantE);
  472.     }
  473.  
  474.     ~bala() {
  475.         Console::SetCursorPosition(x, y);
  476.         cout << " ";
  477.     }
  478.     void colision(vector<comandante*> &comandanteA, vector<abeja*> &abejaA, vector<mariposa*> &mariposaA, int &cantE) {
  479.         for (int e = 0; e < comandanteA.size(); e++) {
  480.             if (x == comandanteA[e]->x + 1 && y == comandanteA[e]->y || x == comandanteA[e]->x + 2 && y == comandanteA[e]->y || x == comandanteA[e]->x + 3 && y == comandanteA[e]->y || x == comandanteA[e]->x + 4 && y == comandanteA[e]->y || x == comandanteA[e]->x + 5 && y == comandanteA[e]->y) {
  481.                 comandanteA[e]->vc--;
  482.                 if (comandanteA[e]->vc == 0) {
  483.                     cantE--;
  484.                     delete comandanteA[e];
  485.                     comandanteA.erase(comandanteA.begin() + e);
  486.                     e--;
  487.                     puntos += 400;
  488.                 }
  489.             }
  490.         }
  491.         for (int e = 0; e < abejaA.size(); e++) {
  492.             if (x == abejaA[e]->x + 1 && y == abejaA[e]->y || x == abejaA[e]->x + 2 && y == abejaA[e]->y || x == abejaA[e]->x + 3 && y == abejaA[e]->y || x == abejaA[e]->x + 4 && y == abejaA[e]->y || x == abejaA[e]->x + 5 && y == abejaA[e]->y) {
  493.                 cantE--;
  494.                 delete abejaA[e];
  495.                 abejaA.erase(abejaA.begin() + e);
  496.                 e--;
  497.                 puntos += 100;
  498.             }
  499.         }
  500.         for (int e = 0; e < mariposaA.size(); e++) {
  501.             if (x == mariposaA[e]->x + 1 && y == mariposaA[e]->y || x == mariposaA[e]->x + 2 && y == mariposaA[e]->y || x == mariposaA[e]->x + 3 && y == mariposaA[e]->y || x == mariposaA[e]->x + 4 && y == mariposaA[e]->y || x == mariposaA[e]->x + 5 && y == mariposaA[e]->y) {
  502.                 cantE--;
  503.                 delete mariposaA[e];
  504.                 mariposaA.erase(mariposaA.begin() + e);
  505.                 e--;
  506.                 puntos += 160;
  507.             }
  508.         }
  509.    
  510.     }
  511. };
  512. void gameOver() {
  513.     //TODO: HACER PANTALLA DE PERDIDA ;
  514. }
  515. void score(personaje* &personajeA, bool &continuar) {
  516.     if (vidas == 1 || vidas == 2) {
  517.         personajeA->dibujar();
  518.     }
  519.     if (vidas == 0) {
  520.         gameOver();
  521.     }
  522.     tiempo = clock() + 1;
  523.     tiempoenS = tiempo / 1000;
  524.     Console::SetCursorPosition(1, 1);
  525.     CambiarColorLetra(MORADO);
  526.     cout << "Vidas: ";
  527.     CambiarColorLetra(BLANCO);
  528.     cout << vidas;
  529.     Console::SetCursorPosition(105, 1);
  530.     CambiarColorLetra(MORADO);
  531.     cout << "Puntos: ";
  532.     CambiarColorLetra(BLANCO);
  533.     cout << puntos;
  534.     Console::SetCursorPosition(50, 1);
  535.     CambiarColorLetra(MORADO);
  536.     cout << "Tiempo: ";
  537.     CambiarColorLetra(BLANCO);
  538.     cout << tiempoenS;
  539. }
  540. void eliminarBala(vector<bala*> &disparar, vector <mariposa*> mariposaA) {
  541.    
  542.     for (int e = 0; e < mariposaA.size(); e++) {
  543.         for (int i = 0; i < disparar.size(); i++) {
  544.             if (disparar[i]->x == mariposaA[e]->x + 1 && disparar[i]->y == mariposaA[e]->y || disparar[i]->x == mariposaA[e]->x + 2 && disparar[i]->y == mariposaA[e]->y || disparar[i]->x == mariposaA[e]->x + 3 && disparar[i]->y == mariposaA[e]->y || disparar[i]->x == mariposaA[e]->x + 4 && disparar[i]->y == mariposaA[e]->y || disparar[i]->x == mariposaA[e]->x + 5 && disparar[i]->y == mariposaA[e]->y)
  545.                 delete disparar[i];
  546.             disparar.erase(disparar.begin() + i);
  547.             i--;
  548.         }
  549.        
  550.     }
  551. }
  552.  
  553. void game() {
  554.     int retraso = 0;
  555.     int retrasov = 0;
  556.     int res = 0;
  557.     bool nivel_2 = true;
  558.    
  559.     int cantE = 12;
  560.  
  561.    
  562.     Random random;
  563.     personaje* personajeA = new personaje[1];
  564.     vector<comandante*> comandanteA;
  565.     vector<bala*> disparar;
  566.     vector<abeja*> abejaA;
  567.     vector<mariposa*> mariposaA;
  568.     system("cls");
  569.     bool nivel_1 = true;
  570.     for (int i = 0; i < 4; ++i) {
  571.  
  572.         comandanteA.push_back(new comandante());
  573.        
  574.     }
  575.     for (int i = 0; i < 4; ++i) {
  576.         abejaA.push_back(new abeja());
  577.         mariposaA.push_back(new mariposa());
  578.     }
  579.     srand(time(NULL));
  580.     abejaA[0]->x = 35;
  581.     abejaA[0]->y = 20;
  582.     abejaA[1]->x = 40;
  583.     abejaA[1]->y = 22;
  584.     abejaA[2]->x = 45;
  585.     abejaA[3]->y = 24;
  586.     abejaA[3]->x = 50;
  587.  
  588.    
  589.     mariposaA[0]->x = 65;
  590.     mariposaA[0]->y = 20;
  591.     mariposaA[1]->x = 70;
  592.     mariposaA[1]->y = 22;
  593.     mariposaA[2]->x = 75;
  594.     mariposaA[2]->y = 24;
  595.     mariposaA[3]->x = 80;
  596.     mariposaA[3]->y = 26;
  597.  
  598.     comandanteA[0]->x = 30;
  599.     comandanteA[1]->x = 50;
  600.     comandanteA[2]->x = 70;
  601.     comandanteA[3]->x = 90;
  602.  
  603.  
  604.  
  605.     while (nivel_1) {
  606.         if (vidas == 0) {
  607.             nivel_1 = false;
  608.             system("cls");
  609.             CambiarColorLetra(ROJO);
  610.             cout << "**************************************************************************************" << endl;
  611.             cout << "**                                                                                  **" << endl;
  612.             cout << "**                                                                                  **" << endl;
  613.             cout << "**                                                                                  **" << endl;
  614.             cout << "**                                                                                  **" << endl;
  615.             cout << "**                XX         XX    XXXXXXXXXXXXX    XX           XX                 **" << endl;
  616.             cout << "**                 X        X      XX         XX    XX           XX                 **" << endl;
  617.             cout << "**                  X      X       XX         XX    XX           XX                 **" << endl;
  618.             cout << "**                   X    X        XX         XX    XX           XX                 **" << endl;
  619.             cout << "**                    X  X         XX         XX    XX           XX                 **" << endl;
  620.             cout << "**                     XX          XX         XX    XX           XX                 **" << endl;
  621.             cout << "**                     XX          XX         XX    XX           XX                 **" << endl;
  622.             cout << "**                     XX          XX         XX    XX           XX                 **" << endl;
  623.             cout << "**                     XX          XX         XX    XX           XX                 **" << endl;
  624.             cout << "**                     XX          XX         XX    XX           XX                 **" << endl;
  625.             cout << "**                     XX          XXXXXXXXXXXXX    XXXXXXXXXXXXXXX                 **" << endl;
  626.             cout << "**                                                                                  **" << endl;
  627.             cout << "**                                                                                  **" << endl;
  628.             cout << "**                                                                                  **" << endl;
  629.             cout << "**                                                                                  **" << endl;
  630.             cout << "**     XX                XXXXXXXXXXXXX     XXXXXXXXXXXXXX     XXXXXXXXXXXXXXXXXX    **" << endl;
  631.             cout << "**     XX                XX         XX     XX                   XXXXXXXXXXXXXX      **" << endl;
  632.             cout << "**     XX                XX         XX     XX                         XX            **" << endl;
  633.             cout << "**     XX                XX         XX     XX                         XX            **" << endl;
  634.             cout << "**     XX                XX         XX     XX                         XX            **" << endl;
  635.             cout << "**     XX                XX         XX     XXXXXXXXXXXXXX             XX            **" << endl;
  636.             cout << "**     XX                XX         XX                 XX             XX            **" << endl;
  637.             cout << "**     XX                XX         XX                 XX             XX            **" << endl;
  638.             cout << "**     XXX               XX         XX                 XX             XX            **" << endl;
  639.             cout << "**     XXXX              XX         XX                 XX             XX            **" << endl;
  640.             cout << "**     XXXXXXXXXXXXX     XXXXXXXXXXXXX     XXXXXXXXXXXXXX             XX            **" << endl;
  641.             cout << "**                                                                                  **" << endl;
  642.             cout << "**                                                                                  **" << endl;
  643.             cout << "**                                                                                  **" << endl;
  644.             cout << "**************************************************************************************" << endl;
  645.             for (int i = 0; i < abejaA.size(); i++) {
  646.                 delete abejaA[i];
  647.             }
  648.             for (int i = 0; i < mariposaA.size(); i++) {
  649.                 delete mariposaA[i];
  650.             }
  651.             for (int i = 0; i < comandanteA.size(); i++) {
  652.                 delete comandanteA[i];
  653.             }
  654.             system("pause>0");
  655.             exit(0);
  656.         }
  657.         if (res == 300) {
  658.             score(personajeA, nivel_1);
  659.             res = 0;
  660.         }
  661.         res++;
  662.         if (kbhit()) {
  663.             char direccion = getch();
  664.             personajeA[0].animar(direccion);
  665.             if (direccion == 32) {
  666.                 disparar.push_back(new bala(personajeA->x + 2, personajeA->y - 1));
  667.             }
  668.  
  669.         }
  670.         for (int e = 0; e < abejaA.size(); e++) {
  671.             if (abejaA[e]->y >= 0) {
  672.                 abejaA[e]->animar();
  673.             }
  674.  
  675.         }
  676.         for (int e = 0; e < comandanteA.size(); e++) {
  677.             if (comandanteA[e]->y >= 0) {
  678.                 comandanteA[e]->animar(personajeA);
  679.             }
  680.         }
  681.         for (int e = 0; e < mariposaA.size(); e++) {
  682.             if (mariposaA[e]->y >= 0) {
  683.                 mariposaA[e]->animar();
  684.             }
  685.         }
  686.         for (int i = 0; i < disparar.size(); i++, retraso++) {
  687.             if (retraso == 300) {
  688.                 if (puntos >= 2500) {
  689.                     nivel_1 = false;
  690.  
  691.  
  692.                 }
  693.                 disparar[i]->animar(comandanteA, abejaA, mariposaA, cantE);
  694.                 retraso = 0;
  695.             }
  696.  
  697.             retraso++;
  698.             if (disparar[i]->y == 0) {
  699.                 delete disparar[i];
  700.                 disparar.erase(disparar.begin() + i);
  701.                 i--;
  702.             }
  703.         }
  704.     }
  705.     system("cls");
  706.     cout << "********************************************************************************************" << endl;
  707.     cout << "**                                                                                        **" << endl;
  708.     cout << "**                                                                                        **" << endl;
  709.     cout << "**                                                                                        **" << endl;
  710.     cout << "**                                                                                        **" << endl;
  711.     cout << "**                                                                                        **" << endl;
  712.     cout << "**                                                                                        **" << endl;
  713.     cout << "**                                                                                        **" << endl;
  714.     cout << "**       ||           ||    ||    ||                ||    |||||||||||   ||                **" << endl;
  715.     cout << "**       |||          ||    ||     ||              ||     ||            ||                **" << endl;
  716.     cout << "**       || ||        ||    ||      ||            ||      ||            ||                **" << endl;
  717.     cout << "**       ||   ||      ||    ||       ||          ||       ||            ||                **" << endl;
  718.     cout << "**       ||     ||    ||    ||        ||        ||        |||||||||||   ||                **" << endl;
  719.     cout << "**       ||       ||  ||    ||         ||      ||         ||            ||                **" << endl;
  720.     cout << "**       ||        || ||    ||          ||    ||          ||            ||                **" << endl;
  721.     cout << "**       ||          |||    ||           ||  ||           ||            ||                **" << endl;
  722.     cout << "**       ||           ||    ||            ||||            |||||||||||   |||||||||||       **" << endl;
  723.     cout << "**                                                                                        **" << endl;
  724.     cout << "**                                                                                        **" << endl;
  725.     cout << "**                                                                                        **" << endl;
  726.     cout << "**                                                                                        **" << endl;
  727.     cout << "**                                                                                        **" << endl;
  728.     cout << "**                                         * * * *                                        **" << endl;
  729.     cout << "**                                       **      **                                       **" << endl;
  730.     cout << "**                                     **          **                                     **" << endl;
  731.     cout << "**                                     **          **                                     **" << endl;
  732.     cout << "**                                                 **                                     **" << endl;
  733.     cout << "**                                                 **                                     **" << endl;
  734.     cout << "**                                                 **                                     **" << endl;
  735.     cout << "**                                                **                                      **" << endl;
  736.     cout << "**                                               **                                       **" << endl;
  737.     cout << "**                                              **                                        **" << endl;
  738.     cout << "**                                            **                                          **" << endl;
  739.     cout << "**                                          **                                            **" << endl;
  740.     cout << "**                                        ***                                             **" << endl;
  741.     cout << "**                                      ***        **                                     **" << endl;
  742.     cout << "**                                      *************                                     **" << endl;
  743.     cout << "**                                                                                        **" << endl;
  744.     cout << "**                                                                                        **" << endl;
  745.     cout << "**                                                                                        **" << endl;
  746.     cout << "********************************************************************************************" << endl;
  747.     for (int i = 0; i < abejaA.size(); i++) {
  748.         delete abejaA[i];
  749.     }
  750.     for (int i = 0; i < mariposaA.size(); i++) {
  751.         delete mariposaA[i];
  752.     }
  753.     for (int i = 0; i < comandanteA.size(); i++) {
  754.         delete comandanteA[i];
  755.     }
  756.     system("pause>0");
  757.     //NIVEL 2
  758.  
  759.     system("cls");
  760.     for (int i = 0; i < 4; ++i) {
  761.  
  762.         comandanteA.push_back(new comandante());
  763.  
  764.     }
  765.     for (int i = 0; i < 8; ++i) {
  766.         abejaA.push_back(new abeja());
  767.         mariposaA.push_back(new mariposa());
  768.     }
  769.     abejaA[0]->x = 35;
  770.     abejaA[0]->y = 20;
  771.     abejaA[1]->x = 40;
  772.     abejaA[1]->y = 22;
  773.     abejaA[2]->x = 45;
  774.     abejaA[3]->y = 24;
  775.     abejaA[3]->x = 50;
  776.     abejaA[4]->x = 35;
  777.     abejaA[4]->y = 26;
  778.     abejaA[5]->x = 40;
  779.     abejaA[6]->x = 45;
  780.     abejaA[7]->x = 50;
  781.     abejaA[4]->y = 25;
  782.     abejaA[5]->y = 27;
  783.     abejaA[6]->y = 29;
  784.     abejaA[7]->y = 30;
  785.  
  786.  
  787.     mariposaA[0]->x = 65;
  788.     mariposaA[0]->y = 20;
  789.     mariposaA[1]->x = 70;
  790.     mariposaA[1]->y = 22;
  791.     mariposaA[2]->x = 75;
  792.     mariposaA[2]->y = 24;
  793.     mariposaA[3]->x = 80;
  794.     mariposaA[3]->y = 26;
  795.     mariposaA[4]->x = 65;
  796.     mariposaA[5]->x = 70;
  797.     mariposaA[6]->x = 75;
  798.     mariposaA[7]->x = 80;
  799.     mariposaA[4]->y = 25;
  800.     mariposaA[5]->y = 27;
  801.     mariposaA[6]->y = 29;
  802.     mariposaA[7]->y = 30;
  803.  
  804.     comandanteA[0]->x = 30;
  805.     comandanteA[1]->x = 50;
  806.     comandanteA[2]->x = 70;
  807.     comandanteA[3]->x = 90;
  808.     while (nivel_2) {
  809.         if (vidas == 0) {
  810.             nivel_2 = false;
  811.             system("cls");
  812.             CambiarColorLetra(ROJO);
  813.             cout << "**************************************************************************************" << endl;
  814.             cout << "**                                                                                  **" << endl;
  815.             cout << "**                                                                                  **" << endl;
  816.             cout << "**                                                                                  **" << endl;
  817.             cout << "**                                                                                  **" << endl;
  818.             cout << "**                XX         XX    XXXXXXXXXXXXX    XX           XX                 **" << endl;
  819.             cout << "**                 X        X      XX         XX    XX           XX                 **" << endl;
  820.             cout << "**                  X      X       XX         XX    XX           XX                 **" << endl;
  821.             cout << "**                   X    X        XX         XX    XX           XX                 **" << endl;
  822.             cout << "**                    X  X         XX         XX    XX           XX                 **" << endl;
  823.             cout << "**                     XX          XX         XX    XX           XX                 **" << endl;
  824.             cout << "**                     XX          XX         XX    XX           XX                 **" << endl;
  825.             cout << "**                     XX          XX         XX    XX           XX                 **" << endl;
  826.             cout << "**                     XX          XX         XX    XX           XX                 **" << endl;
  827.             cout << "**                     XX          XX         XX    XX           XX                 **" << endl;
  828.             cout << "**                     XX          XXXXXXXXXXXXX    XXXXXXXXXXXXXXX                 **" << endl;
  829.             cout << "**                                                                                  **" << endl;
  830.             cout << "**                                                                                  **" << endl;
  831.             cout << "**                                                                                  **" << endl;
  832.             cout << "**                                                                                  **" << endl;
  833.             cout << "**     XX                XXXXXXXXXXXXX     XXXXXXXXXXXXXX     XXXXXXXXXXXXXXXXXX    **" << endl;
  834.             cout << "**     XX                XX         XX     XX                   XXXXXXXXXXXXXX      **" << endl;
  835.             cout << "**     XX                XX         XX     XX                         XX            **" << endl;
  836.             cout << "**     XX                XX         XX     XX                         XX            **" << endl;
  837.             cout << "**     XX                XX         XX     XX                         XX            **" << endl;
  838.             cout << "**     XX                XX         XX     XXXXXXXXXXXXXX             XX            **" << endl;
  839.             cout << "**     XX                XX         XX                 XX             XX            **" << endl;
  840.             cout << "**     XX                XX         XX                 XX             XX            **" << endl;
  841.             cout << "**     XXX               XX         XX                 XX             XX            **" << endl;
  842.             cout << "**     XXXX              XX         XX                 XX             XX            **" << endl;
  843.             cout << "**     XXXXXXXXXXXXX     XXXXXXXXXXXXX     XXXXXXXXXXXXXX             XX            **" << endl;
  844.             cout << "**                                                                                  **" << endl;
  845.             cout << "**                                                                                  **" << endl;
  846.             cout << "**                                                                                  **" << endl;
  847.             cout << "**************************************************************************************" << endl;
  848.             for (int i = 0; i < abejaA.size(); i++) {
  849.                 delete abejaA[i];
  850.             }
  851.             for (int i = 0; i < mariposaA.size(); i++) {
  852.                 delete mariposaA[i];
  853.             }
  854.             for (int i = 0; i < comandanteA.size(); i++) {
  855.                 delete comandanteA[i];
  856.             }
  857.             system("pause>0");
  858.             exit(0);
  859.         }
  860.         if (res == 300) {
  861.             score(personajeA, nivel_2);
  862.             res = 0;
  863.         }
  864.         res++;
  865.         if (kbhit()) {
  866.             char direccion = getch();
  867.             personajeA[0].animar(direccion);
  868.             if (direccion == 32) {
  869.                 disparar.push_back(new bala(personajeA->x + 2, personajeA->y - 1));
  870.             }
  871.  
  872.         }
  873.         for (int e = 0; e < abejaA.size(); e++) {
  874.             if (abejaA[e]->y >= 0) {
  875.                 abejaA[e]->animar();
  876.             }
  877.  
  878.         }
  879.         for (int e = 0; e < comandanteA.size(); e++) {
  880.             if (comandanteA[e]->y >= 0) {
  881.                 comandanteA[e]->animar(personajeA);
  882.             }
  883.         }
  884.         for (int e = 0; e < mariposaA.size(); e++) {
  885.             if (mariposaA[e]->y >= 0) {
  886.                 mariposaA[e]->animar();
  887.             }
  888.         }
  889.         for (int i = 0; i < disparar.size(); i++, retraso++) {
  890.             if (retraso == 300) {
  891.                 if (puntos >= 5000) {
  892.                     nivel_2 = false;
  893.  
  894.  
  895.                 }
  896.                 disparar[i]->animar(comandanteA, abejaA, mariposaA, cantE);
  897.                 retraso = 0;
  898.             }
  899.  
  900.             retraso++;
  901.             if (disparar[i]->y == 0) {
  902.                 delete disparar[i];
  903.                 disparar.erase(disparar.begin() + i);
  904.                 i--;
  905.             }
  906.         }
  907.  
  908.  
  909.     }
  910.        
  911.    
  912.    
  913.    
  914. }
  915. void main() {
  916.  
  917.     Console::CursorVisible = false;
  918.     Console::SetWindowSize(120, 50);
  919.     game();
  920.     return;
  921.  
  922. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement