daily pastebin goal
9%
SHARE
TWEET

Point.h

Archon Oct 4th, 2011 139 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.  
  23.    //addition/subtraction with other Points
  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.  
  41.    //addition/subtraction with SDL_Rects
  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.  
  47. //addition/subtraction with SDL_Rects, reversed
  48. SDL_Rect operator+(SDL_Rect lhs, const Point &rhs);
  49. SDL_Rect operator-(SDL_Rect lhs, const Point &rhs);
  50.  
  51. //comparison with SDL_Rect, reversed
  52. bool operator==(const SDL_Rect &lhs, const Point &rhs);
  53.  
  54. #endif
  55.  
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top