2D_Game_Engine
Loading...
Searching...
No Matches
structs.cpp
Go to the documentation of this file.
1#include <pch.hpp>
2#include <structs.hpp>
3
4Vec2::Vec2(): x(0),y(0){}
5Vec2::Vec2(float x,float y): x(x),y(y){}
6
7Vec3::Vec3(): r(0),g(0),b(0){}
8Vec3::Vec3(float r,float g,float b): r(r),g(g),b(b){}
9
10Vec4::Vec4(): r(0),g(0),b(0),a(0){}
11Vec4::Vec4(float r,float g,float b,float a): r(r),g(g),b(b),a(a){}
12
13TriangleVertex::TriangleVertex(): position(Vec2()),color(Vec4()),layer(0){}
14TriangleVertex::TriangleVertex(Vec2 pos,Vec4 color,int layer): position(pos),color(color),layer(layer){}
15
16LineVertex::LineVertex(): pos(Vec2()),color(Vec4()),layer(0){}
17LineVertex::LineVertex(Vec2 pos,Vec4 color,int layer): pos(pos),color(color),layer(layer){}
18
19PointVertex::PointVertex(): pos(Vec2()),color(Vec4()),layer(0){}
20PointVertex::PointVertex(Vec2 pos,Vec4 color,float border,int layer): pos(pos),color(color),border(border),layer(layer){}
21
22Vertex::Vertex(): position(Vec2()),texcoords(Vec2()),layer(0),texID(0){}
23Vertex::Vertex(Vec2 pos,Vec2 texcoords,int layer,float texID): position(pos),texcoords(texcoords),layer(layer),texID(texID){}
24
26 return {a.x+b.x,a.y+b.y};
27}
28
30 return {a.x-b.x,a.y-b.y};
31}
32
34 return {a.x*b.x,a.y*b.y};
35}
36
37Vec2 operator*(float a,Vec2 b){
38 return {a*b.x,a*b.y};
39}
40
41Vec2 operator*(Vec2 a,float b){
42 return {a.x*b,a.y*b};
43}
44
46 return {a.x/b.x,a.y/b.y};
47}
48
49Vec2 operator/(float a,Vec2 b){
50 return {a/b.x,a/b.y};
51}
52
54 return {a.x/b,a.y/b};
55}
56
57Rect::Rect(): pos(Vec2()),size(Vec2()),vel(Vec2()){}
58Rect::Rect(Vec2 pos,Vec2 size,Vec2 vel): pos(pos),size(size),vel(vel){}
59
60std::ostream &operator<<(std::ostream &os,const Vec2 &v){
61 os<<"["<<v.x<<","<<v.y<< "]";
62 return os;
63}
64
65std::ostream &operator<<(std::ostream &os,const Vec3 &v){
66 os<<"["<<v.r<<","<<v.g<<","<<v.b<< "]";
67 return os;
68}
69
70std::ostream &operator<<(std::ostream &os,const Vec4 &v){
71 os<<"["<<v.r<<","<<v.g<<","<<v.b<<","<<v.a<< "]";
72 return os;
73}
74
75std::ostream &operator<<(std::ostream &os,const Vertex &v){
76 os<<"Position: "<<v.position<<" Texcoords: "<<v.texcoords<<" Layer: "<<v.layer<<" TexID: "<<v.texID;
77 return os;
78}
79
80std::ostream &operator<<(std::ostream &os,const LineVertex &v){
81 os<<"Position: "<<v.pos<<" Color: "<<v.color<<" Layer: "<<v.layer;
82 return os;
83}
84
85std::ostream &operator<<(std::ostream &os,const PointVertex &v){
86 os<<"Position: "<<v.pos<<" Color: "<<v.color<<" Border: "<<v.border<<" Layer: "<<v.layer;
87 return os;
88}
89
90std::ostream &operator<<(std::ostream &os,const TriangleVertex &v){
91 os<<"Position: "<<v.position<<" Color: "<<v.color<<" Layer: "<<v.layer;
92 return os;
93}
94
95std::ostream &operator<<(std::ostream &os,const Rect &v){
96 os<<"Position: "<<v.pos<<" Size: "<<v.size<<" Velocity: "<<v.vel;
97 return os;
98}
Vec4 color
Definition structs.hpp:40
float border
Definition structs.hpp:50
Vec2 size
Definition structs.hpp:76
Vec2 pos
Definition structs.hpp:75
Rect()
Definition structs.cpp:57
Vec2 vel
Definition structs.hpp:77
float y
Definition structs.hpp:9
Vec2()
Definition structs.cpp:4
float x
Definition structs.hpp:5
float b
Definition structs.hpp:17
float r
Definition structs.hpp:17
float g
Definition structs.hpp:17
Vec3()
Definition structs.cpp:7
float g
Definition structs.hpp:23
float b
Definition structs.hpp:23
float a
Definition structs.hpp:23
Vec4()
Definition structs.cpp:10
float r
Definition structs.hpp:23
float texID
Definition structs.hpp:32
Vec2 position
Definition structs.hpp:29
Vertex()
Definition structs.cpp:22
Vec2 texcoords
Definition structs.hpp:30
int layer
Definition structs.hpp:31
Vec2 operator-(Vec2 a, Vec2 b)
Definition structs.cpp:29
Vec2 operator*(Vec2 a, Vec2 b)
Definition structs.cpp:33
Vec2 operator/(Vec2 a, Vec2 b)
Definition structs.cpp:45
std::ostream & operator<<(std::ostream &os, const Vec2 &v)
Definition structs.cpp:60
Vec2 operator+(Vec2 a, Vec2 b)
Definition structs.cpp:25