home *** CD-ROM | disk | FTP | other *** search
/ Game.EXE 2002 May / Game.EXE_05_2002.iso / Alawar / Lib / 2D / Place2D.h < prev    next >
Encoding:
C/C++ Source or Header  |  2002-02-25  |  675 b   |  42 lines

  1. #ifndef __PLACE2D_H__
  2. #define __PLACE2D_H__
  3.  
  4. struct Place2D
  5. {
  6.     double x;
  7.     double y;
  8.     Place2D()
  9.     {}
  10.     Place2D(const Place2D & p)
  11.         :    x( p.x ),
  12.             y( p.y )
  13.     {}
  14.     Place2D(double x, double y)
  15.         :    x( x ),
  16.             y( y )
  17.     {}
  18.     const Place2D & operator+=(const Place2D & pl)
  19.     {
  20.         x += pl.x;
  21.         y += pl.y;
  22.         return *this;
  23.     }
  24.     const Place2D & operator-=(const Place2D & pl)
  25.     {
  26.         x -= pl.x;
  27.         y -= pl.y;
  28.         return *this;
  29.     }
  30. };
  31.  
  32. inline Place2D operator+ (const Place2D & pl1, const Place2D & pl2)
  33. {
  34.     return Place2D(pl1) += pl2;
  35. }
  36.  
  37. inline Place2D operator- (const Place2D & pl1, const Place2D & pl2)
  38. {
  39.     return Place2D(pl1) -= pl2;
  40. }
  41.  
  42. #endif //__PLACE2D_H__