BWAPI 4.2.0 An API for interacting with Starcraft: Broodwar (1.16.1) |
Public Types | |
typedef std::deque< Point< T, Scale > > | list |
Public Member Functions | |
Point ()=default | |
Point (T _x, T _y) | |
template<typename FromT > | |
Point (const Point< FromT, Scale > &pt) | |
template<typename FromT , int FromScale> | |
Point (const Point< FromT, FromScale > &pt) | |
int | getApproxDistance (const Point< T, Scale > &position) const |
double | getDistance (const Point< T, Scale > &position) const |
double | getLength () const |
bool | isValid () const |
Point & | makeValid () |
operator bool () const | |
bool | operator!= (const Point< T, Scale > &pos) const |
Point< T, Scale > | operator% (const T &v) const |
Point< T, Scale > & | operator%= (const T &val) |
Point< T, Scale > | operator& (const T &v) const |
Point< T, Scale > & | operator&= (const T &v) |
Point< T, Scale > | operator* (const T &v) const |
Point< T, Scale > & | operator*= (const T &v) |
Point< T, Scale > | operator+ (const Point< T, Scale > &p) const |
Point< T, Scale > & | operator+= (const Point< T, Scale > &p) |
Point< T, Scale > | operator- (const Point< T, Scale > &p) const |
Point< T, Scale > & | operator-= (const Point< T, Scale > &p) |
Point< T, Scale > | operator/ (const T &v) const |
Point< T, Scale > & | operator/= (const T &val) |
bool | operator< (const Point< T, Scale > &position) const |
bool | operator== (const Point< T, Scale > &pos) const |
Point< T, Scale > | operator^ (const T &v) const |
Point< T, Scale > & | operator^= (const T &v) |
Point< T, Scale > | operator| (const T &v) const |
Point< T, Scale > & | operator|= (const T &v) |
Point & | setMax (T max_x, T max_y) |
Point & | setMax (const Point< T, Scale > &max) |
Point & | setMin (T min_x, T min_y) |
Point & | setMin (const Point< T, Scale > &min) |
Public Attributes | |
T | x = T{} |
T | y = T{} |
Friends | |
std::ostream & | operator<< (std::ostream &os, const Point< T, Scale > &pt) |
std::wostream & | operator<< (std::wostream &os, const Point< T, Scale > &pt) |
std::istream & | operator>> (std::istream &in, Point< T, Scale > &pt) |
std::wistream & | operator>> (std::wistream &in, Point< T, Scale > &pt) |
The Point class is a base class that implements convenience members and performs conversions for several different position scales.
It is intended to be inherited or typedef'd for use with BWAPI. Users can extend the Point class, and implement their own members, and it will remain compatible with BWAPI.
T | The underlying type of the x and y values. BWAPI uses int. |
Scale | The underlying scale that this is intended to be used for. The smaller this value, the higher the precision. A value of 1 indicates the pixel level. |
Consider the following:
It then follows that this code will work without incident:
T
must have a precision of at least 16 bits and Scale
must be a factor of 32. Referenced by BWAPI::Point< T, Scale >::Point().
A copy constructor for positions with different underlying types.
pt | The Point to receive data from. |
FromT | The type being converted to type T. |
References BWAPI::Point< T, Scale >::Point(), BWAPI::Point< T, Scale >::x, and BWAPI::Point< T, Scale >::y.
A conversion copy constructor to convert positions of different scales to one another.
FromT | The type that it is converting from. |
FromScale | The scale that it is converting from. |
A convenience for use with if statements to identify if a position is valid.
References BWAPI::Point< T, Scale >::isValid().
References std::tie(), BWAPI::Point< T, Scale >::x, and BWAPI::Point< T, Scale >::y.
A less than operator that enables positions to be used by additional STL containers.
Compares lexicographically the x position, followed by the y position.
References std::tie(), BWAPI::Point< T, Scale >::x, and BWAPI::Point< T, Scale >::y.
References BWAPI::Point< T, Scale >::x, and BWAPI::Point< T, Scale >::y.
References BWAPI::Point< T, Scale >::x, and BWAPI::Point< T, Scale >::y.
References BWAPI::Point< T, Scale >::x, and BWAPI::Point< T, Scale >::y.
References BWAPI::Point< T, Scale >::x, and BWAPI::Point< T, Scale >::y.
References BWAPI::Point< T, Scale >::x, and BWAPI::Point< T, Scale >::y.
References BWAPI::Point< T, Scale >::x, and BWAPI::Point< T, Scale >::y.
References BWAPI::Point< T, Scale >::x, and BWAPI::Point< T, Scale >::y.
References BWAPI::Point< T, Scale >::x, and BWAPI::Point< T, Scale >::y.
Checks if this point is within the game's map bounds.
true | If it is a valid position and on the map/playing field. |
false | If this is not a valid position. |
Referenced by BWAPI::Point< T, Scale >::operator bool().
Checks if this point is within the game's map bounds, if not, then it will set the x and y values to be within map bounds.
For example, if x is less than 0, then x is set to 0.
Gets an accurate distance measurement from this point to the given position.
position | The target position to get the distance to. |
position
. Gets the length of this point from the top left corner of the map.
References BWAPI::Point< T, Scale >::x, and BWAPI::Point< T, Scale >::y.
Retrieves the approximate distance using an algorithm from Starcraft: Broodwar.
position | The target point to measure the distance to. |
position
. References std::swap(), BWAPI::Point< T, Scale >::x, and BWAPI::Point< T, Scale >::y.
Sets the maximum x and y values.
If the current x or y values exceed the given maximum, then values are set to the maximum.
max_x | Maximum x value. |
max_y | Maximum y value. |
References BWAPI::Point< T, Scale >::x, and BWAPI::Point< T, Scale >::y.
Referenced by BWAPI::Point< T, Scale >::setMax().
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
References BWAPI::Point< T, Scale >::setMax().
Sets the minimum x and y values.
If the current x or y values are below the given minimum, then values are set to the minimum.
min_x | Minimum x value. |
min_y | Minimum y value. |
References BWAPI::Point< T, Scale >::x, and BWAPI::Point< T, Scale >::y.
Referenced by BWAPI::Point< T, Scale >::setMin().
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
References BWAPI::Point< T, Scale >::setMin().
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Input stream operator overload.
Reads the input in the form "x y" without quotations.
The x and y values are read as type T(typically int or float) and stored into pt.
in | The input stream. |
pt | The receiving variable. |
in
. This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
The x and y members for this class.
Simply reference these members when retrieving a position's x and y values.
Referenced by BWAPI::Point< T, Scale >::getApproxDistance(), BWAPI::Point< T, Scale >::getLength(), BWAPI::Point< T, Scale >::operator%=(), BWAPI::Point< T, Scale >::operator&=(), BWAPI::Point< T, Scale >::operator*=(), BWAPI::Point< T, Scale >::operator+=(), BWAPI::Point< T, Scale >::operator-=(), BWAPI::Point< T, Scale >::operator/=(), BWAPI::Point< T, Scale >::operator<(), BWAPI::Point< T, Scale >::operator==(), BWAPI::Point< T, Scale >::operator^=(), BWAPI::Point< T, Scale >::operator|=(), BWAPI::Point< T, Scale >::Point(), BWAPI::Point< T, Scale >::setMax(), and BWAPI::Point< T, Scale >::setMin().
Referenced by BWAPI::Point< T, Scale >::getApproxDistance(), BWAPI::Point< T, Scale >::getLength(), BWAPI::Point< T, Scale >::operator%=(), BWAPI::Point< T, Scale >::operator&=(), BWAPI::Point< T, Scale >::operator*=(), BWAPI::Point< T, Scale >::operator+=(), BWAPI::Point< T, Scale >::operator-=(), BWAPI::Point< T, Scale >::operator/=(), BWAPI::Point< T, Scale >::operator<(), BWAPI::Point< T, Scale >::operator==(), BWAPI::Point< T, Scale >::operator^=(), BWAPI::Point< T, Scale >::operator|=(), BWAPI::Point< T, Scale >::Point(), BWAPI::Point< T, Scale >::setMax(), and BWAPI::Point< T, Scale >::setMin().