Advertisement
dioses1302

Untitled

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