Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ConsoleApplication6.cpp : main project file.
- #include "stdafx.h"
- #include <conio.h>
- #include <iostream>
- using namespace std;
- using namespace System;
- void genera_muestra_matrix(int Matriz[][23])
- {
- for (int i = 0; i < 20; i++)
- {
- for (int j = 0;j < 23; j++)
- {
- switch (Matriz[i][j])
- {
- case 0:Console::BackgroundColor = ConsoleColor::DarkRed;
- Console::ForegroundColor = ConsoleColor::White;
- cout << (char)22;break;
- case 1:
- Console::BackgroundColor = ConsoleColor::White;
- Console::ForegroundColor = ConsoleColor::Black;
- cout << (char)219;break;
- }
- }cout << endl;
- }
- }
- void desplazar_movil_y_enemigo(int Matrix[][23], int my, int mx)
- {
- int tecla, my, mx;
- int my = 8; mx = 10;
- int ex = 19, ey = 6, dey = 1;
- Console::SetCursorPosition(ex, ey);
- Console::BackgroundColor = ConsoleColor::Black;
- cout << (char)1;
- while (1)
- {
- if (kbhit())
- {
- tecla = _getch();
- if (tecla == 224)
- {
- Console::SetCursorPosition(mx, my);
- cout << " ";
- tecla = _getch();
- switch (tecla)
- {
- case 77:mx++; if (Matrix[my][mx] == 0)
- Console::SetCursorPosition(mx, my);break;
- case 75:mx--; if (Matrix[my][mx]==0)
- Console::SetCursorPosition(mx, my);break;
- case 72:my--; if (Matrix[my][mx] == 0)
- Console::SetCursorPosition(mx, my);break;
- case 80:my++; if (Matrix[my][mx] == 0)
- Console::SetCursorPosition(mx, my);break;
- }
- }Console::SetCursorPosition(mx, my);cout << '*';
- }
- _sleep(75);
- Console::SetCursorPosition(ex, ey);
- cout << ' ';
- if (ey == 3 || ey == 8)
- dey *= -1;
- ey += dey;
- Console::SetCursorPosition(ex, ey);
- cout << (char)1;
- }
- }
- int main()
- {
- int Matrix[20][23]=
- {
- { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
- { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
- { 0,0,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