Engine
Raylib based game framework
Loading...
Searching...
No Matches
Components.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "MyMath/MyVectors.hpp"
4#include "raylib.h"
5
6#include "Types.hpp"
7
8#include <Engine/Registry.hpp>
9#include <Networking/Encryption.hpp>
10#include <functional>
11#include <vector>
12
17
18
19namespace Component
20{
25 struct Transform
26 {
27 Vec2<float> position;
28 Vec2<float> velocity;
29 float rotation = 0;
30
31 constexpr bool operator<=>(const Transform&) const = default;
32 };
33
38 struct Sprite
39 {
40 Texture2D texture = {};
41 Rectangle rectangle = {0, 0, 0, 0};
42 Color color = WHITE;
43 float scale = 1;
44 u32 layer = 1;
45 };
46
51 struct Animation
52 {
53 Texture2D texture = {};
54 std::vector<Rectangle> frames;
55 float frameDuration = 1;
56 bool loop = false;
57
58 float time = 0;
59 bool playing = true;
60 float speed = 1;
61 };
62
67 struct Particle
68 {
69 Vec2<float> position;
70 Vec2<float> velocity;
71 float lifetime = 1;
72 float age = 0;
73
74 Color startColor = WHITE;
75 Color endColor = {255, 255, 255, 0};
76 float startSize = 1;
77 float endSize = 1;
78
79 float rotation = 0;
80 float angularVelocity = 0;
81
82 Texture2D texture = {};
83 Rectangle texRect = {};
84 };
85
91 {
92 float radius = 1;
93 bool edgeOnly = false;
94
95 float spawnRate = 10;
96 u32 burst = 0;
97 bool playing = true;
98
99 float lifetimeMin = 1;
100 float lifetimeMax = 1;
101
102 float speedMin = 1;
103 float speedMax = 1;
104
105 bool useDirection = false;
106 float directionAngle = 0;
107 float directionSpread = 0;
108
109 Color startColor = WHITE;
110 Color endColor = {255, 255, 255, 0};
111 float startSize = 1;
112 float endSize = 1;
113
114 Texture2D texture = {};
115 std::vector<Rectangle> textureFrames;
116
117 float angularVelocityMin = 0;
118 float angularVelocityMax = 0;
119 float initialRotationMin = 0;
120 float initialRotationMax = 0;
121
122 std::function<Component::Particle(const Component::ParticleEmitter&, const Vec2<float>&)> spawnOverride;
123
124 float gravity = 0;
125
126 float spawnAccumulator = 0;
127 };
128}
Engine entt::registry wrapper.
Frame‑based animation data and playback state.
Definition Components.hpp:52
Spawn parameters and runtime state for a particle emitter.
Definition Components.hpp:91
Individual particle state (position, velocity, colour, size, etc.).
Definition Components.hpp:68
Texture, source rectangle, tint, scale and render layer.
Definition Components.hpp:39
Position, velocity and rotation.
Definition Components.hpp:26