2024-10-21 01:18:48 -03:00
|
|
|
#ifndef PARALLAX_H
|
|
|
|
#define PARALLAX_H
|
|
|
|
|
|
|
|
#include <stdint.h>
|
2024-10-23 02:53:23 -03:00
|
|
|
#include "camera.h"
|
2024-10-21 01:18:48 -03:00
|
|
|
|
|
|
|
/* .PRL file layout
|
|
|
|
==================
|
|
|
|
number of strips: u8
|
|
|
|
Array of strips:
|
|
|
|
number of parts: u8
|
|
|
|
do not repeat (single)?: u8
|
|
|
|
horizontal scroll factor: s16
|
|
|
|
Y position: s16
|
|
|
|
Array of parts:
|
|
|
|
u0: u8
|
|
|
|
v0: u8
|
|
|
|
texture index (BG0 or BG1): u8
|
|
|
|
width: u16
|
|
|
|
height: u16
|
|
|
|
*/
|
|
|
|
|
2024-10-27 21:06:46 -03:00
|
|
|
// Holds a single parallax strip for a level.
|
|
|
|
// A strip is a horizontally-repeating quad.
|
2024-10-21 01:18:48 -03:00
|
|
|
typedef struct {
|
2024-10-29 03:31:53 -03:00
|
|
|
//uint8_t u0;
|
|
|
|
//uint8_t v0;
|
2024-10-21 01:18:48 -03:00
|
|
|
uint16_t width;
|
|
|
|
uint16_t height;
|
2024-10-29 03:31:53 -03:00
|
|
|
//uint8_t bgindex;
|
2024-10-21 01:18:48 -03:00
|
|
|
uint8_t is_single;
|
2024-10-23 00:56:42 -03:00
|
|
|
int32_t scrollx;
|
2024-10-25 00:49:22 -03:00
|
|
|
int32_t speedx;
|
2024-10-21 01:18:48 -03:00
|
|
|
int16_t y0;
|
2024-10-25 00:49:22 -03:00
|
|
|
|
|
|
|
// State
|
|
|
|
int32_t rposx;
|
2024-10-21 01:18:48 -03:00
|
|
|
} ParallaxStrip;
|
|
|
|
|
|
|
|
// Holds all parallax strips for a level
|
|
|
|
typedef struct {
|
|
|
|
uint8_t num_strips;
|
|
|
|
ParallaxStrip *strips;
|
|
|
|
} Parallax;
|
|
|
|
|
2024-10-27 22:41:31 -03:00
|
|
|
void load_parallax(Parallax *parallax, const char *filename,
|
2024-10-23 02:53:23 -03:00
|
|
|
uint8_t tx_mode, int32_t px, int32_t py, int32_t cx, int32_t cy);
|
2024-10-27 22:41:31 -03:00
|
|
|
void parallax_draw(Parallax *prl, Camera *camera);
|
2024-10-21 01:18:48 -03:00
|
|
|
|
|
|
|
#endif
|