Advertisement
Guest User

Untitled

a guest
Apr 24th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. class mapa
  2. {
  3. ifstream archivo;
  4. short ** map;
  5. public:
  6. mapa(short nivel)
  7. {
  8. switch (nivel)
  9. {
  10. case 1: archivo.open("niv1.txt"); break;
  11. case 2: archivo.open("niv2.txt"); break;
  12. case 3: archivo.open("niv3.txt"); break;
  13. case 4: archivo.open("niv4.txt"); break;
  14. case 5: archivo.open("niv5.txt"); break;
  15. }
  16. map = new short*[40];
  17. for (short i = 0; i < 40; i++)
  18. {
  19. map[i] = new short[20];
  20. }
  21. if (archivo.is_open())
  22. {
  23. for (short i = 0; i < 20; i++)
  24. {
  25. for (short k = 0; k < 40; k++)
  26. {
  27. archivo >> map[k][i];
  28. }
  29. }
  30. }
  31. }
  32.  
  33. ~mapa()
  34. {
  35. for (short i = 0; i < 20; i++)
  36. {
  37. delete[] map[i];
  38. }
  39. delete[] map;
  40. }
  41. void printmap()
  42. {
  43. for (short i = 0; i < 20; i++)
  44. {
  45. for (short j = 0; j < 40; j++)
  46. {
  47. switch (map[j][i])
  48. {
  49. case 0: cout << " "; break;
  50. case 1: cout << (char)219; break;
  51. case 2: cout << (char)219; break;
  52. }
  53. }
  54. cout << endl;
  55. }
  56. }
  57. bool esCamino(short x, short y)
  58. {
  59. if (this->map[x][y] != 0) return false;
  60. else return true;
  61. }
  62. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement