123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- #ifndef STARFIELD_H
- #define STARFIELD_H
- #include "door.h"
- #include <random>
- #include <set>
- struct star_pos {
- int x;
- int y;
- int symbol;
- int color;
-
- bool operator<(const star_pos rhs) const {
- if (rhs.y > y)
- return true;
- if (rhs.y == y) {
- if (rhs.x > x)
- return true;
- return false;
- }
- return false;
- }
- };
- class Starfield {
- door::Door &door;
- std::mt19937 &rng;
- std::set<star_pos> sky;
- std::uniform_int_distribution<int> uni_x;
- std::uniform_int_distribution<int> uni_y;
- star_pos make_pos(void);
- door::ANSIColor white;
- door::ANSIColor dark;
- const char *stars[2];
- public:
- Starfield(door::Door &Door, std::mt19937 &Rng);
- void regenerate(void);
- void display(void);
- };
- struct moving_star {
- int x;
- int y;
- int symbol;
- int color;
- bool visible;
- double xpos;
- double ypos;
- double movex;
- double movey;
- };
- typedef std::function<bool(int x, int y)> checkVisibleFunction;
- class AnimatedStarfield {
- door::Door &door;
- std::mt19937 &rng;
- std::vector<moving_star> sky;
- std::uniform_int_distribution<int> uni_x;
- std::uniform_int_distribution<int> uni_y;
- moving_star make_pos(bool centered = false);
- int mx;
- int my;
- double cx;
- double cy;
- double max_d;
- door::ANSIColor white;
- door::ANSIColor dark;
- const char *stars[2];
- double distance(double x, double y);
- checkVisibleFunction visible;
- public:
- AnimatedStarfield(door::Door &door, std::mt19937 &Rng);
- void regenerate(void);
- void display(void);
- void animate(void);
- void setVisible(checkVisibleFunction cvf);
- };
- #endif
|