Board.h 828 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #pragma once
  2. #include <vector>
  3. #include "oxygine-framework.h"
  4. #include <vector>
  5. #include "Jewel.h"
  6. using namespace oxygine;
  7. DECLARE_SMART(Jewel, spJewel);
  8. struct space
  9. {
  10. Point pos;
  11. spJewel jewel;
  12. };
  13. class Board
  14. {
  15. public:
  16. Board();
  17. void init(int w, int h);
  18. void free();
  19. spActor getView();
  20. private:
  21. space* getSpace(const Point& pos, bool check = true);
  22. void update(const UpdateState& us);
  23. spTween swap(space& a, space& b);
  24. void touched(Event*);
  25. void swapped(Event*);
  26. void findMatches(std::vector<space*>& spaces, space& sp);
  27. void findMatches(std::vector<space*>& spaces, space& sp, const Point& dir);
  28. spSprite _view;
  29. space* _selected;
  30. spTween _current;
  31. std::vector<space> _field;
  32. Point _size;
  33. };