Advertisement
Guest User

frogger

a guest
Jun 25th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.51 KB | None | 0 0
  1. #include<iostream>
  2. #include<conio.h>
  3. #include<Windows.h>
  4. #include<stdio.h>
  5. #include <locale.h>
  6.  
  7. using namespace std;
  8. using namespace System;
  9. #define ARRIBA 72
  10. #define IZQUIERDA 75
  11. #define DERECHA 77
  12. #define ABAJO 80
  13.  
  14. #define CF 25
  15. #define CC 22
  16.  
  17. int dir = 3;
  18. char tecla;
  19.  
  20. void colr(int x)
  21. {
  22. HANDLE colr = GetStdHandle(STD_OUTPUT_HANDLE);
  23. SetConsoleTextAttribute(colr, x);
  24. }
  25. void teclear() {
  26. if (kbhit()) {
  27. tecla = getch();
  28. switch (tecla) {
  29. case ARRIBA: if (dir != 2) dir = 1; break;
  30. case ABAJO: if (dir != 1) dir = 2; break;
  31. case DERECHA: if (dir != 4) dir = 3; break;
  32. case IZQUIERDA: if (dir != 3) dir = 4; break;
  33. }
  34. }
  35. }
  36.  
  37. void nivel1()
  38. {
  39. int mat[CF][CC] = {
  40. { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 },
  41. { 1,1,2,2,1,1,2,2,1,1,2,2,1,1,2,2,1,1,2,2,1,1 },
  42. { 1,1,2,2,1,1,2,2,1,1,2,2,1,1,2,2,1,1,2,2,1,1 },
  43. { 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 },
  44. { 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 },
  45. { 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 },
  46. { 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 },
  47. { 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 },
  48. { 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 },
  49. { 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 },
  50. { 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 },
  51. { 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 },
  52. { 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 },
  53. { 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 },
  54. { 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 },
  55. { 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4 },
  56. { 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4 },
  57. { 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4 },
  58. { 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4 },
  59. { 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4 },
  60. { 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4 },
  61. { 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4 },
  62. { 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4 },
  63. { 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 },
  64. { 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 } };
  65.  
  66.  
  67.  
  68. for (int i = 0; i < CF; i++)
  69. {
  70. for (int j = 0; j <CC; j++)
  71. {
  72. switch (mat[i][j])
  73. {
  74. case 0:
  75. Console::SetCursorPosition(j, i);
  76. Console::BackgroundColor = ConsoleColor::White;
  77. cout << " ";
  78. break;
  79. case 1:
  80. colr(34);
  81. cout << " ";
  82. break;
  83.  
  84. case 2:
  85. Console::SetCursorPosition(j, i);
  86. Console::BackgroundColor = ConsoleColor::Cyan;
  87. cout << " ";
  88. break;
  89.  
  90. case 3:
  91. Console::SetCursorPosition(j, i);
  92. Console::BackgroundColor = ConsoleColor::DarkRed;
  93. cout << " ";
  94. break;
  95.  
  96. case 4:
  97. Console::SetCursorPosition(j, i);
  98. Console::BackgroundColor = ConsoleColor::Gray;
  99. cout << " ";
  100. break;
  101.  
  102. }
  103. }
  104. cout << endl;
  105.  
  106. }
  107.  
  108. }
  109.  
  110. void nivel2()
  111. {
  112. int mat[CF][CC] = { { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 },
  113. { 1,1,2,2,1,1,2,2,1,1,2,2,1,1,2,2,1,1,2,2,1,1 },
  114. { 1,1,2,2,1,1,2,2,1,1,2,2,1,1,2,2,1,1,2,2,1,1 },
  115. { 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 },
  116. { 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 },
  117. { 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 },
  118. { 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 },
  119. { 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 },
  120. { 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 },
  121. { 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 },
  122. { 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 },
  123. { 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 },
  124. { 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 },
  125. { 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 },
  126. { 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 },
  127. { 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 },
  128. { 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 },
  129. { 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 },
  130. { 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 },
  131. { 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 },
  132. { 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 },
  133. { 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 },
  134. { 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 },
  135. { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 },
  136. { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 } };
  137.  
  138. for (int i = 0; i < CF; i++)
  139. {
  140. for (int j = 0; j <CC; j++)
  141. {
  142. switch (mat[i][j])
  143. {
  144. case 0:
  145. Console::SetCursorPosition(j, i);
  146. Console::BackgroundColor = ConsoleColor::White;
  147. cout << " ";
  148. break;
  149. case 1:
  150. colr(34);
  151. cout << " ";
  152. break;
  153.  
  154. case 2:
  155. Console::SetCursorPosition(j, i);
  156. Console::BackgroundColor = ConsoleColor::Cyan;
  157. cout << " ";
  158. break;
  159.  
  160. case 3:
  161. Console::SetCursorPosition(j, i);
  162. Console::BackgroundColor = ConsoleColor::Gray;
  163. cout << " ";
  164. break;
  165.  
  166. }
  167. }
  168. cout << endl;
  169. }
  170. }
  171. void nivel3()
  172. {
  173. int mat[CF][CC] = { { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 },
  174. { 1,1,2,2,1,1,2,2,1,1,2,2,1,1,2,2,1,1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,3,3 },
  195. { 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 },
  196. { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 },
  197. { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 } };
  198.  
  199.  
  200. for (int i = 0; i < CF; i++)
  201. {
  202. for (int j = 0; j <CC; j++)
  203. {
  204. switch (mat[i][j])
  205. {
  206. case 0:
  207. Console::SetCursorPosition(j, i);
  208. Console::BackgroundColor = ConsoleColor::White;
  209. cout << " ";
  210. break;
  211. case 1:
  212. colr(34);
  213. cout << " ";
  214. break;
  215.  
  216. case 2:
  217. Console::SetCursorPosition(j, i);
  218. Console::BackgroundColor = ConsoleColor::Cyan;
  219. cout << " ";
  220. break;
  221.  
  222. case 3:
  223. Console::SetCursorPosition(j, i);
  224. Console::BackgroundColor = ConsoleColor::Gray;
  225. cout << " ";
  226. break;
  227.  
  228. case 4:
  229. colr(106);
  230. cout << " ";
  231. break;
  232.  
  233.  
  234. }
  235. }
  236. cout << endl;
  237. }
  238. }
  239. void nivel4()
  240. {
  241. int mat[CF][CC] = { { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 },
  242. { 1,1,2,2,1,1,2,2,1,1,2,2,1,1,2,2,1,1,2,2,1,1 },
  243. { 1,1,2,2,1,1,2,2,1,1,2,2,1,1,2,2,1,1,2,2,1,1 },
  244. { 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 },
  245. { 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 },
  246. { 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 },
  247. { 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 },
  248. { 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4 },
  249. { 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4 },
  250. { 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4 },
  251. { 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4 },
  252. { 5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,5,5,5,5 },
  253. { 5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,5,5,5,5 },
  254. { 5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,5,5,5,5 },
  255. { 5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,5,5,5,5 },
  256. { 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4 },
  257. { 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4 },
  258. { 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4 },
  259. { 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4 },
  260. { 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4 },
  261. { 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4 },
  262. { 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4 },
  263. { 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4 },
  264. { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 },
  265. { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 } };
  266.  
  267. for (int i = 0; i < CF; i++)
  268. {
  269. for (int j = 0; j <CC; j++)
  270. {
  271. switch (mat[i][j])
  272. {
  273. case 0:
  274. Console::SetCursorPosition(j, i);
  275. Console::BackgroundColor = ConsoleColor::White;
  276. cout << " ";
  277. break;
  278. case 1:
  279. colr(34);
  280. cout << " ";
  281. break;
  282.  
  283. case 2:
  284. Console::SetCursorPosition(j, i);
  285. Console::BackgroundColor = ConsoleColor::Cyan;
  286. cout << " ";
  287. break;
  288.  
  289. case 3:
  290. colr(106);
  291. cout << " ";
  292. break;
  293.  
  294. case 4:
  295. Console::SetCursorPosition(j, i);
  296. Console::BackgroundColor = ConsoleColor::Gray;
  297. cout << " ";
  298. break;
  299. case 5:
  300. Console::SetCursorPosition(j, i);
  301. Console::BackgroundColor = ConsoleColor::DarkMagenta;
  302. cout << " ";
  303. break;
  304. case 6:
  305. Console::SetCursorPosition(j, i);
  306. Console::BackgroundColor = ConsoleColor::Yellow;
  307. cout << " ";
  308. break;
  309.  
  310.  
  311. }
  312. }
  313. cout << endl;
  314. }
  315. }
  316. void nivel5()
  317. {
  318. int mat[CF][CC] = { { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 },
  319. { 1,1,2,2,1,1,2,2,1,1,2,2,1,1,2,2,1,1,2,2,1,1 },
  320. { 1,1,2,2,1,1,2,2,1,1,2,2,1,1,2,2,1,1,2,2,1,1 },
  321. { 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 },
  322. { 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 },
  323. { 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 },
  324. { 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 },
  325. { 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 },
  326. { 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 },
  327. { 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 },
  328. { 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 },
  329. { 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 },
  330. { 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 },
  331. { 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 },
  332. { 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 },
  333. { 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 },
  334. { 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 },
  335. { 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 },
  336. { 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 },
  337. { 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 },
  338. { 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 },
  339. { 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 },
  340. { 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 },
  341. { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 },
  342. { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 } };
  343.  
  344. for (int i = 0; i < CF; i++)
  345. {
  346. for (int j = 0; j <CC; j++)
  347. {
  348. switch (mat[i][j])
  349. {
  350. case 0:
  351. Console::SetCursorPosition(j, i);
  352. Console::BackgroundColor = ConsoleColor::White;
  353. cout << " ";
  354. break;
  355. case 1:
  356. colr(34);
  357. cout << " ";
  358. break;
  359.  
  360. case 2:
  361. Console::SetCursorPosition(j, i);
  362. Console::BackgroundColor = ConsoleColor::Cyan;
  363. cout << " ";
  364. break;
  365.  
  366. case 3:
  367. Console::SetCursorPosition(j, i);
  368. Console::BackgroundColor = ConsoleColor::Gray;
  369. cout << " ";
  370. break;
  371. }
  372. }
  373. cout << endl;
  374. }
  375. }
  376.  
  377. void main()
  378. {
  379. int level;
  380.  
  381. //BIENVENIDA();
  382.  
  383. cout << "escoja nivel:" << endl;
  384. cout << "1) primer nivel" << endl;
  385. cout << "2) segundo nivel" << endl;
  386. cout << "3) tercer nivel" << endl;
  387. cout << "4) cuarto nivel" << endl;
  388. cout << "5) quinto nivel" << endl;
  389. cout << endl;
  390. cin >> level;
  391.  
  392. switch (level)
  393. {
  394. case 1:
  395. Console::Clear();
  396. nivel1();
  397. break;
  398. case 2:
  399. Console::Clear();
  400. nivel2();
  401. break;
  402. case 3:
  403. Console::Clear();
  404. nivel3();
  405. break;
  406. case 4:
  407. Console::Clear();
  408. nivel4();
  409. break;
  410. case 5:
  411. Console::Clear();
  412. nivel5();
  413. break;
  414. }
  415. _getch();
  416. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement