Advertisement
Guest User

Untitled

a guest
May 25th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.76 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3. using namespace std;
  4. using namespace System;
  5.  
  6. #define UP 72
  7. #define LEFT 75
  8. #define DOWN 80
  9. #define RIGHT 77
  10.  
  11. void dibuja(int x, int y, ConsoleColor color) {
  12.     Console::ForegroundColor = color;
  13.     Console::SetCursorPosition(x, y);
  14.     cout << (char)1;
  15. }
  16.  
  17.  
  18. int main() {
  19.     int c, x=5, y=7;
  20.     dibuja(x, y, ConsoleColor::Yellow);
  21.  
  22.     while (true) {
  23.         if (_kbhit()) {
  24.             c = _getch();
  25.             switch (c) {
  26.             case UP:
  27.                 cout << "Arriba" << endl;
  28.                 break;
  29.             case DOWN:
  30.                 cout << "Abajo" << endl;
  31.                 break;
  32.             case LEFT:
  33.                 cout << "Izquierda" << endl;
  34.                 break;
  35.             case RIGHT:
  36.                 cout << "Derecha" << endl;
  37.                 break;
  38.             }
  39.             Console::Clear();
  40.             dibuja(x, y, ConsoleColor::Yellow);
  41.         }
  42.     }
  43.     return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement