R-Type 0.1
Loading...
Searching...
No Matches
Parallax.hpp
1#pragma once
2
3#include <Registry.hpp>
4#include <cstdint>
5#include <nlohmann/json.hpp>
6
7namespace component {
16struct Parallax {
17 float speedX{0.0f};
18 float loopWidth{0.0f};
19};
20
27inline void parallaxFromJson(rtk::ecs::Registry &reg, std::size_t entity,
28 const nlohmann::json &data) {
29 component::Parallax parallax{};
30 parallax.speedX = data.value("speedX", 50.0f);
31 parallax.loopWidth = data.value("loopWidth", 1920.0f);
32
33 reg.get_components<component::Parallax>().insert_at(entity, parallax);
34}
35
37} // namespace component
void parallaxFromJson(rtk::ecs::Registry &reg, std::size_t entity, const nlohmann::json &data)
Adds a Parallax to an entity from its blueprint data.
Definition Parallax.hpp:27
Background layer that scrolls left and wraps around.
Definition Parallax.hpp:16
float speedX
Scrolling speed in pixels per second.
Definition Parallax.hpp:17
float loopWidth
Width of one tile of the layer, in pixels.
Definition Parallax.hpp:18