Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
ParallaxLayerManager.h
Go to the documentation of this file.
1/*
2 * ParallaxLayerManager.h - Parallax scrolling system for image layers
3 *
4 * Manages parallax background/foreground layers with support for:
5 * - Parallax scroll factors (parallaxx, parallaxy)
6 * - Texture repeating (repeatx, repeaty)
7 * - Layer offsets and opacity
8 * - Camera-relative positioning
9 */
10
11#pragma once
12
13#include <string>
14#include <vector>
15#include <memory>
16#include "../../ECS_Systems.h"
17
18// Forward declarations
19struct SDL_Texture;
20struct SDL_Renderer;
21
22namespace Olympe {
23namespace Tiled {
24
25
26
28 {
29 string name;
30 string imagePath;
33 float offsetX;
34 float offsetY;
35 float opacity;
36 bool repeatX;
37 bool repeatY;
38 bool visible;
39 int tintColor; // ARGB
40 int zOrder; // Z-order for sorting (lower = background, higher = foreground)
41 SDL_Texture* texture; // Runtime texture
42
44 : scrollFactorX(1.0f), scrollFactorY(1.0f),
45 offsetX(0.0f), offsetY(0.0f), opacity(1.0f),
47 tintColor(0xFFFFFFFF), zOrder(0), texture(nullptr) {
48 }
49 };
50
52 {
53 public:
54 // Singleton access
55 static ParallaxLayerManager& Get();
56
57 // Add a parallax layer
58 void AddLayer(const ParallaxLayer& layer);
59
60 // Get all layers
61 const vector<ParallaxLayer>& GetLayers() const { return layers_; }
62
63 // Clear all layers
64 void Clear();
65
66 // Calculate render position for a layer based on camera position
68 const ParallaxLayer& layer,
69 float cameraX, float cameraY,
70 float zoom,
71 float& outX, float& outY) const;
72
73 // Get number of layers
74 size_t GetLayerCount() const { return layers_.size(); }
75
76 // Get layer by index
77 const ParallaxLayer* GetLayer(size_t index) const;
78
79 // Render a specific layer
80 void RenderLayer(const ParallaxLayer& layer, const CameraTransform& cam) const;
81
82 // Render all layers in z-order
83 void RenderAllLayers(const CameraTransform& cam) const;
84
87
88 // Prevent copying
91
93 };
94
95} // namespace Tiled
96} // namespace Olympe
RenderLayer
Render layer enumeration for Z-ordering.
ComponentTypeID GetComponentTypeID_Static()
Definition ECS_Entity.h:56
const ParallaxLayer * GetLayer(size_t index) const
ParallaxLayerManager(const ParallaxLayerManager &)=delete
void AddLayer(const ParallaxLayer &layer)
void RenderAllLayers(const CameraTransform &cam) const
ParallaxLayerManager & operator=(const ParallaxLayerManager &)=delete
const vector< ParallaxLayer > & GetLayers() const
static ParallaxLayerManager & Get()
void CalculateRenderPosition(const ParallaxLayer &layer, float cameraX, float cameraY, float zoom, float &outX, float &outY) const