Fireworks Engine  v2.0
Lightweight Sandbox Game Engine using OpenGL for additional Customisation and Quick Prototyping
vec2.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <iostream>
4 
5 namespace fireworks { namespace maths {
6 
7  struct vec2
8  {
9  float x, y;
10 
11  vec2();
12  vec2(const float& x, const float& y);
13 
14  vec2& add(const vec2& other);
15  vec2& subtract(const vec2& other);
16  vec2& mutiply(const vec2& other);
17  vec2& divide(const vec2& other);
18 
19  /*
20  * friend because we are passing the left and right explicitly and not using
21  * this pointer we don't want to pass in the this pointer to the function hence
22  * we mark them as non-member friend and still give it access to the private members
23  */
24  friend vec2 operator+(vec2 left, const vec2& right);
25  friend vec2 operator-(vec2 left, const vec2& right);
26  friend vec2 operator*(vec2 left, const vec2& right);
27  friend vec2 operator/(vec2 left, const vec2& right);
28 
29  bool operator==(const vec2& other);
30  bool operator!=(const vec2& other);
31 
32  vec2& operator+=(const vec2& other);
33  vec2& operator-=(const vec2& other);
34  vec2& operator*=(const vec2& other);
35  vec2& operator/=(const vec2& other);
36 
37  friend std::ostream& operator<<(std::ostream& stream, const vec2& vector);
38  };
39 
40 } }
bool operator!=(const vec2 &other)
Definition: vec2.cpp:73
friend vec2 operator*(vec2 left, const vec2 &right)
Definition: vec2.cpp:58
vec2 & divide(const vec2 &other)
Definition: vec2.cpp:40
bool operator==(const vec2 &other)
Definition: vec2.cpp:68
friend vec2 operator/(vec2 left, const vec2 &right)
Definition: vec2.cpp:63
float x
Definition: vec2.h:9
Definition: audioclip.cpp:3
friend std::ostream & operator<<(std::ostream &stream, const vec2 &vector)
Definition: vec2.cpp:98
Definition: vec2.h:7
vec2 & operator*=(const vec2 &other)
Definition: vec2.cpp:88
vec2()
Definition: vec2.cpp:6
float y
Definition: vec2.h:9
vec2 & subtract(const vec2 &other)
Definition: vec2.cpp:26
friend vec2 operator-(vec2 left, const vec2 &right)
Definition: vec2.cpp:53
vec2 & add(const vec2 &other)
Definition: vec2.cpp:18
vec2 & operator-=(const vec2 &other)
Definition: vec2.cpp:83
friend vec2 operator+(vec2 left, const vec2 &right)
Definition: vec2.cpp:48
vec2 & operator+=(const vec2 &other)
Definition: vec2.cpp:78
vec2 & mutiply(const vec2 &other)
Definition: vec2.cpp:33
vec2 & operator/=(const vec2 &other)
Definition: vec2.cpp:93