• API
• FAQ
• Tools
• Archive
daily pastebin goal
46%
SHARE
TWEET

# Point.h

Archon Oct 4th, 2011 139 Never
ENDING IN00days00hours00mins00secs

1. // (C) 2009, 2010 Tim Gurto
2.
3. #ifndef POINT_H
4. #define POINT_H
5.
6. #include "SDL.h"
7. #include "Types.h"
8.
9. //Simple x and y, with operations to work with
10. //SDL_Rects
11. struct Point{
12.    pixels_t x;
13.    pixels_t y;
14.
15.    Point(const SDL_Rect &original);
16.    Point(pixels_t xCoord = 0, pixels_t yCoord = 0);
17.
18.    //implicit cast to SDL_Rect
19.    operator SDL_Rect();
20.
21.    Point &operator=(const SDL_Rect &rhs);
22.
24.    Point operator+(const Point &rhs) const;
25.    Point &operator+=(const Point &rhs);
26.    Point operator-(const Point &rhs) const;
27.    Point &operator-=(const Point &rhs);
28.
29.    //scalar multiplication
30.    Point operator*(double rhs) const;
31.    Point operator/(double rhs) const;
32.
33.    //comparison with Point
34.    bool operator<(const Point &rhs) const;
35.    bool operator==(const Point &rhs) const;
36.    bool operator!=(const Point &rhs) const;
37.
38.    //comparison with SDL_Rect
39.    bool operator==(const SDL_Rect &rhs) const;
40.
42.    //width and height values of rhs are retained
43.    SDL_Rect operator-(const SDL_Rect &rhs) const;
44.    SDL_Rect operator+(const SDL_Rect &rhs) const;
45. };
46.