summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/coord-circle.h
diff options
context:
space:
mode:
authorRobert Vollmert <rvollmert@gmx.net>2009-11-07 17:57:53 +0100
committerRobert Vollmert <rvollmert@gmx.net>2009-11-08 01:41:37 +0100
commitdbb39bdfc8ddc1c4b06b07f09d626791e46ed4bb (patch)
tree28c17990d45da16913eb686c9ddf3b702794287a /crawl-ref/source/coord-circle.h
parentef9199151b8f3e969fc006ad4c52282b44ab8133 (diff)
downloadcrawl-ref-dbb39bdfc8ddc1c4b06b07f09d626791e46ed4bb.tar.gz
crawl-ref-dbb39bdfc8ddc1c4b06b07f09d626791e46ed4bb.zip
Create coord-circle.cc containing circle_def.
circle_def unifies the shapes that a radius_iterator can iterate over. It's meant to replace bounds_func in losparam.h and eventually provide a base for radius_iterator.
Diffstat (limited to 'crawl-ref/source/coord-circle.h')
-rw-r--r--crawl-ref/source/coord-circle.h76
1 files changed, 76 insertions, 0 deletions
diff --git a/crawl-ref/source/coord-circle.h b/crawl-ref/source/coord-circle.h
new file mode 100644
index 0000000000..172e2600b6
--- /dev/null
+++ b/crawl-ref/source/coord-circle.h
@@ -0,0 +1,76 @@
+#ifndef COORD_CIRCLE_H
+#define COORD_CIRCLE_H
+
+#include "coordit.h"
+
+enum shape_type
+{
+ SH_SQUARE, // square around an origin
+ SH_CIRCLE // circle around an origin
+};
+
+enum circle_type
+{
+ C_SQUARE,
+ C_CIRCLE,
+ C_POINTY,
+ C_ROUND
+};
+
+class rect_def
+{
+ coord_def min;
+ coord_def max;
+
+public:
+ rect_def() {}
+ rect_def(const coord_def &min_, const coord_def &max_)
+ : min(min_), max(max_) {}
+
+ rectangle_iterator iter() const;
+};
+
+class circle_iterator;
+class circle_def
+{
+ bool los_radius;
+ shape_type shape;
+
+ coord_def origin;
+ int radius;
+ int radius_sq;
+ rect_def bbox;
+
+public:
+ // Circle around (0,0) with radius that tracks global LOS radius.
+ circle_def();
+ // Circle around (0,0) of specified shape and size.
+ explicit circle_def(int param, circle_type ctype = C_SQUARE);
+ // Circle around given origin of specified shape and size.
+ circle_def(const coord_def &origin_, int param, circle_type ctype = C_SQUARE);
+
+ bool contains(const coord_def &p) const;
+ const rect_def& get_bbox() const;
+
+ circle_iterator iter() const;
+
+private:
+ void init(int param, circle_type ctype);
+};
+
+class circle_iterator
+{
+ const circle_def &circle;
+ rectangle_iterator iter;
+
+public:
+ circle_iterator(const circle_def &circle_);
+
+ operator bool() const;
+ coord_def operator*() const;
+
+ void operator++();
+ void operator++(int);
+};
+
+#endif