Air-Trap 1.0.0
A multiplayer R-Type clone game engine built with C++23 and ECS architecture
Loading...
Searching...
No Matches
ParallaxSystem.hpp
Go to the documentation of this file.
1#pragma once
2
7
8namespace rtp::client {
9
11 public:
12 explicit ParallaxSystem(ecs::Registry& r) : _r(r) {}
13
14 void update(float dt) override {
16
17 for (auto&& [transform, parallax] : view) {
18 transform.position.x -= parallax.speed * dt;
19
20 float scaledWidth = parallax.textureWidth * transform.scale.x;
21 if (transform.position.x <= -scaledWidth) {
22 transform.position.x += scaledWidth * 2.0f;
23 }
24 }
25 }
26
27 private:
29 };
30} // namespace rtp::client
Interface for ECS systems.
void update(float dt) override
Update system logic for one frame.
ParallaxSystem(ecs::Registry &r)
Abstract base class for all ECS systems.
Definition ISystem.hpp:57
auto zipView(this Self &self)
R-Type client namespace.
Tag component indicating that an entity should loop its position when it exits the screen (infinite s...
float speed
Scrolling speed of the parallax layer.
Component representing position, rotation, and scale of an entity.
Definition Transform.hpp:23