Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <conio.h>
- using namespace std;
- using namespace System;
- #define UP 72
- #define LEFT 75
- #define DOWN 80
- #define RIGHT 77
- void dibuja(int x, int y, ConsoleColor color) {
- Console::ForegroundColor = color;
- Console::SetCursorPosition(x, y);
- cout << (char)1;
- }
- int main() {
- int c, x=5, y=7;
- dibuja(x, y, ConsoleColor::Yellow);
- while (true) {
- if (_kbhit()) {
- c = _getch();
- switch (c) {
- case UP:
- cout << "Arriba" << endl;
- break;
- case DOWN:
- cout << "Abajo" << endl;
- break;
- case LEFT:
- cout << "Izquierda" << endl;
- break;
- case RIGHT:
- cout << "Derecha" << endl;
- break;
- }
- Console::Clear();
- dibuja(x, y, ConsoleColor::Yellow);
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement