Jamie Slowgrove - MGP Assignment 2 - JAM
 All Classes Namespaces Files Functions Variables Macros
Vec2.h
Go to the documentation of this file.
1 #pragma once
2 
9 struct JAM_Vec2
10 {
11  /*position variables.*/
12  float x, y;
13 
19  {
20  x = 0;
21  y = 0;
22  }
23 
30  JAM_Vec2(float inputX, float inputY)
31  {
32  x = inputX;
33  y = inputY;
34  }
35 
43  {
44  x += a.x;
45  y += a.y;
46  return this;
47  }
48 
56  {
57  x -= a.x;
58  y -= a.y;
59  return this;
60  }
61 
62 };
63 
71 {
72  JAM_Vec2 b;
73  b.x = -a.x;
74  b.y = -a.y;
75  return b;
76 }
77 
86 {
87  JAM_Vec2 c;
88  c.x = a.x + b.x;
89  c.y = a.y + b.y;
90  return c;
91 }
92 
101 {
102  JAM_Vec2 c;
103  c.x = a.x - b.x;
104  c.y = a.y - b.y;
105  return c;
106 }
107 
115 inline JAM_Vec2 operator / (JAM_Vec2 a, float b)
116 {
117  JAM_Vec2 c;
118  c.x = a.x / b;
119  c.y = a.y / b;
120  return c;
121 }
122 
130 inline JAM_Vec2 operator * (JAM_Vec2 a, float b)
131 {
132  JAM_Vec2 c;
133  c.x = a.x * b;
134  c.y = a.y * b;
135  return c;
136 }
float x
Definition: Vec2.h:12
JAM_Vec2(float inputX, float inputY)
Definition: Vec2.h:30
JAM_Vec2()
Definition: Vec2.h:18
JAM_Vec2 operator/(JAM_Vec2 a, float b)
Definition: Vec2.h:115
JAM_Vec2 operator*(JAM_Vec2 a, float b)
Definition: Vec2.h:130
JAM_Vec2 * operator-=(JAM_Vec2 a)
Definition: Vec2.h:55
JAM_Vec2 operator-(JAM_Vec2 a)
Definition: Vec2.h:70
JAM_Vec2 operator+(JAM_Vec2 a, JAM_Vec2 b)
Definition: Vec2.h:85
JAM_Vec2 * operator+=(JAM_Vec2 a)
Definition: Vec2.h:42
float y
Definition: Vec2.h:12
Creates an Vec2 structure with functions. Creates an Vec2 structure with overloaded operators to crea...
Definition: Vec2.h:9