8#include <aegis2d/render/export.hpp>
35 {.count = 160, .speed = 25.0F, .size = 1.0F, .color =
rgb(0x50506A)},
36 {.count = 90, .speed = 70.0F, .size = 2.0F, .color =
rgb(0x8080A0)},
37 {.count = 40, .speed = 160.0F, .size = 3.0F, .color =
rgb(0xC8C8E6)},
62 explicit Starfield(
Vec2 area, std::span<const StarLayer> layers = default_star_layers,
63 std::uint64_t seed = 1);
68 void update(
double seconds)
noexcept;
84 [[nodiscard]] std::vector<Vec2>
positions(std::size_t layer)
const;
88 [[nodiscard]]
double elapsed() const noexcept;
92 [[nodiscard]]
std::
size_t layers() const noexcept;
96 [[nodiscard]]
std::
size_t size() const noexcept;
100 [[nodiscard]]
Vec2 area() const noexcept;
105 std::vector<Vec2> starts;
108 [[nodiscard]]
float x_of(
const Layer& layer,
float start)
const noexcept;
111 std::vector<Layer> layers_;
112 double elapsed_ = 0.0;
What the game draws with, whatever the graphics API behind it.
Definition renderer.hpp:81
Stars scrolling across the screen in layers, each at its own speed: a parallax background for a side-...
Definition starfield.hpp:54
std::vector< Vec2 > positions(std::size_t layer) const
Where the stars of a layer are now.
void update(core::Duration step) noexcept
Moves time forward by a step, such as one tick of core::MainLoop.
void update(double seconds) noexcept
Moves time forward.
double elapsed() const noexcept
Time spent since the stars were spread.
Starfield(Vec2 area, std::span< const StarLayer > layers=default_star_layers, std::uint64_t seed=1)
Spreads the stars of each layer over an area.
void draw(IRenderer &renderer, std::int32_t layer=-100) const
Draws every star, from the farthest layer to the nearest.
Fixed-timestep accumulator and monotonic stopwatch.
RGBA color used by the renderer.
Vector and matrix types of the engine (GLM behind engine names).
std::chrono::nanoseconds Duration
Duration type used for simulation time (nanoseconds).
Definition clock.hpp:14
OpenGL renderer: sprites, text and camera (client only).
Definition bitmap_font.hpp:16
aegis2d::Vec2 Vec2
2D vector of floats, in logical pixels: the engine-wide aegis2d::Vec2.
Definition renderer.hpp:17
constexpr std::array< StarLayer, 3 > default_star_layers
Three layers, from the farthest: many small dim stars scrolling slowly, then fewer,...
Definition starfield.hpp:34
constexpr Color rgb(std::uint32_t hex, float alpha=1.0F) noexcept
Color from its hexadecimal sRGB code, as design tools and palettes give it.
Definition color.hpp:25
Definition endpoint.hpp:85
Backend-independent renderer interface and the sprite it draws.
RGBA color with components in [0, 1].
Definition color.hpp:10
float r
Red component.
Definition color.hpp:12
One layer of a starfield: stars at one depth.
Definition starfield.hpp:20
float size
Side of a star, in logical pixels.
Definition starfield.hpp:27
Color color
Color of the stars.
Definition starfield.hpp:29
float speed
Scroll speed, in logical pixels per second, to the left (negative: to the right). Far layers scroll s...
Definition starfield.hpp:25
std::size_t count
Number of stars.
Definition starfield.hpp:22