Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <conio.h>
- #include <ctype.h>
- #include <conio.h>
- #include <vector>
- #include <ctime>
- #define ARRIBA 72
- #define IZQUIERDA 75
- #define ABAJO 80
- #define DERECHA 77
- #define ALTO 2
- #define ANCHO 5
- int vidas = 3;
- int puntos = 0;
- int tiempo;
- int tiempoenS;
- /**/
- #define ALEATORIO(NUM1, NUM2) rand() % (NUM2 - NUM1 + 1) + NUM1;
- using namespace std;
- using namespace System;
- enum Color { NEGRO, ROJO, AZUL, BLANCO, VERDE, AMARILLO, MORADO };
- void CambiarColorFondo(Color c) {
- switch (c)
- {
- case NEGRO: Console::BackgroundColor = ConsoleColor::Black; break;
- case ROJO: Console::BackgroundColor = ConsoleColor::Red; break;
- case AZUL: Console::BackgroundColor = ConsoleColor::Blue; break;
- case BLANCO: Console::BackgroundColor = ConsoleColor::White; break;
- case VERDE: Console::BackgroundColor = ConsoleColor::Green; break;
- case AMARILLO: Console::BackgroundColor = ConsoleColor::Yellow; break;
- case MORADO: Console::BackgroundColor = ConsoleColor::Magenta; break;
- }
- }
- void CambiarColorLetra(Color c) {
- switch (c) {
- case NEGRO: Console::ForegroundColor = ConsoleColor::Black; break;
- case ROJO: Console::ForegroundColor = ConsoleColor::Red; break;
- case AZUL: Console::ForegroundColor = ConsoleColor::Blue; break;
- case BLANCO: Console::ForegroundColor = ConsoleColor::White; break;
- case VERDE: Console::ForegroundColor = ConsoleColor::Green; break;
- case AMARILLO: Console::ForegroundColor = ConsoleColor::Yellow; break;
- case MORADO: Console::ForegroundColor = ConsoleColor::Magenta; break;
- }
- }
- typedef struct abeja {
- short x;
- short y;
- int pasos;
- short dx;
- short dy;
- short retraso;
- char imagen[3][4];
- abeja(short a = 20, short b = 20, short c = 0) {
- x = a;
- y = b;
- pasos = c;
- dx = 1;
- dy = 1;
- retraso = 0;
- imagen[0][0] = ' ';
- imagen[0][1] = char(92);
- imagen[0][2] = '/';
- imagen[0][3] = ' ';
- imagen[1][0] = '(';
- imagen[1][1] = char(248);
- imagen[1][2] = ')';
- imagen[1][3] = ')';
- imagen[2][0] = ' ';
- imagen[2][1] = char(39);
- imagen[2][2] = char(39);
- imagen[2][3] = ' ';
- }
- ~abeja() {
- borrar();
- }
- void animar() {
- if (retraso == 1000) {
- borrar();
- mover();
- restriccion();
- dibujar();
- retraso = 0;
- }
- retraso++;
- }
- void dibujar() {
- for (int i = 0; i < 3; i++) {
- Console::SetCursorPosition(x, y + i);
- for (int j = 0; j < 4; j++) {
- if (i == 0) {
- CambiarColorLetra(AZUL);
- }
- else if (i == 1 && j == 1) {
- CambiarColorLetra(ROJO);
- }
- else if (i == 1 && j > 1 || i == 1 && j == 0) {
- CambiarColorLetra(AMARILLO);
- }
- else if (i == 2) {
- CambiarColorLetra(ROJO);
- }
- cout << imagen[i][j];
- }
- }
- }
- void borrar() {
- for (int i = 0; i < 3; i++) {
- Console::SetCursorPosition(x, y + i);
- for (int j = 0; j < 4; j++) {
- cout << ' ';
- }
- }
- }
- void mover() {
- if (y == 30 ) dy *= -1;
- if (x == 50 ) dx *= -1;
- if (y == 10 ) dy *= -1;
- if (x == 10 )dx *= -1;
- x += dx;
- y += dy;
- }
- void restriccion() {
- if (x == -1) {
- x = 0;
- }
- else if (y == -1) {
- y = 0;
- }
- }
- };
- typedef struct personaje {
- short x;
- short y;
- int pasos;
- char imagen[ALTO][ANCHO];
- personaje(short a = 50, short b = 35, short c = 0) {
- x = a;
- y = b;
- pasos = c;
- imagen[0][0] = ' ';
- imagen[0][1] = ':';
- imagen[0][2] = '^';
- imagen[0][3] = ':';
- imagen[0][4] = ' ';
- imagen[1][0] = ':';
- imagen[1][1] = '^';
- imagen[1][2] = ':';
- imagen[1][3] = '^';
- imagen[1][4] = ':';
- }
- void animar(char direccion) {
- borrar();
- mover(direccion);
- restriccion();
- dibujar();
- }
- void dibujar() {
- for (int i = 0; i < ALTO; i++) {
- Console::SetCursorPosition(x, y + i);
- for (int j = 0; j < ANCHO; j++) {
- if (j == 1 && i == 0 || j == 3 && i == 0 || j == 0 && i == 1 || j == 2 && i == 1 || j == 4 && i == 1) {
- CambiarColorLetra(ROJO);
- }
- else {
- CambiarColorLetra(BLANCO);
- }
- cout << imagen[i][j];
- }
- }
- }
- void borrar() {
- for (int i = 0; i < ALTO; i++) {
- Console::SetCursorPosition(x, y + i);
- for (int j = 0; j < ANCHO; j++) {
- cout << ' ';
- }
- }
- }
- void mover(char direccion) {
- switch (toupper(direccion)) {
- case IZQUIERDA: x -= 6; pasos++; break;
- case DERECHA: x += 6; pasos++; break;
- }
- }
- void restriccion() {
- if (x < 0) {
- x = 0;
- }
- else if (x>115) {
- x = 115;
- }
- }
- };
- typedef struct comandante {
- int vc = 2;
- short x;
- short y;
- int pasos;
- short dx;
- short dy;
- short retraso;
- int xbala;
- int ybala;
- int dybala;
- short retraso1 = 0;
- int disparar;
- char imagen[3][6];
- comandante(short a = 5, short b = 5, short c = 0) {
- x = a;
- y = b;
- pasos = c;
- dx = 1;
- dy = 1;
- retraso = 0;
- xbala = x;
- ybala = y;
- dybala = 1;
- imagen[0][0] = ' ';
- imagen[0][1] = ' ';
- imagen[0][2] = '*';
- imagen[0][3] = '*';
- imagen[0][4] = ' ';
- imagen[0][5] = ' ';
- imagen[1][0] = ' ';
- imagen[1][1] = ' ';
- imagen[1][2] = '*';
- imagen[1][3] = '*';
- imagen[1][4] = ' ';
- imagen[1][5] = ' ';
- imagen[2][0] = '{';
- imagen[2][1] = '¨';
- imagen[2][2] = ' ';
- imagen[2][3] = ' ';
- imagen[2][4] = '¨';
- imagen[2][5] = '}';
- }
- ~comandante() {
- borrar();
- Console::SetCursorPosition(xbala, ybala);
- cout << " ";
- }
- void animar(personaje* personajeA) {
- if (retraso == 1000) {
- eliminarNave(personajeA);
- borrar();
- mover();
- restriccion();
- if (vc == 1) {
- dibujar2();
- }
- if (vc == 2) {
- dibujar();
- }
- animarBala();
- if (ybala == 45) {
- borrarBala();
- }
- retraso = 0;
- }
- retraso++;
- }
- void dibujar() {
- for (int i = 0; i < 3; i++) {
- Console::SetCursorPosition(x, y + i);
- for (int j = 0; j < 6; j++) {
- if (i < 2) {
- CambiarColorLetra(AZUL);
- }
- else {
- CambiarColorLetra(AMARILLO);
- }
- cout << imagen[i][j];
- }
- }
- }
- void borrar() {
- for (int i = 0; i < 3; i++) {
- Console::SetCursorPosition(x, y + i);
- for (int j = 0; j < 6; j++) {
- cout << ' ';
- }
- }
- }
- void mover() {
- if (x == 20 || x == 90) {
- dx *= -1;
- }
- x += dx;
- }
- void dibujar2() {
- for (int i = 0; i < 3; i++) {
- Console::SetCursorPosition(x, y + i);
- for (int j = 0; j < 6; j++) {
- if (i < 2) {
- CambiarColorLetra(MORADO);
- }
- else {
- CambiarColorLetra(AMARILLO);
- }
- cout << imagen[i][j];
- }
- }
- }
- void restriccion() {
- if (x == -1) {
- x = 0;
- }
- else if (x == 120) {
- x = 119;
- }
- else if (y == -1) {
- y = 0;
- }
- else if (y == 35) {
- y = 34;
- }
- }
- void crearBala() {
- Console::SetCursorPosition(xbala, ybala);
- cout << "*";
- }
- void borrarBala() {
- Console::SetCursorPosition(xbala, ybala);
- cout << " ";
- }
- void animarBala() {
- borrarBala();
- if (ybala == 45) {
- disparar = ALEATORIO(30, 60);
- }
- if (ybala == 45) {
- borrarBala();
- }
- if (ybala < 45) {
- ybala += dybala;
- }
- if (x == disparar) {
- xbala = x + 3;
- ybala = y + 3;
- }
- if (!(xbala == 5)) {
- crearBala();
- }
- }
- void eliminarNave(personaje* &personajeA) {
- 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) {
- vidas--;
- }
- 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) {
- borrarBala();
- }
- }
- };
- typedef struct mariposa {
- short x;
- short y;
- int pasos;
- short dx;
- short dy;
- short retraso;
- char imagen[2][6];
- mariposa(short a = 70, short b = 20, short c = 0) {
- x = a;
- y = b;
- pasos = c;
- dx = 1;
- dy = 1;
- retraso = 0;
- imagen[0][0] = ' ';
- imagen[0][1] = char(92);
- imagen[0][2] = char(92);
- imagen[0][3] = '/';
- imagen[0][4] = '/';
- imagen[0][5] = ' ';
- imagen[1][0] = ' ';
- imagen[1][1] = ' ';
- imagen[1][2] = char(39);
- imagen[1][3] = char(39);
- imagen[1][4] = ' ';
- imagen[1][5] = ' ';
- }
- ~mariposa() {
- borrar();
- }
- void animar() {
- if (retraso == 1000) {
- borrar();
- mover();
- restriccion();
- dibujar();
- retraso = 0;
- }
- retraso++;
- }
- void dibujar() {
- for (int i = 0; i < 2; i++) {
- Console::SetCursorPosition(x, y + i);
- for (int j = 0; j < 6; j++) {
- if (i == 0) {
- CambiarColorLetra(ROJO);
- }
- else {
- CambiarColorLetra(AZUL);
- }
- cout << imagen[i][j];
- }
- }
- }
- void borrar() {
- for (int i = 0; i < 2; i++) {
- Console::SetCursorPosition(x, y + i);
- for (int j = 0; j < 6; j++) {
- cout << ' ';
- }
- }
- }
- void mover() {
- if (y == 30) dy *= -1;
- if (x == 100) dx *= -1;
- if (y == 10) dy *= -1;
- if (x == 60)dx *= -1;
- x += dx;
- y += dy;
- }
- void restriccion() {
- if (x == -1) {
- x = 0;
- }
- else if (y == -1) {
- y = 0;
- }
- }
- };
- typedef struct bala {
- short x;
- short y;
- bala(short a = 2, short b = 3) {
- x = a;
- y = b;
- }
- void animar(vector<comandante*> &comandanteA, vector<abeja*> &abejaA, vector<mariposa*> &mariposaA, int &cantE) {
- Console::SetCursorPosition(x, y);
- cout << " ";
- if (y > 0) {
- y--;
- }
- Console::SetCursorPosition(x, y);
- cout << "*";
- colision(comandanteA, abejaA, mariposaA, cantE);
- }
- ~bala() {
- Console::SetCursorPosition(x, y);
- cout << " ";
- }
- void colision(vector<comandante*> &comandanteA, vector<abeja*> &abejaA, vector<mariposa*> &mariposaA, int &cantE) {
- for (int e = 0; e < comandanteA.size(); e++) {
- 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) {
- comandanteA[e]->vc--;
- if (comandanteA[e]->vc == 0) {
- cantE--;
- delete comandanteA[e];
- comandanteA.erase(comandanteA.begin() + e);
- e--;
- puntos += 400;
- }
- }
- }
- for (int e = 0; e < abejaA.size(); e++) {
- 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) {
- cantE--;
- delete abejaA[e];
- abejaA.erase(abejaA.begin() + e);
- e--;
- puntos += 100;
- }
- }
- for (int e = 0; e < mariposaA.size(); e++) {
- 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) {
- cantE--;
- delete mariposaA[e];
- mariposaA.erase(mariposaA.begin() + e);
- e--;
- puntos += 160;
- }
- }
- }
- };
- void gameOver() {
- //TODO: HACER PANTALLA DE PERDIDA ;
- }
- void score(personaje* &personajeA, bool &continuar) {
- if (vidas == 1 || vidas == 2) {
- personajeA->dibujar();
- }
- if (vidas == 0) {
- gameOver();
- }
- tiempo = clock() + 1;
- tiempoenS = tiempo / 1000;
- Console::SetCursorPosition(1, 1);
- CambiarColorLetra(MORADO);
- cout << "Vidas: ";
- CambiarColorLetra(BLANCO);
- cout << vidas;
- Console::SetCursorPosition(105, 1);
- CambiarColorLetra(MORADO);
- cout << "Puntos: ";
- CambiarColorLetra(BLANCO);
- cout << puntos;
- Console::SetCursorPosition(50, 1);
- CambiarColorLetra(MORADO);
- cout << "Tiempo: ";
- CambiarColorLetra(BLANCO);
- cout << tiempoenS;
- }
- void eliminarBala(vector<bala*> &disparar, vector <mariposa*> mariposaA) {
- for (int e = 0; e < mariposaA.size(); e++) {
- for (int i = 0; i < disparar.size(); i++) {
- 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)
- delete disparar[i];
- disparar.erase(disparar.begin() + i);
- i--;
- }
- }
- }
- void game() {
- int retraso = 0;
- int retrasov = 0;
- int res = 0;
- bool nivel_2 = true;
- int cantE = 12;
- Random random;
- personaje* personajeA = new personaje[1];
- vector<comandante*> comandanteA;
- vector<bala*> disparar;
- vector<abeja*> abejaA;
- vector<mariposa*> mariposaA;
- system("cls");
- bool nivel_1 = true;
- for (int i = 0; i < 4; ++i) {
- comandanteA.push_back(new comandante());
- }
- for (int i = 0; i < 4; ++i) {
- abejaA.push_back(new abeja());
- mariposaA.push_back(new mariposa());
- }
- srand(time(NULL));
- abejaA[0]->x = 35;
- abejaA[0]->y = 20;
- abejaA[1]->x = 40;
- abejaA[1]->y = 22;
- abejaA[2]->x = 45;
- abejaA[3]->y = 24;
- abejaA[3]->x = 50;
- mariposaA[0]->x = 65;
- mariposaA[0]->y = 20;
- mariposaA[1]->x = 70;
- mariposaA[1]->y = 22;
- mariposaA[2]->x = 75;
- mariposaA[2]->y = 24;
- mariposaA[3]->x = 80;
- mariposaA[3]->y = 26;
- comandanteA[0]->x = 30;
- comandanteA[1]->x = 50;
- comandanteA[2]->x = 70;
- comandanteA[3]->x = 90;
- while (nivel_1) {
- if (vidas == 0) {
- nivel_1 = false;
- system("cls");
- CambiarColorLetra(ROJO);
- cout << "**************************************************************************************" << endl;
- cout << "** **" << endl;
- cout << "** **" << endl;
- cout << "** **" << endl;
- cout << "** **" << endl;
- cout << "** XX XX XXXXXXXXXXXXX XX XX **" << endl;
- cout << "** X X XX XX XX XX **" << endl;
- cout << "** X X XX XX XX XX **" << endl;
- cout << "** X X XX XX XX XX **" << endl;
- cout << "** X X XX XX XX XX **" << endl;
- cout << "** XX XX XX XX XX **" << endl;
- cout << "** XX XX XX XX XX **" << endl;
- cout << "** XX XX XX XX XX **" << endl;
- cout << "** XX XX XX XX XX **" << endl;
- cout << "** XX XX XX XX XX **" << endl;
- cout << "** XX XXXXXXXXXXXXX XXXXXXXXXXXXXXX **" << endl;
- cout << "** **" << endl;
- cout << "** **" << endl;
- cout << "** **" << endl;
- cout << "** **" << endl;
- cout << "** XX XXXXXXXXXXXXX XXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXX **" << endl;
- cout << "** XX XX XX XX XXXXXXXXXXXXXX **" << endl;
- cout << "** XX XX XX XX XX **" << endl;
- cout << "** XX XX XX XX XX **" << endl;
- cout << "** XX XX XX XX XX **" << endl;
- cout << "** XX XX XX XXXXXXXXXXXXXX XX **" << endl;
- cout << "** XX XX XX XX XX **" << endl;
- cout << "** XX XX XX XX XX **" << endl;
- cout << "** XXX XX XX XX XX **" << endl;
- cout << "** XXXX XX XX XX XX **" << endl;
- cout << "** XXXXXXXXXXXXX XXXXXXXXXXXXX XXXXXXXXXXXXXX XX **" << endl;
- cout << "** **" << endl;
- cout << "** **" << endl;
- cout << "** **" << endl;
- cout << "**************************************************************************************" << endl;
- for (int i = 0; i < abejaA.size(); i++) {
- delete abejaA[i];
- }
- for (int i = 0; i < mariposaA.size(); i++) {
- delete mariposaA[i];
- }
- for (int i = 0; i < comandanteA.size(); i++) {
- delete comandanteA[i];
- }
- system("pause>0");
- exit(0);
- }
- if (res == 300) {
- score(personajeA, nivel_1);
- res = 0;
- }
- res++;
- if (kbhit()) {
- char direccion = getch();
- personajeA[0].animar(direccion);
- if (direccion == 32) {
- disparar.push_back(new bala(personajeA->x + 2, personajeA->y - 1));
- }
- }
- for (int e = 0; e < abejaA.size(); e++) {
- if (abejaA[e]->y >= 0) {
- abejaA[e]->animar();
- }
- }
- for (int e = 0; e < comandanteA.size(); e++) {
- if (comandanteA[e]->y >= 0) {
- comandanteA[e]->animar(personajeA);
- }
- }
- for (int e = 0; e < mariposaA.size(); e++) {
- if (mariposaA[e]->y >= 0) {
- mariposaA[e]->animar();
- }
- }
- for (int i = 0; i < disparar.size(); i++, retraso++) {
- if (retraso == 300) {
- if (puntos >= 2500) {
- nivel_1 = false;
- }
- disparar[i]->animar(comandanteA, abejaA, mariposaA, cantE);
- retraso = 0;
- }
- retraso++;
- if (disparar[i]->y == 0) {
- delete disparar[i];
- disparar.erase(disparar.begin() + i);
- i--;
- }
- }
- }
- system("cls");
- cout << "********************************************************************************************" << endl;
- cout << "** **" << endl;
- cout << "** **" << endl;
- cout << "** **" << endl;
- cout << "** **" << endl;
- cout << "** **" << endl;
- cout << "** **" << endl;
- cout << "** **" << endl;
- cout << "** || || || || || ||||||||||| || **" << endl;
- cout << "** ||| || || || || || || **" << endl;
- cout << "** || || || || || || || || **" << endl;
- cout << "** || || || || || || || || **" << endl;
- cout << "** || || || || || || ||||||||||| || **" << endl;
- cout << "** || || || || || || || || **" << endl;
- cout << "** || || || || || || || || **" << endl;
- cout << "** || ||| || || || || || **" << endl;
- cout << "** || || || |||| ||||||||||| ||||||||||| **" << endl;
- cout << "** **" << endl;
- cout << "** **" << endl;
- cout << "** **" << endl;
- cout << "** **" << endl;
- cout << "** **" << endl;
- cout << "** * * * * **" << endl;
- cout << "** ** ** **" << endl;
- cout << "** ** ** **" << endl;
- cout << "** ** ** **" << endl;
- cout << "** ** **" << endl;
- cout << "** ** **" << endl;
- cout << "** ** **" << endl;
- cout << "** ** **" << endl;
- cout << "** ** **" << endl;
- cout << "** ** **" << endl;
- cout << "** ** **" << endl;
- cout << "** ** **" << endl;
- cout << "** *** **" << endl;
- cout << "** *** ** **" << endl;
- cout << "** ************* **" << endl;
- cout << "** **" << endl;
- cout << "** **" << endl;
- cout << "** **" << endl;
- cout << "********************************************************************************************" << endl;
- for (int i = 0; i < abejaA.size(); i++) {
- delete abejaA[i];
- }
- for (int i = 0; i < mariposaA.size(); i++) {
- delete mariposaA[i];
- }
- for (int i = 0; i < comandanteA.size(); i++) {
- delete comandanteA[i];
- }
- system("pause>0");
- //NIVEL 2
- system("cls");
- for (int i = 0; i < 4; ++i) {
- comandanteA.push_back(new comandante());
- }
- for (int i = 0; i < 8; ++i) {
- abejaA.push_back(new abeja());
- mariposaA.push_back(new mariposa());
- }
- abejaA[0]->x = 35;
- abejaA[0]->y = 20;
- abejaA[1]->x = 40;
- abejaA[1]->y = 22;
- abejaA[2]->x = 45;
- abejaA[3]->y = 24;
- abejaA[3]->x = 50;
- abejaA[4]->x = 35;
- abejaA[4]->y = 26;
- abejaA[5]->x = 40;
- abejaA[6]->x = 45;
- abejaA[7]->x = 50;
- abejaA[4]->y = 25;
- abejaA[5]->y = 27;
- abejaA[6]->y = 29;
- abejaA[7]->y = 30;
- mariposaA[0]->x = 65;
- mariposaA[0]->y = 20;
- mariposaA[1]->x = 70;
- mariposaA[1]->y = 22;
- mariposaA[2]->x = 75;
- mariposaA[2]->y = 24;
- mariposaA[3]->x = 80;
- mariposaA[3]->y = 26;
- mariposaA[4]->x = 65;
- mariposaA[5]->x = 70;
- mariposaA[6]->x = 75;
- mariposaA[7]->x = 80;
- mariposaA[4]->y = 25;
- mariposaA[5]->y = 27;
- mariposaA[6]->y = 29;
- mariposaA[7]->y = 30;
- comandanteA[0]->x = 30;
- comandanteA[1]->x = 50;
- comandanteA[2]->x = 70;
- comandanteA[3]->x = 90;
- while (nivel_2) {
- if (vidas == 0) {
- nivel_2 = false;
- system("cls");
- CambiarColorLetra(ROJO);
- cout << "**************************************************************************************" << endl;
- cout << "** **" << endl;
- cout << "** **" << endl;
- cout << "** **" << endl;
- cout << "** **" << endl;
- cout << "** XX XX XXXXXXXXXXXXX XX XX **" << endl;
- cout << "** X X XX XX XX XX **" << endl;
- cout << "** X X XX XX XX XX **" << endl;
- cout << "** X X XX XX XX XX **" << endl;
- cout << "** X X XX XX XX XX **" << endl;
- cout << "** XX XX XX XX XX **" << endl;
- cout << "** XX XX XX XX XX **" << endl;
- cout << "** XX XX XX XX XX **" << endl;
- cout << "** XX XX XX XX XX **" << endl;
- cout << "** XX XX XX XX XX **" << endl;
- cout << "** XX XXXXXXXXXXXXX XXXXXXXXXXXXXXX **" << endl;
- cout << "** **" << endl;
- cout << "** **" << endl;
- cout << "** **" << endl;
- cout << "** **" << endl;
- cout << "** XX XXXXXXXXXXXXX XXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXX **" << endl;
- cout << "** XX XX XX XX XXXXXXXXXXXXXX **" << endl;
- cout << "** XX XX XX XX XX **" << endl;
- cout << "** XX XX XX XX XX **" << endl;
- cout << "** XX XX XX XX XX **" << endl;
- cout << "** XX XX XX XXXXXXXXXXXXXX XX **" << endl;
- cout << "** XX XX XX XX XX **" << endl;
- cout << "** XX XX XX XX XX **" << endl;
- cout << "** XXX XX XX XX XX **" << endl;
- cout << "** XXXX XX XX XX XX **" << endl;
- cout << "** XXXXXXXXXXXXX XXXXXXXXXXXXX XXXXXXXXXXXXXX XX **" << endl;
- cout << "** **" << endl;
- cout << "** **" << endl;
- cout << "** **" << endl;
- cout << "**************************************************************************************" << endl;
- for (int i = 0; i < abejaA.size(); i++) {
- delete abejaA[i];
- }
- for (int i = 0; i < mariposaA.size(); i++) {
- delete mariposaA[i];
- }
- for (int i = 0; i < comandanteA.size(); i++) {
- delete comandanteA[i];
- }
- system("pause>0");
- exit(0);
- }
- if (res == 300) {
- score(personajeA, nivel_2);
- res = 0;
- }
- res++;
- if (kbhit()) {
- char direccion = getch();
- personajeA[0].animar(direccion);
- if (direccion == 32) {
- disparar.push_back(new bala(personajeA->x + 2, personajeA->y - 1));
- }
- }
- for (int e = 0; e < abejaA.size(); e++) {
- if (abejaA[e]->y >= 0) {
- abejaA[e]->animar();
- }
- }
- for (int e = 0; e < comandanteA.size(); e++) {
- if (comandanteA[e]->y >= 0) {
- comandanteA[e]->animar(personajeA);
- }
- }
- for (int e = 0; e < mariposaA.size(); e++) {
- if (mariposaA[e]->y >= 0) {
- mariposaA[e]->animar();
- }
- }
- for (int i = 0; i < disparar.size(); i++, retraso++) {
- if (retraso == 300) {
- if (puntos >= 5000) {
- nivel_2 = false;
- }
- disparar[i]->animar(comandanteA, abejaA, mariposaA, cantE);
- retraso = 0;
- }
- retraso++;
- if (disparar[i]->y == 0) {
- delete disparar[i];
- disparar.erase(disparar.begin() + i);
- i--;
- }
- }
- }
- }
- void main() {
- Console::CursorVisible = false;
- Console::SetWindowSize(120, 50);
- game();
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement