Jamie Slowgrove - AI Assignment 1
Line of Sight & A* path-finding
 All Classes Namespaces Files Functions Variables
vec2.h
Go to the documentation of this file.
1 #pragma once
2 
7 struct Vec2
8 {
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 
64  Vec2* operator *= (float a)
65  {
66  x *= a;
67  y *= a;
68  return this;
69  }
70 
76  Vec2* operator /= (float a)
77  {
78  x /= a;
79  y /= a;
80  return this;
81  }
82 };
83 
90 {
91  Vec2 b;
92  b.x = -a.x;
93  b.y = -a.y;
94  return b;
95 }
96 
103 inline Vec2 operator + (Vec2 a, Vec2 b)
104 {
105  Vec2 c;
106  c.x = a.x + b.x;
107  c.y = a.y + b.y;
108  return c;
109 }
110 
117 inline Vec2 operator - (Vec2 a, Vec2 b)
118 {
119  Vec2 c;
120  c.x = a.x - b.x;
121  c.y = a.y - b.y;
122  return c;
123 }
124 
131 inline Vec2 operator / (Vec2 a, float b)
132 {
133  Vec2 c;
134  c.x = a.x / b;
135  c.y = a.y / b;
136  return c;
137 }
138 
145 inline Vec2 operator * (Vec2 a, float b)
146 {
147  Vec2 c;
148  c.x = a.x * b;
149  c.y = a.y * b;
150  return c;
151 }
float x
Definition: vec2.h:10
Vec2()
Definition: vec2.h:17
Vec2 operator/(Vec2 a, float b)
Definition: vec2.h:131
Creates a Vec2 structure with functions Creates a Vec2 structure with overloaded operators to create ...
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:145
Vec2 * operator-=(Vec2 a)
Definition: vec2.h:52
float y
Definition: vec2.h:11
Vec2 * operator*=(float a)
Definition: vec2.h:64
Vec2 operator+(Vec2 a, Vec2 b)
Definition: vec2.h:103
Vec2 operator-(Vec2 a)
Definition: vec2.h:89
Vec2 * operator/=(float a)
Definition: vec2.h:76