-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathComponent.h
More file actions
53 lines (44 loc) · 1.31 KB
/
Component.h
File metadata and controls
53 lines (44 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "vectors.h"
#include "sprite.h"
#include <unordered_set>
class Rectangle2d;
class Circle2d;
class Component { // ALL COMPONENTS MUST INHERIT THIS CLASS OR NOT COMPATIBLE WITH GAMEOBJECTS
public:
virtual ~Component() = default;
};
#include "ComponentID.h"
class Rectangle2d : public Component {
public:
Vector2d dimensions;
Vector2d pos;
static std::vector<ComponentTypeID> Exclusions() {
return { GetComponentTypeID<Circle2d>() };
}
Rectangle2d() = default;
Rectangle2d(Vector2d dimensions_, Vector2d pos_) : dimensions(dimensions_), pos(pos_) {};
};
class Circle2d : public Component {
public:
float radius;
Vector2d pos;
static std::vector<ComponentTypeID> Exclusions() {
return { GetComponentTypeID<Rectangle2d>() };
}
Circle2d() = default;
Circle2d(float radius_, Vector2d pos_) : radius(radius_), pos(pos_) {};
};
class SpriteRenderer : public Component {
public:
int w, h, c;
float sw = 1.0f, sh = 1.0f; // scaled w/h, leave 1 if no scaling
int x, y;
std::vector<unsigned char> pixels;
SpriteRenderer* SetSprite(std::string path, int x, int y);
SpriteRenderer* SetSpriteScale(float sw, float sh);
static std::vector<ComponentTypeID> Exclusions() {
return {};
}
SpriteRenderer() = default;
SpriteRenderer(std::string path, int x, int y);
};