70 [[nodiscard]]
constexpr float duration() const noexcept {
76 [[nodiscard]]
constexpr std::uint32_t
frame() const noexcept {
77 const std::uint32_t frames =
count == 0 ? 1 :
count;
82 if (!(steps <
static_cast<float>(frames))) {
85 const auto step =
static_cast<std::uint32_t
>(steps);
86 return first + (step < frames ? step : frames - 1);
91 [[nodiscard]]
constexpr bool finished() const noexcept {
191 [[nodiscard]]
constexpr bool holds(
Action action)
const noexcept {
192 return (
held &
static_cast<std::uint8_t
>(action)) != 0U;
198 constexpr void set(
Action action,
bool pressed)
noexcept {
199 const auto bit =
static_cast<std::uint8_t
>(action);
200 held =
static_cast<std::uint8_t
>(pressed ?
held | bit :
held & ~bit);
267 return std::hash<aegis2d::ecs::Entity::Id>{}(
id.value);
276using shmup::AutoTrigger;
Handle to an entity: 32 bits made of a 24-bit index and an 8-bit generation.
Definition entity.hpp:23
std::uint32_t Id
Packed value: generation in the 8 high bits, index in the 24 low bits.
Definition entity.hpp:30
Generational entity handle: an index into the component pools plus a generation.
Vector and matrix types of the engine (GLM behind engine names).
Entity-Component-System used by client and server.
Definition animation.hpp:13
Action
Actions a player can hold, one bit each in PlayerInput.
Definition components.hpp:168
@ Up
Move up (towards y = 0).
Root namespace of the engine.
Definition audio.hpp:17
glm::vec4 Vec4
4D vector of floats (glm::vec4), e.g. homogeneous positions.
Definition math.hpp:25
glm::vec2 Vec2
2D vector of floats: positions, velocities, sizes (glm::vec2).
Definition math.hpp:19
Components of the shoot'em up module: player ships and weapons.
Frames of the entity's Sprite shown in turn, at a steady rate.
Definition components.hpp:56
float elapsed
Seconds into the clip; kept below duration() while looping.
Definition components.hpp:66
bool loop
true to start again after the last frame, false to stop on it.
Definition components.hpp:64
std::uint32_t first
First frame of the clip in the sprite sheet.
Definition components.hpp:58
constexpr float duration() const noexcept
Length of the clip.
Definition components.hpp:70
constexpr std::uint32_t frame() const noexcept
Frame to show now.
Definition components.hpp:76
constexpr bool finished() const noexcept
Tells whether a clip that does not loop has shown its last frame long enough.
Definition components.hpp:91
std::uint32_t count
Number of frames of the clip; 0 counts as 1.
Definition components.hpp:60
float frame_time
Seconds each frame stays on screen; 0 or less keeps the first frame.
Definition components.hpp:62
Axis-aligned box an entity collides with.
Definition components.hpp:101
std::uint32_t layer
Layers the entity belongs to, one bit each.
Definition components.hpp:107
Vec2 offset
Center of the box relative to the entity's position.
Definition components.hpp:105
std::uint32_t mask
Layers the entity can collide with.
Definition components.hpp:109
Vec2 size
Width and height of the box, in logical pixels.
Definition components.hpp:103
How much damage an entity deals to what it hits.
Definition components.hpp:128
bool consumed_on_hit
true if the entity disappears after its first hit (missiles).
Definition components.hpp:132
std::int32_t amount
Health points removed from the target by one hit.
Definition components.hpp:130
Entity destroyed once its Animation has played to the end: a visual effect that lasts as long as its ...
Definition components.hpp:209
How much damage an entity can still take.
Definition components.hpp:115
constexpr bool depleted() const noexcept
Tells whether the entity has no health left.
Definition components.hpp:121
std::int32_t points
Remaining health points.
Definition components.hpp:117
Lives of a player, and how it comes back after losing one.
Definition components.hpp:158
Vec2 spawn
Where the player respawns (Transform::position).
Definition components.hpp:162
std::uint32_t count
Lives left, the current one included; 0 once the player is out.
Definition components.hpp:160
std::int32_t health
Health points given back on respawn.
Definition components.hpp:164
Identity of an entity shared by the server and the clients.
Definition components.hpp:245
Entity::Id value
The server entity's Entity::id().
Definition components.hpp:247
friend constexpr bool operator==(const NetworkId &, const NetworkId &) noexcept=default
Compares the ids.
static constexpr NetworkId of(Entity entity) noexcept
Network id of a server entity.
Definition components.hpp:252
Entity destroyed once it has left the play area for good.
Definition components.hpp:217
float margin
Distance beyond each edge of the area, in logical pixels, before the entity counts as gone.
Definition components.hpp:220
Entity that created this one, e.g. the player who fired a missile.
Definition components.hpp:137
Entity entity
The creator; null if there is none.
Definition components.hpp:139
Points earned by the player who destroys this entity.
Definition components.hpp:149
std::uint32_t points
Points of one kill, 100 by default.
Definition components.hpp:151
Points a player has earned.
Definition components.hpp:143
std::uint32_t points
Total points; it stops at the largest value instead of wrapping.
Definition components.hpp:145
Sine wave added to an entity's movement, like an enemy weaving up and down.
Definition components.hpp:230
Vec2 amplitude
Largest offset from the path, in logical pixels, and its direction: {0, 48} weaves 48 pixels up and d...
Definition components.hpp:233
float period
Seconds for one full wave; a period of zero or less does not move the entity.
Definition components.hpp:235
float elapsed
Seconds into the current wave, kept in [0, period). Starting above 0 shifts the phase,...
Definition components.hpp:238
What an entity looks like.
Definition components.hpp:34
std::int32_t layer
Drawing order: higher layers are drawn over lower ones.
Definition components.hpp:43
Vec2 size
Size on screen, in logical pixels.
Definition components.hpp:39
std::uint32_t texture
Texture of the resource manager (render::TextureId), 0 for a plain rectangle.
Definition components.hpp:37
Vec4 tint
RGBA color multiplied with the texture, components in [0, 1]; opaque white keeps it unchanged.
Definition components.hpp:46
std::uint32_t frame
Frame of the texture's sprite sheet, 0 for the first (or only) frame.
Definition components.hpp:41
How fast an entity moves.
Definition components.hpp:25
Vec2 value
Speed in logical pixels per second.
Definition components.hpp:27