Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <ctype.h>
- #include <conio.h>
- #include <time.h>
- #include <vector>
- using namespace std;
- using namespace System;
- #define IZQUIERDA 75
- #define DERECHA 77
- #define DISPARAR 32
- #define ALTO 2
- #define ANCHO 8
- #define ESC 27
- #define BORDEDERECHA 50
- #define BORDEIZQUIERDA 15
- #define ALEATORIO (INI, FIN) rand() % (FIN - INI + 1) + INI
- struct enemigo {
- short x;
- short y;
- short dx;
- char enemigos[2][4]{
- { '-','-','-','-' },
- { ' ','|','|',' ' } };
- enemigo(int _x = 19, int _y = rand() % 10 + 5) {
- x = _x;
- y = _y;
- dx = 1;
- }
- void animar() {
- borrar();
- mover();
- dibujar();
- }
- void borrar() {
- for (short f = 0; f < 2; ++f) {
- Console::SetCursorPosition(x, y + f);
- for (short c = 0; c < 4; ++c) {
- cout << " ";
- }
- }
- }
- void mover() {
- if (x == BORDEIZQUIERDA + 4 || x == BORDEDERECHA + 4) dx *= -1;
- x += dx;
- }
- void dibujar() {
- Console::ForegroundColor = ConsoleColor::Yellow;
- Console::SetCursorPosition(x, y);
- for (short f = 0; f < 2; ++f) {
- Console::SetCursorPosition(x, y + f);
- for (short c = 0; c < 4; ++c) {
- cout << enemigos[f][c];
- }
- }
- }
- };
- struct enemigos2 {
- short x;
- short y;
- short dx;
- short dy;
- char enemigos[2][3]{
- { '-','-','-' },
- { ' ','"',' ' } };
- enemigos2(int _x = 19, int _y = rand() % 8 + 5) {
- x = _x;
- y = _y;
- dx = 1;
- dy = 1;
- }
- void animar() {
- borrar();
- mover();
- dibujar();
- }
- void borrar() {
- for (short f = 0; f < 2; ++f) {
- Console::SetCursorPosition(x, y + f);
- for (short c = 0; c < 3; ++c) {
- cout << " ";
- }
- }
- }
- void mover() {
- if (x == BORDEIZQUIERDA + 3 || x == BORDEDERECHA + 6) dx *= -1;
- x += dx;
- }
- void dibujar() {
- Console::ForegroundColor = ConsoleColor::Red;
- Console::SetCursorPosition(x, y);
- for (short f = 0; f < 2; ++f) {
- Console::SetCursorPosition(x, y + f);
- for (short c = 0; c < 3; ++c) {
- cout << enemigos[f][c];
- }
- }
- }
- };
- struct enemigos3 {
- short x;
- int vida = 2;
- short y;
- short dx;
- short dy;
- char enemigos[3][4]{
- { '/','(',')','/' },
- { ' ','(',')',' ' },
- { ' ','"','"',' ' } };
- enemigos3(int _x = rand() % 11 + 11, int _y = 2) {
- x = _x;
- y = _y;
- dx = 1;
- dy = 1;
- }
- void animar() {
- borrar();
- mover();
- dibujar();
- }
- void borrar() {
- for (short f = 0; f < 3; ++f) {
- Console::SetCursorPosition(x, y + f);
- for (short c = 0; c < 4; ++c) {
- cout << " ";
- }
- }
- }
- void mover() {
- if (x == BORDEIZQUIERDA || x == BORDEDERECHA + 4) dx *= -1;
- x += dx;
- }
- void dibujar() {
- Console::ForegroundColor = ConsoleColor::Blue;
- Console::SetCursorPosition(x, y);
- for (short f = 0; f < 3; ++f) {
- Console::SetCursorPosition(x, y + f);
- for (short c = 0; c < 4; ++c) {
- cout << enemigos[f][c];
- if (vida == 1)
- {
- Console::ForegroundColor = ConsoleColor::DarkMagenta;
- dibujar();
- }
- }
- }
- }
- };
- struct bala {
- short x, y;
- bala(int _x = 10, int _y = 10) {
- x = _x;
- y = _y;
- }
- void animar() {
- borrar();
- mover();
- dibujar();
- }
- void mover() {
- y--;
- }
- void dibujar() {
- Console::SetCursorPosition(x, y);
- cout << char(34);
- }
- void borrar() {
- Console::SetCursorPosition(x, y);
- cout << " ";
- }
- };
- struct personaje {
- int vidas = 4;
- short x;
- short y;
- char nave[ALTO][ANCHO]{
- { ' ',' ',' ','|','|',' ',' ',' ' },
- { '!','-','[','>','<',']' ,'-','!', } };
- personaje(short _x = 0, short _y = 0) {
- x = _x;
- y = _y;
- vidas = 3;
- }
- void animar(char direccion) {
- borrar();
- mover(direccion);
- dibujar();
- }
- void mover(char direccion) {
- if (direccion == IZQUIERDA && x>0)x--;
- if (direccion == DERECHA && x<BORDEDERECHA)x++;
- }
- void dibujar() {
- Console::ForegroundColor = ConsoleColor::White;
- for (short f = 0; f < ALTO; ++f) {
- Console::SetCursorPosition(x, y + f);
- for (short c = 0; c < ANCHO; ++c) {
- cout << nave[f][c];
- }
- }
- }
- void borrar() {
- for (short f = 0; f < ALTO; ++f) {
- Console::SetCursorPosition(x, y + f);
- for (short c = 0; c < ANCHO; ++c) {
- cout << " ";
- }
- }
- }
- };
- bool colision(short xe, short ye, short &xb, short &yb) {
- for (int i = 0; i < 2; i++) {
- for (int j = 0; j < 4; j++) {
- if (xe + i == xb && ye + j == yb) return true;
- else return false;
- }
- }
- }
- void jugar() {
- int contE = 5;
- int puntaje = 0;
- personaje nave = personaje(36, 37);
- vector<enemigo*>pEnemigosM;
- vector<enemigos2*>pEnemigosA;
- vector<enemigos3*>pEnemigosC;
- bool continuar = true;
- vector<bala*> balas;
- for (short i = 0; i < 2; i++) {
- int x = rand() % 31 + 18;
- int y = rand() % 16 + 7;
- pEnemigosA.push_back(new enemigos2(x, y));
- }
- for (short i = 0; i < 2; i++) {
- int x = rand() % 31 + 18;
- int y = rand() % 16 + 5;
- pEnemigosM.push_back(new enemigo(x, y));
- }
- for (short i = 0; i < 1; i++) {
- int x = rand() % 30 + 18;
- int y = rand() % 1 + 2;
- pEnemigosC.push_back(new enemigos3(x, y));
- }
- while (continuar) {
- if (kbhit()) {
- char direccion = getch();
- nave.animar(direccion);
- if (direccion == DISPARAR)
- {
- balas.push_back(new bala(nave.x + 4, nave.y - 1));
- }
- }
- for (short i = 0; i < pEnemigosM.size(); i++) {
- pEnemigosM[i]->animar();
- }
- for (short i = 0; i < pEnemigosA.size(); i++) {
- pEnemigosA[i]->animar();
- }
- for (short i = 0; i < pEnemigosC.size(); i++) {
- pEnemigosC[i]->animar();
- }
- for (int i = 0; i < balas.size(); i++) {
- if (balas[i]->y != 2) {
- balas[i]->animar();
- for (int j = 0; j < pEnemigosM.size(); j++) {
- if (colision(pEnemigosM[j]->x, pEnemigosM[j]->y + 1, balas[i]->x, balas[i]->y) ||
- colision(pEnemigosM[j]->x + 1, pEnemigosM[j]->y + 1, balas[i]->x, balas[i]->y) ||
- colision(pEnemigosM[j]->x + 2, pEnemigosM[j]->y + 1, balas[i]->x, balas[i]->y) ||
- colision(pEnemigosM[j]->x + 3, pEnemigosM[j]->y + 1, balas[i]->x, balas[i]->y)) {
- puntaje += 100;
- Console::SetCursorPosition(90, 1);
- Console::ForegroundColor = ConsoleColor::White;
- cout << "PUNTAJE = " << puntaje;
- pEnemigosM[j]->borrar();
- delete pEnemigosM[j];
- pEnemigosM.erase(pEnemigosM.begin() + j);
- j--;
- contE--;
- if (contE == 0)
- {
- continuar = false;
- }
- }
- }
- for (int k = 0; k < pEnemigosA.size(); k++) {
- if (colision(pEnemigosA[k]->x, pEnemigosA[k]->y + 1, balas[i]->x, balas[i]->y) ||
- colision(pEnemigosA[k]->x + 1, pEnemigosA[k]->y + 1, balas[i]->x, balas[i]->y) ||
- colision(pEnemigosA[k]->x + 2, pEnemigosA[k]->y + 1, balas[i]->x, balas[i]->y) ||
- colision(pEnemigosA[k]->x + 3, pEnemigosA[k]->y + 1, balas[i]->x, balas[i]->y)) {
- puntaje += 100;
- Console::SetCursorPosition(90, 1);
- Console::ForegroundColor = ConsoleColor::White;
- cout << "PUNTAJE = " << puntaje;
- pEnemigosA[k]->borrar();
- delete pEnemigosA[k];
- pEnemigosA.erase(pEnemigosA.begin() + k);
- k--;
- contE--;
- if (contE == 0)
- {
- continuar = false;
- }
- }
- }
- for (int l = 0; l < pEnemigosC.size(); l++) {
- if (colision(pEnemigosC[l]->x, pEnemigosC[l]->y + 1, balas[i]->x, balas[l]->y) ||
- colision(pEnemigosC[l]->x + 1, pEnemigosC[l]->y + 1, balas[i]->x, balas[i]->y) ||
- colision(pEnemigosC[l]->x + 2, pEnemigosC[l]->y + 1, balas[i]->x, balas[i]->y) ||
- colision(pEnemigosC[l]->x + 3, pEnemigosC[l]->y + 1, balas[i]->x, balas[i]->y)) {
- puntaje += 100;
- Console::SetCursorPosition(90, 1);
- Console::ForegroundColor = ConsoleColor::White;
- cout << "PUNTAJE = " << puntaje;
- pEnemigosC[l]->borrar();
- delete pEnemigosC[l];
- pEnemigosC.erase(pEnemigosC.begin() + l);
- l--;
- contE--;
- if (contE == 0)
- {
- continuar = false;
- }
- }
- }
- }
- else {
- balas[i]->borrar();
- delete balas[i];
- balas.erase(balas.begin() + i);
- i--;
- break;
- }
- }
- _sleep(45);
- }
- system("cls");
- Console::SetCursorPosition(45, 37);
- cout << "NIVEL 2" << endl;
- system("pause");
- system("cls");
- int contE2 = 5;
- int puntaje2 = 0;
- personaje nave2 = personaje(35, 37);
- vector<enemigo*>pEnemigosM2;
- vector<enemigos2*>pEnemigosA2;
- vector<enemigos3*>pEnemigosC2;
- bool continuar2 = true;
- vector<bala*> balas2;
- for (short i = 0; i < 2; i++) {
- int x = rand() % 31 + 20;
- int y = rand() % 16 + 7;
- pEnemigosA2.push_back(new enemigos2(x, y));
- }
- for (short i = 0; i < 2; i++) {
- int x = rand() % 31 + 20;
- int y = rand() % 16 + 5;
- pEnemigosM2.push_back(new enemigo(x, y));
- }
- for (short i = 0; i < 1; i++) {
- int x = rand() % 30 + 20;
- int y = rand() % 1 + 2;
- pEnemigosC2.push_back(new enemigos3(x, y));
- }
- while (continuar2) {
- if (kbhit()) {
- char direccion2 = getch();
- nave2.animar(direccion2);
- if (direccion2 == DISPARAR)
- {
- balas2.push_back(new bala(nave2.x + 4, nave2.y - 1));
- }
- }
- for (short i = 0; i < pEnemigosM2.size(); i++) {
- pEnemigosM2[i]->animar();
- }
- for (short i = 0; i < pEnemigosA2.size(); i++) {
- pEnemigosA2[i]->animar();
- }
- for (short i = 0; i < pEnemigosC2.size(); i++) {
- pEnemigosC2[i]->animar();
- }
- for (int i = 0; i < balas2.size(); i++) {
- if (balas2[i]->y != 2) {
- balas2[i]->animar();
- for (int j = 0; j < pEnemigosM2.size(); j++) {
- if (colision(pEnemigosM2[j]->x, pEnemigosM2[j]->y + 1, balas2[i]->x, balas2[i]->y) ||
- colision(pEnemigosM2[j]->x + 1, pEnemigosM2[j]->y + 1, balas2[i]->x, balas2[i]->y) ||
- colision(pEnemigosM2[j]->x + 2, pEnemigosM2[j]->y + 1, balas2[i]->x, balas2[i]->y) ||
- colision(pEnemigosM2[j]->x + 3, pEnemigosM2[j]->y + 1, balas2[i]->x, balas2[i]->y)) {
- puntaje += 100;
- Console::SetCursorPosition(90, 1);
- Console::ForegroundColor = ConsoleColor::White;
- cout << "PUNTAJE = " << puntaje;
- pEnemigosM2[j]->borrar();
- delete pEnemigosM2[j];
- pEnemigosM2.erase(pEnemigosM2.begin() + j);
- j--;
- contE2--;
- if (contE2 == 0)
- {
- continuar2 = false;
- }
- }
- }
- for (int k = 0; k < pEnemigosA2.size(); k++) {
- if (colision(pEnemigosA2[k]->x, pEnemigosA2[k]->y + 1, balas2[i]->x, balas2[i]->y) ||
- colision(pEnemigosA2[k]->x + 1, pEnemigosA2[k]->y + 1, balas2[i]->x, balas2[i]->y) ||
- colision(pEnemigosA2[k]->x + 2, pEnemigosA2[k]->y + 1, balas2[i]->x, balas2[i]->y) ||
- colision(pEnemigosA2[k]->x + 3, pEnemigosA2[k]->y + 1, balas2[i]->x, balas2[i]->y)) {
- puntaje += 100;
- Console::SetCursorPosition(90, 1);
- Console::ForegroundColor = ConsoleColor::White;
- cout << "PUNTAJE = " << puntaje;
- pEnemigosA2[k]->borrar();
- delete pEnemigosA2[k];
- pEnemigosA2.erase(pEnemigosA2.begin() + k);
- k--;
- contE2--;
- if (contE2 == 0)
- {
- continuar2 = false;
- }
- }
- }
- for (int l = 0; l < pEnemigosC2.size(); l++) {
- if (colision(pEnemigosC2[l]->x, pEnemigosC2[l]->y + 1, balas2[i]->x, balas2[l]->y) ||
- colision(pEnemigosC2[l]->x + 1, pEnemigosC2[l]->y + 1, balas2[i]->x, balas2[i]->y) ||
- colision(pEnemigosC2[l]->x + 2, pEnemigosC2[l]->y + 1, balas2[i]->x, balas2[i]->y) ||
- colision(pEnemigosC2[l]->x + 3, pEnemigosC2[l]->y + 1, balas2[i]->x, balas2[i]->y)) {
- puntaje += 100;
- Console::SetCursorPosition(90, 1);
- Console::ForegroundColor = ConsoleColor::White;
- cout << "PUNTAJE = " << puntaje;
- pEnemigosC2[l]->borrar();
- delete pEnemigosC2[l];
- pEnemigosC2.erase(pEnemigosC2.begin() + l);
- l--;
- contE2--;
- if (contE2 == 0)
- {
- continuar2 = false;
- }
- }
- }
- }
- else {
- balas2[i]->borrar();
- delete balas2[i];
- balas2.erase(balas2.begin() + i);
- i--;
- break;
- }
- }
- _sleep(45);
- }
- system("cls");
- Console::SetCursorPosition(45, 37);
- cout << "NIVEL 3" << endl;
- system("pause");
- system("cls");
- int contE3 = 5;
- int puntaje3 = 0;
- personaje nave3 = personaje(35, 37);
- vector<enemigo*>pEnemigosM3;
- vector<enemigos2*>pEnemigosA3;
- vector<enemigos3*>pEnemigosC3;
- bool continuar3 = true;
- vector<bala*> balas3;
- for (short i = 0; i < 2; i++) {
- int x = rand() % 31 + 20;
- int y = rand() % 16 + 7;
- pEnemigosA3.push_back(new enemigos2(x, y));
- }
- for (short i = 0; i < 2; i++) {
- int x = rand() % 31 + 20;
- int y = rand() % 16 + 5;
- pEnemigosM3.push_back(new enemigo(x, y));
- }
- for (short i = 0; i < 1; i++) {
- int x = rand() % 30 + 20;
- int y = rand() % 1 + 2;
- pEnemigosC3.push_back(new enemigos3(x, y));
- }
- while (continuar3) {
- if (kbhit()) {
- char direccion3 = getch();
- nave3.animar(direccion3);
- if (direccion3 == DISPARAR)
- {
- balas3.push_back(new bala(nave3.x + 4, nave3.y - 1));
- }
- }
- for (short i = 0; i < pEnemigosM3.size(); i++) {
- pEnemigosM3[i]->animar();
- }
- for (short i = 0; i < pEnemigosA3.size(); i++) {
- pEnemigosA3[i]->animar();
- }
- for (short i = 0; i < pEnemigosC3.size(); i++) {
- pEnemigosC3[i]->animar();
- }
- for (int i = 0; i < balas3.size(); i++) {
- if (balas3[i]->y != 2) {
- balas3[i]->animar();
- for (int j = 0; j < pEnemigosM3.size(); j++) {
- if (colision(pEnemigosM3[j]->x, pEnemigosM3[j]->y + 1, balas3[i]->x, balas3[i]->y) ||
- colision(pEnemigosM3[j]->x + 1, pEnemigosM3[j]->y + 1, balas3[i]->x, balas3[i]->y) ||
- colision(pEnemigosM3[j]->x + 2, pEnemigosM3[j]->y + 1, balas3[i]->x, balas3[i]->y) ||
- colision(pEnemigosM3[j]->x + 3, pEnemigosM3[j]->y + 1, balas3[i]->x, balas3[i]->y)) {
- puntaje += 100;
- Console::SetCursorPosition(90, 1);
- Console::ForegroundColor = ConsoleColor::White;
- cout << "PUNTAJE = " << puntaje;
- pEnemigosM3[j]->borrar();
- delete pEnemigosM3[j];
- pEnemigosM3.erase(pEnemigosM3.begin() + j);
- j--;
- contE3--;
- if (contE3 == 0)
- {
- continuar3 = false;
- }
- }
- }
- for (int k = 0; k < pEnemigosA3.size(); k++) {
- if (colision(pEnemigosA3[k]->x, pEnemigosA3[k]->y + 1, balas3[i]->x, balas3[i]->y) ||
- colision(pEnemigosA3[k]->x + 1, pEnemigosA3[k]->y + 1, balas3[i]->x, balas3[i]->y) ||
- colision(pEnemigosA3[k]->x + 2, pEnemigosA3[k]->y + 1, balas3[i]->x, balas3[i]->y) ||
- colision(pEnemigosA3[k]->x + 3, pEnemigosA3[k]->y + 1, balas3[i]->x, balas3[i]->y)) {
- puntaje += 100;
- Console::SetCursorPosition(90, 1);
- Console::ForegroundColor = ConsoleColor::White;
- cout << "PUNTAJE = " << puntaje;
- pEnemigosA3[k]->borrar();
- delete pEnemigosA3[k];
- pEnemigosA3.erase(pEnemigosA3.begin() + k);
- k--;
- contE3--;
- if (contE3 == 0)
- {
- continuar3 = false;
- }
- }
- }
- for (int l = 0; l < pEnemigosC3.size(); l++) {
- if (colision(pEnemigosC3[l]->x, pEnemigosC3[l]->y + 1, balas3[i]->x, balas3[l]->y) ||
- colision(pEnemigosC3[l]->x + 1, pEnemigosC3[l]->y + 1, balas3[i]->x, balas3[i]->y) ||
- colision(pEnemigosC3[l]->x + 2, pEnemigosC3[l]->y + 1, balas3[i]->x, balas3[i]->y) ||
- colision(pEnemigosC3[l]->x + 3, pEnemigosC3[l]->y + 1, balas3[i]->x, balas3[i]->y)) {
- puntaje += 100;
- Console::SetCursorPosition(90, 1);
- Console::ForegroundColor = ConsoleColor::White;
- cout << "PUNTAJE = " << puntaje;
- pEnemigosC3[l]->borrar();
- delete pEnemigosC3[l];
- pEnemigosC3.erase(pEnemigosC3.begin() + l);
- l--;
- contE3--;
- if (contE3 == 0)
- {
- continuar3 = false;
- }
- }
- }
- }
- else {
- balas3[i]->borrar();
- delete balas3[i];
- balas3.erase(balas3.begin() + i);
- i--;
- break;
- }
- }
- _sleep(45);
- }
- system("cls");
- Console::SetCursorPosition(45, 37);
- cout << "NIVEL 4" << endl;
- system("pause");
- system("cls");
- int contE4 = 5;
- personaje nave4 = personaje(35, 37);
- vector<enemigo*>pEnemigosM4;
- vector<enemigos2*>pEnemigosA4;
- vector<enemigos3*>pEnemigosC4;
- bool continuar4 = true;
- vector<bala*> balas4;
- for (short i = 0; i < 2; i++) {
- int x = rand() % 31 + 20;
- int y = rand() % 16 + 7;
- pEnemigosA4.push_back(new enemigos2(x, y));
- }
- for (short i = 0; i < 2; i++) {
- int x = rand() % 31 + 20;
- int y = rand() % 16 + 5;
- pEnemigosM4.push_back(new enemigo(x, y));
- }
- for (short i = 0; i < 1; i++) {
- int x = rand() % 30 + 20;
- int y = rand() % 1 + 2;
- pEnemigosC4.push_back(new enemigos3(x, y));
- }
- while (continuar4) {
- if (kbhit()) {
- char direccion4 = getch();
- nave4.animar(direccion4);
- if (direccion4 == DISPARAR)
- {
- balas4.push_back(new bala(nave4.x + 4, nave4.y - 1));
- }
- }
- for (short i = 0; i < pEnemigosM4.size(); i++) {
- pEnemigosM4[i]->animar();
- }
- for (short i = 0; i < pEnemigosA4.size(); i++) {
- pEnemigosA4[i]->animar();
- }
- for (short i = 0; i < pEnemigosC4.size(); i++) {
- pEnemigosC4[i]->animar();
- }
- for (int i = 0; i < balas4.size(); i++) {
- if (balas4[i]->y != 2) {
- balas4[i]->animar();
- for (int j = 0; j < pEnemigosM4.size(); j++) {
- if (colision(pEnemigosM4[j]->x, pEnemigosM4[j]->y + 1, balas4[i]->x, balas4[i]->y) ||
- colision(pEnemigosM4[j]->x + 1, pEnemigosM4[j]->y + 1, balas4[i]->x, balas4[i]->y) ||
- colision(pEnemigosM4[j]->x + 2, pEnemigosM4[j]->y + 1, balas4[i]->x, balas4[i]->y) ||
- colision(pEnemigosM4[j]->x + 3, pEnemigosM4[j]->y + 1, balas4[i]->x, balas4[i]->y)) {
- puntaje += 100;
- Console::SetCursorPosition(90, 1);
- Console::ForegroundColor = ConsoleColor::White;
- cout << "PUNTAJE = " << puntaje;
- pEnemigosM4[j]->borrar();
- delete pEnemigosM4[j];
- pEnemigosM4.erase(pEnemigosM4.begin() + j);
- j--;
- contE4--;
- if (contE4 == 0)
- {
- continuar3 = false;
- }
- }
- }
- for (int k = 0; k < pEnemigosA4.size(); k++) {
- if (colision(pEnemigosA4[k]->x, pEnemigosA4[k]->y + 1, balas4[i]->x, balas4[i]->y) ||
- colision(pEnemigosA4[k]->x + 1, pEnemigosA4[k]->y + 1, balas4[i]->x, balas4[i]->y) ||
- colision(pEnemigosA4[k]->x + 2, pEnemigosA4[k]->y + 1, balas4[i]->x, balas4[i]->y) ||
- colision(pEnemigosA4[k]->x + 3, pEnemigosA4[k]->y + 1, balas4[i]->x, balas4[i]->y)) {
- puntaje += 100;
- Console::SetCursorPosition(90, 1);
- Console::ForegroundColor = ConsoleColor::White;
- cout << "PUNTAJE = " << puntaje;
- pEnemigosA4[k]->borrar();
- delete pEnemigosA4[k];
- pEnemigosA4.erase(pEnemigosA4.begin() + k);
- k--;
- contE3--;
- if (contE4 == 0)
- {
- continuar4 = false;
- }
- }
- }
- for (int l = 0; l < pEnemigosC4.size(); l++) {
- if (colision(pEnemigosC4[l]->x, pEnemigosC4[l]->y + 1, balas4[i]->x, balas4[l]->y) ||
- colision(pEnemigosC4[l]->x + 1, pEnemigosC4[l]->y + 1, balas4[i]->x, balas3[i]->y) ||
- colision(pEnemigosC4[l]->x + 2, pEnemigosC4[l]->y + 1, balas4[i]->x, balas4[i]->y) ||
- colision(pEnemigosC4[l]->x + 3, pEnemigosC4[l]->y + 1, balas4[i]->x, balas4[i]->y)) {
- puntaje += 100;
- Console::SetCursorPosition(90, 1);
- Console::ForegroundColor = ConsoleColor::White;
- cout << "PUNTAJE = " << puntaje;
- pEnemigosC4[l]->borrar();
- delete pEnemigosC4[l];
- pEnemigosC4.erase(pEnemigosC4.begin() + l);
- l--;
- contE4--;
- if (contE4 == 0)
- {
- continuar4 = false;
- }
- }
- }
- }
- else {
- balas4[i]->borrar();
- delete balas4[i];
- balas4.erase(balas4.begin() + i);
- i--;
- break;
- }
- }
- _sleep(45);
- }
- }
- void instrucciones() {
- Console::SetCursorPosition(50, 20);
- Console::ForegroundColor = ConsoleColor::DarkYellow;
- cout << "Derecha: ->" << endl;
- Console::SetCursorPosition(50, 21);
- Console::ForegroundColor = ConsoleColor::DarkYellow;
- cout << "Izquierda: <-";
- Console::SetCursorPosition(50, 22);
- Console::ForegroundColor = ConsoleColor::DarkYellow;
- cout << "Disparar: espacio";
- _sleep(5000);
- }
- void menu() {
- int n;
- Console::SetCursorPosition(10, 9);
- cout << "*****************************************" << endl;
- Console::SetCursorPosition(10, 10);
- cout << "*****************************************" << endl;
- Console::SetCursorPosition(10, 11);
- cout << "* ** ** ***** *** **** ** ** **" << endl;
- Console::SetCursorPosition(10, 12);
- cout << "* ****** ** ** ***** ** *** ***** ** *** ****** ** **" << endl;
- Console::SetCursorPosition(10, 13);
- cout << "* ****** ** **** *** **** ** ****** *" << endl;
- Console::SetCursorPosition(10, 14);
- cout << "* *** ** ** ** **** ** *** ***** ** *** *** ** ** *" << endl;
- Console::SetCursorPosition(10, 15);
- cout << "* *** ** ** ** **** ** *** ***** ** *** *** ** ** *" << endl;
- Console::SetCursorPosition(10, 16);
- cout << "* ** ** ** ** ** *** *** ** *** ** ** *" << endl;
- Console::SetCursorPosition(10, 17);
- cout << "*****************************************" << endl;
- Console::SetCursorPosition(10, 18);
- cout << "*****************************************" << endl;
- Console::SetCursorPosition(50, 20);
- cout << "1.Jugar" << endl;
- Console::SetCursorPosition(50, 21);
- cout << "0.Salir";
- Console::SetCursorPosition(50, 22);
- cout << "Digite la opcion:"; cin >> n;
- switch (n)
- {
- case 0:break;
- case 1:
- system("cls");
- instrucciones();
- system("cls");
- jugar();
- default:
- break;
- }
- }
- int main() {
- srand(time(NULL));
- Console::CursorVisible = false;
- menu();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement