-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathComponents.h
More file actions
116 lines (96 loc) · 2.11 KB
/
Components.h
File metadata and controls
116 lines (96 loc) · 2.11 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#pragma once
#include "Vec2.h"
#include <SFML/Graphics.hpp>
#include "Animation.h"
class Component {
public:
bool has = false;
};
class CTransform : public Component {
public:
Vec2 pos = { 0.0, 0.0 };
Vec2 prevPos = { 0.0, 0.0 };
Vec2 velocity = { 0.0f, 0.0f };
Vec2 scale = { 1.0f, 1.0f };
float angle = 0;
CTransform() {}
CTransform(const Vec2& p, const Vec2& v, float a) :
pos(p), velocity(v), angle(a) {}
};
class CShape : public Component {
public:
sf::CircleShape circle;
CShape() {}
CShape(float radius, int point, const sf::Color fill,
const sf::Color& outline, float thickness)
: circle(radius, point) {
circle.setFillColor(fill);
circle.setOutlineColor(outline);
circle.setOutlineThickness(thickness);
circle.setOrigin(radius, radius);
}
};
class CSprite : public Component {
public :
sf::Sprite sprite;
sf::IntRect rect;
CSprite() {}
CSprite(sf::Texture& t, sf::IntRect r) : sprite(t, r), rect(r){
sprite.setOrigin(r.width/2, r.height/2);
}
};
class CCollision : public Component {
public:
float radius = 0;
CCollision(){}
CCollision(float r) : radius(r) {}
};
class CScore : public Component {
public:
int score = 0;
CScore() {}
CScore(int s) : score(s) {}
};
class CLifespan : public Component {
public:
int remaining = 0;
int total = 0;
CLifespan(int total)
: remaining(total), total(total) {}
CLifespan() {}
};
class CInput : public Component {
public:
bool up = false;
bool down = false;
bool left = false;
bool right = false;
bool shoot = false;
Vec2 axis = {0.0, 0.0};
CInput() : axis(0.0, 0.0){}
};
class CBoundingBox : public Component {
public:
Vec2 size;
Vec2 halfSize;
CBoundingBox(Vec2 s) : size(s) , halfSize(s.x/2, s.y/2){}
CBoundingBox() {}
};
class CAnimation : public Component {
public:
Animation currentAnimation;
CAnimation() {};
CAnimation(Animation newAnim) : currentAnimation(newAnim) {}
};
class CState : public Component {
public :
std::string stateName;
CState() {};
CState(const std::string& name) : stateName(name) {}
};
class CGravity : public Component {
public:
float gravity;
CGravity() {};
CGravity(float value) : gravity(value) {}
};