Advertisement
Mauriciocaradenepe

mov

Jun 20th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.21 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3. #include <fstream>
  4. #include<ctime>
  5. #include<cstdlib>
  6. #define FILAS 24
  7. #define COLUMNAS 80
  8. using namespace std;
  9. using namespace System;
  10. int dir = 1;
  11. int lvl2[FILAS][COLUMNAS] = {
  12. { 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4 },
  13. { 4,4,4,4,4,4,4,4,1,1,1,4,4,4,4,4,4,4,4,4,4,4,4,4,1,1,1,4,4,4,4,4,4,4,4,4,4,4,4,1,1,1,1,4,4,4,4,4,4,4,4,4,4,4,4,1,1,1,4,4,4,4,4,4,4,4,4,4,4,4,4,1,1,1,4,4,4,4,4,4 },
  14. { 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 },
  15. { 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 },
  16. { 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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4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4 }
  36. };
  37. void dibujo2() {
  38. for (int cf = 0; cf < FILAS; cf++)
  39. {
  40. for (int cc = 0; cc < COLUMNAS; cc++)
  41. {
  42. Console::SetCursorPosition(cc, cf);
  43. switch (lvl2[cf][cc])
  44. {
  45. case 1:Console::ForegroundColor = ConsoleColor::Cyan; cout << (char)219; break;
  46. case 2:Console::ForegroundColor = ConsoleColor::DarkGray; cout << (char)219; break;
  47. case 3:Console::ForegroundColor = ConsoleColor::Gray; cout << (char)219; break;
  48. case 4:Console::ForegroundColor = ConsoleColor::DarkGreen; cout << (char)219; break;
  49. case 5:Console::ForegroundColor = ConsoleColor::Green; cout << (char)219; break;
  50. case 6:Console::ForegroundColor = ConsoleColor::DarkBlue; cout << (char)219; break;
  51. case 7:Console::ForegroundColor = ConsoleColor::White; cout << (char)219; break;
  52. case 9:Console::ForegroundColor = ConsoleColor::Red; cout << (char)219; break;
  53. case 10:Console::ForegroundColor = ConsoleColor::DarkRed; cout << (char)219; break;
  54. case 12:Console::ForegroundColor = ConsoleColor::DarkRed; cout << (char)219; break;
  55. case 13:Console::ForegroundColor = ConsoleColor::DarkRed; cout << (char)219; break;
  56. case 14:Console::ForegroundColor = ConsoleColor::DarkRed; cout << (char)219; break;
  57. case 11:Console::ForegroundColor = ConsoleColor::Magenta; cout << (char)219; break;
  58. case 0:Console::ForegroundColor = ConsoleColor::Yellow; cout << (char)219; break;
  59. }
  60. }
  61. cout << endl;
  62. }
  63. }
  64.  
  65. void pintar(int x, int y) {
  66. Console::SetCursorPosition(x , y); Console::ForegroundColor = ConsoleColor::DarkRed; cout << (char)219 << (char)219 << (char)219 << (char)219 << (char)219 << (char)219 << (char)219;
  67.  
  68.  
  69. }
  70. void borrar(int x, int y) {
  71. Console::SetCursorPosition(x, y);
  72. Console::BackgroundColor = ConsoleColor::Cyan; cout << " ";
  73. }
  74. void buscaPersonaje(int n[FILAS][COLUMNAS],int *x,int *y,int p) {
  75. for (int f = 0; f < FILAS; f++)
  76. {
  77. for (int c = 0; c < COLUMNAS; c++)
  78. {
  79. if (n[f][c]==p)
  80. {
  81. *x = f;
  82. *y = c;
  83. break;
  84. }
  85. }
  86. }
  87.  
  88. }
  89. void moverPersonaje(int n[FILAS][COLUMNAS],short d, int x, int y) {
  90. switch (d)
  91. {
  92. case 1://derecha
  93. if (n[x][y+1]==4 )
  94. {
  95. n[x][y + 1] = 0;
  96. n[x][y] = 4;
  97. }; break;
  98. case 2://izquierda
  99. if (n[x][y-1] == 4)
  100. {
  101. n[x][y - 1] = 0;
  102. n[x][y] = 4;
  103. }; break;
  104. case 3:
  105. if (n[x-1][y] == 4)
  106. {
  107. n[x-1][y] = 0;
  108. n[x][y] = 4;
  109. }; break;
  110. case 4:
  111. if (n[x+1][y] == 4)
  112. {
  113. n[x+1][y] = 0;
  114. n[x][y] = 4;
  115. }; break;
  116. }
  117.  
  118. }
  119. //void moviTRo(int n[FILAS][COLUMNAS],int *x,int *y,int num) {
  120. //
  121. //
  122. // buscaPersonaje(lvl2, x, y, num);
  123. // if (n[*x][*y + 1] == num && n[*x][*y + 7] == 1)
  124. // {
  125. // if (dir==1) {
  126. // for (int i = 1; i < 7; i++) {
  127. // n[*x][*y + i] = num;
  128. // }
  129. // n[*x][*y] = 1;
  130. // }
  131. // else {
  132. // for (int i = 7; i >1; i--) {
  133. // n[*x][*y + i] = num;
  134. // }
  135. // n[*x][*y] = 1;
  136. // }
  137. //
  138. //
  139. // }
  140. // if (n[*x][*y + 7] != 1) {
  141. // dir = 2;
  142. // }
  143. //
  144. //
  145. //
  146. //}
  147. void moverTronco(int n[FILAS][COLUMNAS]) {
  148. int x, y;
  149. /*moviTRo(n,&x, &y, 10);
  150. moviTRo(n, &x, &y, 12);
  151. moviTRo(n, &x,&y, 13);
  152. moviTRo(n, &x, &y, 14);*/
  153. dibujo2();
  154.  
  155. }
  156. int main() {
  157. //repite:
  158. int x = 0;
  159. int tecla;
  160. int y = 0;
  161. int n;
  162. dibujo2();
  163. while (true)
  164. {
  165.  
  166. if (kbhit())
  167. {
  168. buscaPersonaje(lvl2, &x, &y,0);
  169. tecla = _getch();
  170.  
  171. switch (tecla)
  172. {
  173. case 97:moverPersonaje(lvl2, 2, x, y); break;
  174. case 100:moverPersonaje(lvl2, 1, x, y); break;
  175. case 119:moverPersonaje(lvl2, 3, x, y); break;
  176. case 115:moverPersonaje(lvl2, 4, x, y); break;
  177. }
  178. dibujo2();
  179.  
  180. }
  181. n = rand() % 500;
  182. if (n<100)
  183. {
  184. moverTronco(lvl2);
  185. }
  186. }
  187. //A=7
  188. //D=100
  189. //W=119
  190. //S=115
  191. /*while (i<72)
  192. {
  193. _sleep(50);
  194. borrar(x , y);
  195. pintar(x+1 , y);
  196.  
  197. if (i<64)
  198. {
  199. borrar(w, y);
  200. pintar(w + 1, y);
  201. w++;
  202.  
  203. }
  204. if (i<57)
  205. {
  206. borrar(z, y);
  207. pintar(z + 1, y);
  208. z++;
  209. }
  210. x++;
  211. ++i;
  212. }
  213. goto repite;*/
  214.  
  215. cin.get();
  216. return 0;
  217. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement