Advertisement
Guest User

Untitled

a guest
Mar 26th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. /*
  2. ** EPITECH PROJECT, 2019
  3. ** OOP_arcade_2018
  4. ** File description:
  5. ** Vector.hpp
  6. */
  7.  
  8. #ifndef OOP_ARCADE_2018_VECTOR_HPP
  9. #define OOP_ARCADE_2018_VECTOR_HPP
  10.  
  11. #include <zconf.h>
  12.  
  13. template<typename T>
  14. class Vector2 {
  15. public:
  16. Vector2() : x(0), y(0) {
  17. }
  18.  
  19. Vector2(const T &_x, const T &_y) : x(_x), y(_y) {
  20. }
  21.  
  22. template<typename U>
  23. Vector2(const Vector2<U> &vector2)
  24. : x(vector2.x), y(vector2.y) {
  25. }
  26.  
  27. public:
  28. T x;
  29. T y;
  30. };
  31.  
  32. template<typename T>
  33. bool operator==(const Vector2<T> &a, const Vector2<T> &b) {
  34. return a.x == b.x && a.y == b.y;
  35. }
  36.  
  37. template<typename T>
  38. Vector2<T> operator+(const Vector2<T> &a, const Vector2<T> &b) {
  39. return Vector2<T>(a.x + b.x, a.y + b.y);
  40. }
  41.  
  42. template<typename T>
  43. Vector2<T> operator-(const Vector2<T> &a, const Vector2<T> &b) {
  44. return Vector2<T>(a.x - b.x, a.y - b.y);
  45. }
  46.  
  47. using Vector2i = Vector2<int>;
  48. using Vector2u = Vector2<uint>;
  49.  
  50.  
  51. #endif /* !OOP_ARCADE_2018_VECTOR_HPP */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement