Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class mapa
- {
- ifstream archivo;
- short ** map;
- public:
- mapa(short nivel)
- {
- switch (nivel)
- {
- case 1: archivo.open("niv1.txt"); break;
- case 2: archivo.open("niv2.txt"); break;
- case 3: archivo.open("niv3.txt"); break;
- case 4: archivo.open("niv4.txt"); break;
- case 5: archivo.open("niv5.txt"); break;
- }
- map = new short*[40];
- for (short i = 0; i < 40; i++)
- {
- map[i] = new short[20];
- }
- if (archivo.is_open())
- {
- for (short i = 0; i < 20; i++)
- {
- for (short k = 0; k < 40; k++)
- {
- archivo >> map[k][i];
- }
- }
- }
- }
- ~mapa()
- {
- for (short i = 0; i < 20; i++)
- {
- delete[] map[i];
- }
- delete[] map;
- }
- void printmap()
- {
- for (short i = 0; i < 20; i++)
- {
- for (short j = 0; j < 40; j++)
- {
- switch (map[j][i])
- {
- case 0: cout << " "; break;
- case 1: cout << (char)219; break;
- case 2: cout << (char)219; break;
- }
- }
- cout << endl;
- }
- }
- bool esCamino(short x, short y)
- {
- if (this->map[x][y] != 0) return false;
- else return true;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement