Advertisement
GonzaloGuerreroP

Juego_Version4

Nov 17th, 2019
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.52 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3. #include <ctime>
  4. #include <stdlib.h>
  5. using namespace System;
  6. using namespace std;
  7. #define FILAS 20
  8. #define COLUMNAS 75
  9. #define ARRIBA 72
  10. #define ABAJO 80
  11. #define IZQUIERDA 75
  12. #define DERECHA 77
  13. #define LIMITEX 20
  14. #define LIMITEY 20
  15. #define LIMITER 5
  16. #define DISPARO 32
  17. #define DISPARO2 13
  18.  
  19. int matrizIntro[29][85] = {
  20. {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
  21. {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
  22. {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
  23. {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,0,0,0,2,2,0,0,2,2,2,2,2,2,0,0,2,2,2,2,0,0,2,2,2,2,0,0,0,0,2,2,2,2,2,0,2,2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
  80. {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
  81. };
  82.  
  83. int matrizcopia[29][85];
  84.  
  85. void copiasmatriz(int nivel) {
  86. for (int f = 0; f < 29; f++)
  87. {
  88. for (int c = 0; c < 85; c++)
  89. {
  90. if (nivel == 1) {
  91. matrizcopia[f][c] = matrizIntro[f][c];
  92. }
  93. if (nivel == 2) {
  94. matrizcopia[f][c] = matrizEstructura[f][c];
  95. }
  96. }
  97. }
  98. }
  99.  
  100. void imprimirmatriz(int nivel) {
  101. Console::Clear();
  102. for (int i = 0; i < 29; i++) {
  103. for (int j = 0; j < 85; j++) {
  104. if (nivel == 1) {
  105. if (matrizcopia[i][j] == 0) {
  106. cout << " ";
  107. }
  108. if (matrizcopia[i][j] == 1) {
  109. Console::ForegroundColor = ConsoleColor::Yellow;
  110. cout << "*";
  111. }
  112. if (matrizcopia[i][j] == 2) {
  113. Console::ForegroundColor = ConsoleColor::Blue;
  114. cout << char(219);
  115. }
  116. }
  117. if (nivel == 2) {
  118. if (matrizcopia[i][j] == 1) {
  119. Console::ForegroundColor = ConsoleColor::Red;
  120. cout << "*";
  121. }
  122. if (matrizcopia[i][j] == 0) {
  123. cout << " ";
  124. }
  125. }
  126.  
  127. }
  128. cout << "\n";
  129. }
  130. }
  131.  
  132. typedef struct Nave {
  133. int _x, _y, _vidas;
  134. int ybala, xbala;
  135. bool disparo = false;
  136. public:
  137. Nave(int x, int y) {
  138. _x = x;
  139. _y = y;
  140. _vidas = 3;
  141. }
  142. void animar(short tecla) {
  143. borrar();
  144. mover(tecla);
  145. dibujar();
  146. }
  147. void borrar() {
  148. Console::SetCursorPosition(_x, _y);
  149. cout << " ";
  150. Console::SetCursorPosition(_x-1, _y+1);
  151. cout << " ";
  152. Console::SetCursorPosition(_x + 1, _y + 1);
  153. cout << " ";
  154. Console::SetCursorPosition(_x -1, _y + 1);
  155. cout << " ";
  156. Console::SetCursorPosition(_x, _y + 2);
  157. cout << " ";
  158. Console::SetCursorPosition(_x - 1, _y + 2);
  159. cout << " ";
  160. Console::SetCursorPosition(_x + 1 , _y + 2);
  161. cout << " ";
  162. Console::SetCursorPosition(_x + 2, _y + 2);
  163. cout << " ";
  164. Console::SetCursorPosition(_x - 2, _y + 2);
  165. cout << " ";
  166. Console::SetCursorPosition(_x - 2, _y + 3);
  167. cout << " ";
  168. Console::SetCursorPosition(_x + 2, _y + 3);
  169. cout << " ";
  170. }
  171. void mover(short tecla) {
  172. short direccion;
  173. direccion = toupper(tecla);
  174. switch (direccion) {
  175. case 'W': if (_y - 1 >= 1) {
  176. _y--;
  177. ybala = _y;
  178. break;
  179. }
  180. case 'S': if (_y + 4 <= 27) {
  181. _y++;
  182. ybala = _y;
  183. break;
  184. }
  185. case 'A': if (_x - 2 >= 2) {
  186. _x--;
  187. xbala = _x;
  188. break;
  189. }
  190. case 'D': if (_x + 3 <= 83) {
  191. _x++;
  192. xbala = _x;
  193. break;
  194. }
  195. }
  196. }
  197. void dibujar() {
  198. Console::SetCursorPosition(_x, _y);
  199. Console::ForegroundColor = ConsoleColor::Green;
  200. cout << char(219);
  201. Console::SetCursorPosition(_x, _y+1);
  202. Console::ForegroundColor = ConsoleColor::Blue;
  203. cout << char(219);
  204. Console::SetCursorPosition(_x + 1, _y + 1);
  205. Console::ForegroundColor = ConsoleColor::Green;
  206. cout << char(219);
  207. Console::SetCursorPosition(_x -1, _y + 1);
  208. Console::ForegroundColor = ConsoleColor::Green;
  209. cout << char(219);
  210. Console::SetCursorPosition(_x, _y + 2);
  211. Console::ForegroundColor = ConsoleColor::Blue;
  212. cout << char(223);
  213. Console::SetCursorPosition(_x - 1, _y + 2);
  214. Console::ForegroundColor = ConsoleColor::Blue;
  215. cout << char(219);
  216. Console::SetCursorPosition(_x +1 , _y + 2);
  217. Console::ForegroundColor = ConsoleColor::Blue;
  218. cout << char(219);
  219. Console::SetCursorPosition(_x+2, _y + 2);
  220. Console::ForegroundColor = ConsoleColor::Green;
  221. cout << char(219);
  222. Console::SetCursorPosition(_x -2, _y + 2);
  223. Console::ForegroundColor = ConsoleColor::Green;
  224. cout << char(219);
  225. Console::SetCursorPosition(_x - 2, _y + 3);
  226. Console::ForegroundColor = ConsoleColor::Green;
  227. cout << char(223);
  228. Console::SetCursorPosition(_x + 2, _y + 3);
  229. Console::ForegroundColor = ConsoleColor::Green;
  230. cout << char(223);
  231. }
  232.  
  233. void dibujarBala() {
  234. Console::SetCursorPosition(xbala, ybala - 1);
  235. Console::ForegroundColor = ConsoleColor::Cyan;
  236. cout << "*";
  237. }
  238.  
  239. void eliminarBala() {
  240. Console::SetCursorPosition(xbala, ybala - 1);
  241. cout << " ";
  242. }
  243.  
  244. void bala(short tecla) {
  245. if ((int)tecla == DISPARO) {
  246. xbala = _x;
  247. ybala = _y;
  248. disparo = true;
  249. }
  250. }
  251.  
  252.  
  253. };
  254.  
  255. typedef struct NaveEnemiga {
  256. short _x, _y, _dx, _dy, _retraso;
  257. char _img;
  258. public:
  259. NaveEnemiga(short x, short y, short dx, short dy) {
  260. _x = x;
  261. _y = y;
  262. _dx = dx;
  263. _dy = dy;
  264. _retraso = 0;
  265. _img = (char)2;
  266. }
  267. void animar() {
  268. if (_retraso == LIMITER) {
  269.  
  270. borrar();
  271. mover();
  272. dibujar();
  273. _retraso = 0;
  274. }
  275. _retraso++;
  276. }
  277. void borrar() {
  278. Console::SetCursorPosition(_x, _y);
  279. cout << " ";
  280. }
  281. void mover() {
  282. if (_x + _dx < 1 || _x + _dx > 83) {
  283. _dx *= -1;
  284. _y++;
  285. }
  286. if (_y == 28) {
  287. _y = 1;
  288. }
  289. _x += _dx;
  290. }
  291. void dibujar() {
  292. Console::SetCursorPosition(_x, _y);
  293. Console::ForegroundColor = ConsoleColor::Green;
  294. cout << _img;
  295. }
  296. };
  297.  
  298. typedef struct Nave2 {
  299. int _x, _y, _vidas;
  300. int ybala, xbala;
  301. bool disparo = false;
  302. public:
  303. Nave2(int x, int y) {
  304. _x = x;
  305. _y = y;
  306. _vidas = 3;
  307. }
  308. void animar(short tecla) {
  309. borrar();
  310. mover(tecla);
  311. dibujar();
  312. }
  313. void borrar() {
  314. Console::SetCursorPosition(_x, _y);
  315. cout << " ";
  316. Console::SetCursorPosition(_x - 1, _y + 1);
  317. cout << " ";
  318. Console::SetCursorPosition(_x + 1, _y + 1);
  319. cout << " ";
  320. Console::SetCursorPosition(_x - 1, _y + 1);
  321. cout << " ";
  322. Console::SetCursorPosition(_x, _y + 2);
  323. cout << " ";
  324. Console::SetCursorPosition(_x - 1, _y + 2);
  325. cout << " ";
  326. Console::SetCursorPosition(_x + 1, _y + 2);
  327. cout << " ";
  328. Console::SetCursorPosition(_x + 2, _y + 2);
  329. cout << " ";
  330. Console::SetCursorPosition(_x - 2, _y + 2);
  331. cout << " ";
  332. Console::SetCursorPosition(_x - 2, _y + 3);
  333. cout << " ";
  334. Console::SetCursorPosition(_x + 2, _y + 3);
  335. cout << " ";
  336. }
  337. void mover(short tecla) {
  338. switch (tecla) {
  339. case ARRIBA: if (_y - 1 >= 1) _y--; break;
  340. case ABAJO: if (_y + 4 <= 27) _y++; break;
  341. case IZQUIERDA: if (_x - 2 >= 2) _x--; break;
  342. case DERECHA: if (_x + 3 <= 83) _x++; break;
  343. }
  344. }
  345. void dibujar() {
  346. Console::SetCursorPosition(_x, _y);
  347. Console::ForegroundColor = ConsoleColor::White;
  348. cout << char(219);
  349. Console::SetCursorPosition(_x, _y + 1);
  350. Console::ForegroundColor = ConsoleColor::Red;
  351. cout << char(219);
  352. Console::SetCursorPosition(_x + 1, _y + 1);
  353. Console::ForegroundColor = ConsoleColor::White;
  354. cout << char(219);
  355. Console::SetCursorPosition(_x - 1, _y + 1);
  356. Console::ForegroundColor = ConsoleColor::White;
  357. cout << char(219);
  358. Console::SetCursorPosition(_x, _y + 2);
  359. Console::ForegroundColor = ConsoleColor::Red;
  360. cout << char(223);
  361. Console::SetCursorPosition(_x - 1, _y + 2);
  362. Console::ForegroundColor = ConsoleColor::Red;
  363. cout << char(219);
  364. Console::SetCursorPosition(_x + 1, _y + 2);
  365. Console::ForegroundColor = ConsoleColor::Red;
  366. cout << char(219);
  367. Console::SetCursorPosition(_x + 2, _y + 2);
  368. Console::ForegroundColor = ConsoleColor::White;
  369. cout << char(219);
  370. Console::SetCursorPosition(_x - 2, _y + 2);
  371. Console::ForegroundColor = ConsoleColor::White;
  372. cout << char(219);
  373. Console::SetCursorPosition(_x - 2, _y + 3);
  374. Console::ForegroundColor = ConsoleColor::White;
  375. cout << char(223);
  376. Console::SetCursorPosition(_x + 2, _y + 3);
  377. Console::ForegroundColor = ConsoleColor::White;
  378. cout << char(223);
  379. }
  380.  
  381. void dibujarBala() {
  382. Console::SetCursorPosition(xbala, ybala - 1);
  383. Console::ForegroundColor = ConsoleColor::Cyan;
  384. cout << "*";
  385. }
  386.  
  387. void eliminarBala() {
  388. Console::SetCursorPosition(xbala, ybala - 1);
  389. cout << " ";
  390. }
  391.  
  392. void bala(short tecla) {
  393. if ((int)tecla == DISPARO2) {
  394. xbala = _x;
  395. ybala = _y;
  396. disparo = true;
  397. }
  398. }
  399. };
  400.  
  401. inline bool colision(Nave &nave , NaveEnemiga &enemiga) {
  402. return (nave.ybala) - 1 == enemiga._y && nave.xbala == enemiga._x;
  403. }
  404.  
  405. void jugar(int players) {
  406. bool continuar = true;
  407. NaveEnemiga enemigo1 = NaveEnemiga(5, 2, -1, +1);
  408. NaveEnemiga enemigo2 = NaveEnemiga(2, 2, -1, +1);
  409. NaveEnemiga enemigo3 = NaveEnemiga(8, 2, -1, +1);
  410. NaveEnemiga enemigo4 = NaveEnemiga(11, 2, -1, +1);
  411. NaveEnemiga enemigo5 = NaveEnemiga(14, 2, -1, +1);
  412. NaveEnemiga enemigo6 = NaveEnemiga(17, 2, -1, +1);
  413. NaveEnemiga enemigo7 = NaveEnemiga(20, 2, -1, +1);
  414. NaveEnemiga enemigo8 = NaveEnemiga(23, 2, -1, +1);
  415. NaveEnemiga enemigo9 = NaveEnemiga(26, 2, -1, +1);
  416. NaveEnemiga enemigo10 = NaveEnemiga(29, 2, -1, +1);
  417. Nave nave1 = Nave(40, 20);
  418. Nave nave3 = Nave(30, 20);
  419. Nave2 nave2 = Nave2(55, 20);
  420. while (continuar) {
  421. if (kbhit()) {
  422. if (players == 1) {
  423. char tecla = getch();
  424. nave1.animar(tecla);
  425. nave1.bala(tecla);
  426. }
  427. else if (players == 2) {
  428. char tecla = getch();
  429. nave3.animar(tecla);
  430. nave3.bala(tecla);
  431. nave2.animar(tecla);
  432. nave2.bala(tecla);
  433. }
  434. }
  435. if (players == 1) {
  436. if (nave1.disparo)nave1.dibujarBala();
  437. }
  438. else if (players == 2) {
  439. if (nave3.disparo)nave3.dibujarBala();
  440. if (nave2.disparo)nave2.dibujarBala();
  441. }
  442. enemigo1.animar();
  443. enemigo2.animar();
  444. enemigo3.animar();
  445. enemigo4.animar();
  446. enemigo5.animar();
  447. enemigo6.animar();
  448. enemigo7.animar();
  449. enemigo8.animar();
  450. enemigo9.animar();
  451. enemigo10.animar();
  452. _sleep(20);
  453. if (players == 1) {
  454. if (nave1.disparo) {
  455. nave1.eliminarBala();
  456. nave1.ybala--;
  457. }
  458. if (nave1.ybala - 1 <= 1) {
  459. nave1.disparo = false;
  460. }
  461. }
  462. if (players == 2) {
  463. if (nave3.disparo) {
  464. nave3.eliminarBala();
  465. nave3.ybala--;
  466. }
  467. if (nave3.ybala - 1 <= 1) {
  468. nave3.disparo = false;
  469. }
  470. if (nave2.disparo) {
  471. nave2.eliminarBala();
  472. nave2.ybala--;
  473. }
  474. if (nave2.ybala - 1 <= 1) {
  475. nave2.disparo = false;
  476. }
  477. }
  478. if (colision(nave1, enemigo1)) {
  479.  
  480. }
  481. }
  482. getch();
  483. }
  484.  
  485. int main() {
  486. int nivel;
  487. int players;
  488. Console::CursorVisible = false;
  489. copiasmatriz(nivel = 1);
  490. imprimirmatriz(nivel = 1);
  491. Console::SetCursorPosition(27, 27);
  492. Console::ForegroundColor = ConsoleColor::White;
  493. cout << "<<PRESIONE CUALQUIER TECLA PARA COMENZAR>>";
  494. if (getch()) {
  495. do {
  496. system("cls");
  497. copiasmatriz(nivel = 2);
  498. imprimirmatriz(nivel = 2);
  499. Console::SetCursorPosition(16, 14);
  500. Console::ForegroundColor = ConsoleColor::Green;
  501. cout << "Seleccione una cantidad de jugadores entre 1 y 2: ";
  502. cin >> players;
  503. } while (!(players==1 || players ==2));
  504. system("cls");
  505. copiasmatriz(nivel = 2);
  506. imprimirmatriz(nivel = 2);
  507. jugar( players);
  508. }
  509. return 0;
  510. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement