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 ARRIBA 72
- #define IZQUIERDA 75
- #define DERECHA 77
- #define ABAJO 80
- void dibuja(int x, int y) {
- Console::SetCursorPosition(x, y);
- cout << (char)1;
- }
- int main() {
- int c, x=5, y=5;
- Console::Clear();
- dibuja(x, y);
- while (true) {
- if (kbhit()) {
- c = getch();
- c = toupper(c);
- switch (c) {
- case 'W':
- case ARRIBA:
- y--;
- break;
- case 'S':
- case ABAJO:
- y++;
- break;
- case 'D':
- case DERECHA:
- x++;
- break;
- case 'A':
- case IZQUIERDA:
- x--;
- break;
- }
- Console::Clear();
- dibuja(x, y);
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement