diff options
author | Simponic <loganthebean222@gmail.com> | 2020-08-13 12:07:52 -0600 |
---|---|---|
committer | Simponic <loganthebean222@gmail.com> | 2020-08-13 12:07:52 -0600 |
commit | d8b164e4727c887979d4da6a4011a444749862fc (patch) | |
tree | 63ae5ebfab9c1e438c0c2ccc97668e3ab809bdbd /include/point.h | |
parent | 40a568c50224c2832aeb13bd469d714d126118e1 (diff) | |
download | asteroids-cs165-d8b164e4727c887979d4da6a4011a444749862fc.tar.gz asteroids-cs165-d8b164e4727c887979d4da6a4011a444749862fc.zip |
Better file structure, stuff is better in general
Diffstat (limited to 'include/point.h')
-rw-r--r-- | include/point.h | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/include/point.h b/include/point.h new file mode 100644 index 0000000..7f0715f --- /dev/null +++ b/include/point.h @@ -0,0 +1,49 @@ +/*********************************************************************** + * 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); } + + bool inRange ( const Point &p , const float range ); +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 |