starfield.h 693 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #include "door.h"
  2. #include <random>
  3. #include <set>
  4. struct star_pos {
  5. int x;
  6. int y;
  7. /**
  8. * @brief Provide less than operator.
  9. *
  10. * This will allow the star_pos to be stored sorted (top->bottom,
  11. * left->right) in a set.
  12. *
  13. * @param rhs
  14. * @return true
  15. * @return false
  16. */
  17. bool operator<(const star_pos rhs) const {
  18. if (rhs.y > y)
  19. return true;
  20. if (rhs.y == y) {
  21. if (rhs.x > x)
  22. return true;
  23. return false;
  24. }
  25. return false;
  26. }
  27. };
  28. class starfield {
  29. door::Door &door;
  30. std::mt19937 &rng;
  31. std::set<star_pos> sky;
  32. public:
  33. starfield(door::Door &Door, std::mt19937 &Rng);
  34. void regenerate(void);
  35. void display(void);
  36. };