#ifndef JNR_PARALLAX_H #define JNR_PARALLAX_H #include #include #include "config.h" /* Forward declarations */ typedef struct Camera Camera; /* A single parallax layer */ typedef struct ParallaxLayer { SDL_Texture *texture; /* the background image */ int tex_w, tex_h; /* texture dimensions in pixels */ float scroll_x; /* horizontal scroll factor (0=fixed, 1=full) */ float scroll_y; /* vertical scroll factor */ bool active; /* whether this layer is in use */ bool owns_texture; /* true if we generated it (must free) */ } ParallaxLayer; /* Parallax background system — up to two layers */ typedef struct Parallax { ParallaxLayer far_layer; /* distant background (stars) */ ParallaxLayer near_layer; /* mid-ground background (nebula) */ } Parallax; /* Initialize parallax (zeroes everything) */ void parallax_init(Parallax *p); /* Set a layer from an existing texture (loaded via assets) */ void parallax_set_far(Parallax *p, SDL_Texture *tex, float scroll_x, float scroll_y); void parallax_set_near(Parallax *p, SDL_Texture *tex, float scroll_x, float scroll_y); /* Generate procedural starfield texture (far layer) */ void parallax_generate_stars(Parallax *p, SDL_Renderer *renderer); /* Generate procedural nebula/dust texture (near layer) */ void parallax_generate_nebula(Parallax *p, SDL_Renderer *renderer); /* Themed parallax generation styles */ typedef enum ParallaxStyle { PARALLAX_STYLE_DEFAULT, /* generic space (same as stars+nebula) */ PARALLAX_STYLE_ALIEN_SKY, /* alien planet surface: dusty, hazy */ PARALLAX_STYLE_INTERIOR, /* indoor base: panels, pipes, structural */ PARALLAX_STYLE_DEEP_SPACE, /* space station windows: vivid stars */ PARALLAX_STYLE_MOON, /* moon surface: craters, grey terrain */ } ParallaxStyle; /* Generate both layers with a unified style */ void parallax_generate_themed(Parallax *p, SDL_Renderer *renderer, ParallaxStyle style); /* Render both layers (call before tile/entity rendering) */ void parallax_render(const Parallax *p, const Camera *cam, SDL_Renderer *renderer); /* Free generated textures (not file-loaded ones — asset manager owns those) */ void parallax_free(Parallax *p); #endif /* JNR_PARALLAX_H */