Advertisement
Mauriciocaradenepe

Movimiento naranja XD

Jun 6th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. #include<iostream>
  2. #include<conio.h>
  3. #include<fstream>
  4. #include "Mapas.hpp"
  5. using namespace std;
  6. using namespace System;
  7. void dibujo() {
  8.  
  9.  
  10. for (int cf = 0; cf < 15; cf++)
  11. {
  12. for (int cc = 0; cc < 15; cc++)
  13. {
  14. Console::SetCursorPosition(cc,cf);
  15. switch (mapa1[cf][cc])
  16. {
  17. case 0:Console::ForegroundColor = ConsoleColor::DarkRed;cout<<(char)219; break;
  18. case 1:Console::ForegroundColor = ConsoleColor::Green; cout << (char)219; break;
  19. case 2:Console::ForegroundColor = ConsoleColor::Blue; break;
  20. case 3:Console::ForegroundColor = ConsoleColor::Blue; cout << (char)219; break;
  21. case 4:Console::ForegroundColor = ConsoleColor::Gray; cout << (char)219; break;
  22. case 5:Console::ForegroundColor = ConsoleColor::DarkGray; cout << (char)219; break;
  23. case 6:Console::ForegroundColor = ConsoleColor::Yellow; cout << (char)219; break;
  24. case 7:Console::ForegroundColor = ConsoleColor::Red; cout << (char)219; break;
  25. case 8:Console::ForegroundColor = ConsoleColor::DarkMagenta; cout << (char)219; break;
  26. case 9:Console::ForegroundColor = ConsoleColor::DarkGreen; cout << (char)219; break;
  27. break;
  28. }
  29. }
  30. }
  31. }
  32. //key logger
  33. //derecha=77
  34. //izquierda=75
  35. //arriba=72
  36. //abajo=80
  37. void borrarP(int x, int y) {
  38. Console::SetCursorPosition(x, y);
  39.  
  40. cout << "";
  41.  
  42. }
  43. int main() {
  44. char tecla;
  45. int x = 10;//posicion inicial en x
  46. int y = 10;//posicion inicial en y
  47. dibujo();
  48. for (;tecla!=27;)
  49. {
  50. _sleep(40);
  51.  
  52. Console::SetCursorPosition(x, y);
  53. cout << (char)1;
  54. if (kbhit())//detecta si se pulsa tecla
  55. {
  56.  
  57. //borrarP(x, y);
  58. tecla = _getch();
  59. switch ((int)tecla)
  60. {
  61. case 77: if (x < 14) {
  62. ++x; } break;
  63. case 80:if (y < 14) {
  64. ++y; } break;
  65. case 72: if (y > 0) {
  66. --y; }break;
  67. case 75: if (x > 0) {
  68. --x; }break;
  69. }
  70. dibujo();
  71.  
  72. }
  73. }
  74.  
  75.  
  76. cin.get();
  77. return 0;
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement