Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<conio.h>
- #include<Windows.h>
- #include<stdio.h>
- #include <locale.h>
- using namespace std;
- using namespace System;
- #define ARRIBA 72
- #define IZQUIERDA 75
- #define DERECHA 77
- #define ABAJO 80
- #define CF 25
- #define CC 22
- int dir = 3;
- char tecla;
- void colr(int x)
- {
- HANDLE colr = GetStdHandle(STD_OUTPUT_HANDLE);
- SetConsoleTextAttribute(colr, x);
- }
- void teclear() {
- if (kbhit()) {
- tecla = getch();
- switch (tecla) {
- case ARRIBA: if (dir != 2) dir = 1; break;
- case ABAJO: if (dir != 1) dir = 2; break;
- case DERECHA: if (dir != 4) dir = 3; break;
- case IZQUIERDA: if (dir != 3) dir = 4; break;
- }
- }
- }
- void nivel1()
- {
- int mat[CF][CC] = {
- { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 },
- { 1,1,2,2,1,1,2,2,1,1,2,2,1,1,2,2,1,1,2,2,1,1 },
- { 1,1,2,2,1,1,2,2,1,1,2,2,1,1,2,2,1,1,2,2,1,1 },
- { 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 },
- { 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 },
- { 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 },
- { 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 },
- { 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 },
- { 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 },
- { 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 },
- { 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 },
- { 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 },
- { 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 },
- { 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 },
- { 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 },
- { 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4 },
- { 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4 },
- { 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4 },
- { 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4 },
- { 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4 },
- { 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4 },
- { 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4 },
- { 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4 },
- { 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 },
- { 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 } };
- for (int i = 0; i < CF; i++)
- {
- for (int j = 0; j <CC; j++)
- {
- switch (mat[i][j])
- {
- case 0:
- Console::SetCursorPosition(j, i);
- Console::BackgroundColor = ConsoleColor::White;
- cout << " ";
- break;
- case 1:
- colr(34);
- cout << " ";
- break;
- case 2:
- Console::SetCursorPosition(j, i);
- Console::BackgroundColor = ConsoleColor::Cyan;
- cout << " ";
- break;
- case 3:
- Console::SetCursorPosition(j, i);
- Console::BackgroundColor = ConsoleColor::DarkRed;
- cout << " ";
- break;
- case 4:
- Console::SetCursorPosition(j, i);
- Console::BackgroundColor = ConsoleColor::Gray;
- cout << " ";
- break;
- }
- }
- cout << endl;
- }
- }
- void nivel2()
- {
- int mat[CF][CC] = { { 1,1,1,1,1,1,1,1,1,1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3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 },
- { 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 },
- { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 },
- { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 } };
- for (int i = 0; i < CF; i++)
- {
- for (int j = 0; j <CC; j++)
- {
- switch (mat[i][j])
- {
- case 0:
- Console::SetCursorPosition(j, i);
- Console::BackgroundColor = ConsoleColor::White;
- cout << " ";
- break;
- case 1:
- colr(34);
- cout << " ";
- break;
- case 2:
- Console::SetCursorPosition(j, i);
- Console::BackgroundColor = ConsoleColor::Cyan;
- cout << " ";
- break;
- case 3:
- Console::SetCursorPosition(j, i);
- Console::BackgroundColor = ConsoleColor::Gray;
- cout << " ";
- break;
- }
- }
- cout << endl;
- }
- }
- void nivel3()
- {
- int mat[CF][CC] = { { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 },
- { 1,1,2,2,1,1,2,2,1,1,2,2,1,1,2,2,1,1,2,2,1,1 },
- { 1,1,2,2,1,1,2,2,1,1,2,2,1,1,2,2,1,1,2,2,1,1 },
- { 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 },
- { 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 },
- { 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 },
- { 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 },
- { 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 },
- { 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 },
- { 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 },
- { 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4 },
- { 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4 },
- { 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4 },
- { 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4 },
- { 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4 },
- { 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4 },
- { 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 },
- { 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 },
- { 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 },
- { 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 },
- { 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 },
- { 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 },
- { 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 },
- { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 },
- { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 } };
- for (int i = 0; i < CF; i++)
- {
- for (int j = 0; j <CC; j++)
- {
- switch (mat[i][j])
- {
- case 0:
- Console::SetCursorPosition(j, i);
- Console::BackgroundColor = ConsoleColor::White;
- cout << " ";
- break;
- case 1:
- colr(34);
- cout << " ";
- break;
- case 2:
- Console::SetCursorPosition(j, i);
- Console::BackgroundColor = ConsoleColor::Cyan;
- cout << " ";
- break;
- case 3:
- Console::SetCursorPosition(j, i);
- Console::BackgroundColor = ConsoleColor::Gray;
- cout << " ";
- break;
- case 4:
- colr(106);
- cout << " ";
- break;
- }
- }
- cout << endl;
- }
- }
- void nivel4()
- {
- int mat[CF][CC] = { { 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},
- { 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4 },
- { 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4 },
- { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 },
- { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 } };
- for (int i = 0; i < CF; i++)
- {
- for (int j = 0; j <CC; j++)
- {
- switch (mat[i][j])
- {
- case 0:
- Console::SetCursorPosition(j, i);
- Console::BackgroundColor = ConsoleColor::White;
- cout << " ";
- break;
- case 1:
- colr(34);
- cout << " ";
- break;
- case 2:
- Console::SetCursorPosition(j, i);
- Console::BackgroundColor = ConsoleColor::Cyan;
- cout << " ";
- break;
- case 3:
- colr(106);
- cout << " ";
- break;
- case 4:
- Console::SetCursorPosition(j, i);
- Console::BackgroundColor = ConsoleColor::Gray;
- cout << " ";
- break;
- case 5:
- Console::SetCursorPosition(j, i);
- Console::BackgroundColor = ConsoleColor::DarkMagenta;
- cout << " ";
- break;
- case 6:
- Console::SetCursorPosition(j, i);
- Console::BackgroundColor = ConsoleColor::Yellow;
- cout << " ";
- break;
- }
- }
- cout << endl;
- }
- }
- void nivel5()
- {
- int mat[CF][CC] = { { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 },
- { 1,1,2,2,1,1,2,2,1,1,2,2,1,1,2,2,1,1,2,2,1,1 },
- { 1,1,2,2,1,1,2,2,1,1,2,2,1,1,2,2,1,1,2,2,1,1 },
- { 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 },
- { 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 },
- { 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 },
- { 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 },
- { 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 },
- { 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 },
- { 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 },
- { 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 },
- { 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 },
- { 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 },
- { 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 },
- { 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 },
- { 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 },
- { 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 },
- { 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 },
- { 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 },
- { 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 },
- { 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 },
- { 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 },
- { 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 },
- { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 },
- { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 } };
- for (int i = 0; i < CF; i++)
- {
- for (int j = 0; j <CC; j++)
- {
- switch (mat[i][j])
- {
- case 0:
- Console::SetCursorPosition(j, i);
- Console::BackgroundColor = ConsoleColor::White;
- cout << " ";
- break;
- case 1:
- colr(34);
- cout << " ";
- break;
- case 2:
- Console::SetCursorPosition(j, i);
- Console::BackgroundColor = ConsoleColor::Cyan;
- cout << " ";
- break;
- case 3:
- Console::SetCursorPosition(j, i);
- Console::BackgroundColor = ConsoleColor::Gray;
- cout << " ";
- break;
- }
- }
- cout << endl;
- }
- }
- void main()
- {
- int level;
- //BIENVENIDA();
- cout << "escoja nivel:" << endl;
- cout << "1) primer nivel" << endl;
- cout << "2) segundo nivel" << endl;
- cout << "3) tercer nivel" << endl;
- cout << "4) cuarto nivel" << endl;
- cout << "5) quinto nivel" << endl;
- cout << endl;
- cin >> level;
- switch (level)
- {
- case 1:
- Console::Clear();
- nivel1();
- break;
- case 2:
- Console::Clear();
- nivel2();
- break;
- case 3:
- Console::Clear();
- nivel3();
- break;
- case 4:
- Console::Clear();
- nivel4();
- break;
- case 5:
- Console::Clear();
- nivel5();
- break;
- }
- _getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement