Flock You!
 All Classes Files Functions Variables
vec2.h
Go to the documentation of this file.
1 #pragma once
2 
7 struct Vec2
8 {
9  /*position variables*/
10  float x;
11  float y;
12 
17  Vec2()
18  {
19  x = 0;
20  y = 0;
21  }
22 
29  Vec2(float inputX, float inputY)
30  {
31  x = inputX;
32  y = inputY;
33  }
34 
41  {
42  x += a.x;
43  y += a.y;
44  return this;
45  }
46 
53  {
54  x -= a.x;
55  y -= a.y;
56  return this;
57  }
58 
59 };
60 
67 {
68  Vec2 b;
69  b.x = -a.x;
70  b.y = -a.y;
71  return b;
72 }
73 
80 inline Vec2 operator + (Vec2 a, Vec2 b)
81 {
82  Vec2 c;
83  c.x = a.x + b.x;
84  c.y = a.y + b.y;
85  return c;
86 }
87 
94 inline Vec2 operator - (Vec2 a, Vec2 b)
95 {
96  Vec2 c;
97  c.x = a.x - b.x;
98  c.y = a.y - b.y;
99  return c;
100 }
101 
108 inline Vec2 operator / (Vec2 a, float b)
109 {
110  Vec2 c;
111  c.x = a.x / b;
112  c.y = a.y / b;
113  return c;
114 }
115 
122 inline Vec2 operator * (Vec2 a, float b)
123 {
124  Vec2 c;
125  c.x = a.x * b;
126  c.y = a.y * b;
127  return c;
128 }
float x
Definition: vec2.h:10
Vec2()
Definition: vec2.h:17
Vec2 operator/(Vec2 a, float b)
Definition: vec2.h:108
Creates an Vec2 structure with functions Creates an Vec2 structure with overloaded operators to creat...
Definition: vec2.h:7
Vec2 * operator+=(Vec2 a)
Definition: vec2.h:40
Vec2(float inputX, float inputY)
Definition: vec2.h:29
Vec2 operator*(Vec2 a, float b)
Definition: vec2.h:122
Vec2 * operator-=(Vec2 a)
Definition: vec2.h:52
float y
Definition: vec2.h:11
Vec2 operator+(Vec2 a, Vec2 b)
Definition: vec2.h:80
Vec2 operator-(Vec2 a)
Definition: vec2.h:66