summaryrefslogtreecommitdiff
path: root/src/point.h
diff options
context:
space:
mode:
authorLogan Hunt <loganthebean222@gmail.com>2020-08-12 14:13:50 -0600
committerLogan Hunt <loganthebean222@gmail.com>2020-08-12 14:13:50 -0600
commit70ea8877ace50d2ce609d7d5f721c887b0ea83ec (patch)
tree514aa4f3d10b0a1db21928f8a002aa10458ecbb5 /src/point.h
parent495f771530ce1869098bc568f34c243697cab73c (diff)
downloadskeet-cs165-70ea8877ace50d2ce609d7d5f721c887b0ea83ec.tar.gz
skeet-cs165-70ea8877ace50d2ce609d7d5f721c887b0ea83ec.zip
Added files
Diffstat (limited to 'src/point.h')
-rw-r--r--src/point.h48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/point.h b/src/point.h
new file mode 100644
index 0000000..545ce17
--- /dev/null
+++ b/src/point.h
@@ -0,0 +1,48 @@
+/***********************************************************************
+ * Header File:
+ * Point : The representation of a position on the screen
+ * Author:
+ * Br. Helfrich
+ * Summary:
+ * Everything we need to know about a location on the screen, including
+ * the location and the bounds.
+ ************************************************************************/
+
+
+#ifndef POINT_H
+#define POINT_H
+
+#include <iostream>
+
+/*********************************************
+ * POINT
+ * A single position.
+ *********************************************/
+class Point
+{
+public:
+ // constructors
+ Point() : x(0.0), y(0.0) {}
+ Point(bool check) : x(0.0), y(0.0) {}
+ Point(float x, float y);
+
+ // getters
+ float getX() const { return x; }
+ float getY() const { return y; }
+
+ // setters
+ void setX(float x);
+ void setY(float y);
+ void addX(float dx) { setX(getX() + dx); }
+ void addY(float dy) { setY(getY() + dy); }
+
+private:
+ float x; // horizontal position
+ float y; // vertical position
+};
+
+// stream I/O useful for debugging
+std::ostream & operator << (std::ostream & out, const Point & pt);
+std::istream & operator >> (std::istream & in, Point & pt);
+
+#endif // POINT_H