Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<conio.h>
- #include<fstream>
- #include "Mapas.hpp"
- using namespace std;
- using namespace System;
- void dibujo() {
- for (int cf = 0; cf < 15; cf++)
- {
- for (int cc = 0; cc < 15; cc++)
- {
- Console::SetCursorPosition(cc,cf);
- switch (mapa1[cf][cc])
- {
- case 0:Console::ForegroundColor = ConsoleColor::DarkRed;cout<<(char)219; break;
- case 1:Console::ForegroundColor = ConsoleColor::Green; cout << (char)219; break;
- case 2:Console::ForegroundColor = ConsoleColor::Blue; break;
- case 3:Console::ForegroundColor = ConsoleColor::Blue; cout << (char)219; break;
- case 4:Console::ForegroundColor = ConsoleColor::Gray; cout << (char)219; break;
- case 5:Console::ForegroundColor = ConsoleColor::DarkGray; cout << (char)219; break;
- case 6:Console::ForegroundColor = ConsoleColor::Yellow; cout << (char)219; break;
- case 7:Console::ForegroundColor = ConsoleColor::Red; cout << (char)219; break;
- case 8:Console::ForegroundColor = ConsoleColor::DarkMagenta; cout << (char)219; break;
- case 9:Console::ForegroundColor = ConsoleColor::DarkGreen; cout << (char)219; break;
- break;
- }
- }
- }
- }
- //key logger
- //derecha=77
- //izquierda=75
- //arriba=72
- //abajo=80
- void borrarP(int x, int y) {
- Console::SetCursorPosition(x, y);
- cout << "";
- }
- int main() {
- char tecla;
- int x = 10;//posicion inicial en x
- int y = 10;//posicion inicial en y
- dibujo();
- for (;tecla!=27;)
- {
- _sleep(40);
- Console::SetCursorPosition(x, y);
- cout << (char)1;
- if (kbhit())//detecta si se pulsa tecla
- {
- //borrarP(x, y);
- tecla = _getch();
- switch ((int)tecla)
- {
- case 77: if (x < 14) {
- ++x; } break;
- case 80:if (y < 14) {
- ++y; } break;
- case 72: if (y > 0) {
- --y; }break;
- case 75: if (x > 0) {
- --x; }break;
- }
- dibujo();
- }
- }
- cin.get();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement