Advertisement
Deerenaros

Labirint generator interface.

May 4th, 2012
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.01 KB | None | 0 0
  1. #include <utility>
  2. #include <cstdlib>
  3.  
  4. #define BIN__N(x) (x) | x>>3 | x>>6 | x>>9
  5. #define BIN__B(x) (x) & 0xf | (x)>>12 & 0xf0
  6.  
  7. #define BIN8(v) (BIN__B(BIN__N(0x##v)))
  8.  
  9. class labirint;
  10.  
  11. class room{
  12. private:
  13.     friend labirint;
  14.     int m_x;
  15.     int m_y;
  16.     int m_n;
  17.     int m_magicnumber;
  18.     int __mnum;
  19.     int __startfinish; //0 - nothing, 1 - start, 2 - finish
  20.     bool _vis;
  21.     bool m_way;
  22.     room *__backroom;
  23. public:
  24.     room(unsigned x, unsigned y);
  25.     bool left();    //3
  26.     bool right();   //1
  27.     bool up();      //0
  28.     bool down();    //2
  29.     bool start();
  30.     bool finish();
  31.    
  32.     bool way();
  33.    
  34.     std::pair<int, int> getcoords();
  35. };
  36.  
  37.  
  38. class labirint{
  39. private:
  40.     friend room;
  41.     int m_wayweight;
  42.     room* m_rooms;
  43.     room* m_start;
  44.     room* m_finish;
  45.     room* __getroom(int x, int y, unsigned k);
  46.     room* __getroom(unsigned x, unsigned y);
  47.     std::pair<int, int> m_size;
  48.     void __restoreway(room *r);
  49. public:
  50.     labirint(int width, int heigth);
  51.     ~labirint();
  52.    
  53.     void generate(unsigned x, unsigned y);
  54.     room getroom(unsigned x, unsigned y);
  55. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement