Sky Zone Omega - PC Version
 All Classes Namespaces Files Functions Variables Macros
C_Vec2.h
Go to the documentation of this file.
1 #pragma once
2 
7 struct C_Vec2
8 {
10  float x, y;
11 
15  C_Vec2() : x(0.0f), y(0.0f){}
16 
22  C_Vec2(float x, float y) : x(x), y(y){}
23 
29  C_Vec2(int x, int y) : x((float)x), y((float)y){}
30 
37  {
38  x += vecIn.x;
39  y += vecIn.y;
40  return this;
41  }
42 
49  {
50  x -= vecIn.x;
51  y -= vecIn.y;
52  return this;
53  }
54 };
55 
61 inline C_Vec2 operator - (C_Vec2 vecIn)
62 {
63  C_Vec2 vecOut;
64  vecOut.x = -vecIn.x;
65  vecOut.y = -vecIn.y;
66  return vecOut;
67 }
68 
75 inline C_Vec2 operator - (C_Vec2 vecInA, C_Vec2 vecInB)
76 {
77  C_Vec2 vecOut;
78  vecOut.x = vecInA.x - vecInB.x;
79  vecOut.y = vecInA.y - vecInB.y;
80  return vecOut;
81 }
82 
89 inline C_Vec2 operator + (C_Vec2 vecInA, C_Vec2 vecInB)
90 {
91  C_Vec2 vecOut;
92  vecOut.x = vecInA.x + vecInB.x;
93  vecOut.y = vecInA.y + vecInB.y;
94  return vecOut;
95 }
96 
103 inline C_Vec2 operator / (C_Vec2 vecInA, float scalar)
104 {
105  C_Vec2 vecOut;
106  vecOut.x = vecInA.x / scalar;
107  vecOut.y = vecInA.y / scalar;
108  return vecOut;
109 }
110 
117 inline C_Vec2 operator * (C_Vec2 vecInA, float scalar)
118 {
119  C_Vec2 vecOut;
120  vecOut.x = vecInA.x * scalar;
121  vecOut.y = vecInA.y * scalar;
122  return vecOut;
123 }
124 
131 inline C_Vec2 operator * (C_Vec2 vecInA, C_Vec2 vecInB)
132 {
133  C_Vec2 vecOut;
134  vecOut.x = vecInA.x * vecInB.x;
135  vecOut.y = vecInA.y * vecInB.y;
136  return vecOut;
137 }
C_Vec2 * operator-=(C_Vec2 vecIn)
Overloads the -= operator.
Definition: C_Vec2.h:48
C_Vec2(int x, int y)
Constructs the Vec2 setting the values to the input coordinates.
Definition: C_Vec2.h:29
C_Vec2 * operator+=(C_Vec2 vecIn)
Overloads the += operator.
Definition: C_Vec2.h:36
float y
Definition: C_Vec2.h:10
Contains the Vec2 structure with functions and overloaded operators.
Definition: C_Vec2.h:7
C_Vec2()
Constructs the Vec2 setting the values to 0,0.
Definition: C_Vec2.h:15
C_Vec2 operator/(C_Vec2 vecInA, float scalar)
Overloads the / operator allowing a Vec2 to be divided by a scalar.
Definition: C_Vec2.h:103
C_Vec2 operator*(C_Vec2 vecInA, float scalar)
Overloads the * operator allowing a Vec2 to be multiplied by a scalar.
Definition: C_Vec2.h:117
float x
Position variables.
Definition: C_Vec2.h:10
C_Vec2(float x, float y)
Constructs the Vec2 setting the values to the input coordinates.
Definition: C_Vec2.h:22
C_Vec2 operator+(C_Vec2 vecInA, C_Vec2 vecInB)
Overloads the + operator.
Definition: C_Vec2.h:89
C_Vec2 operator-(C_Vec2 vecIn)
Overloads the - operator allowing a Vec2 to be inverted.
Definition: C_Vec2.h:61