1 #ifndef RL_TILE_H 2 #define RL_TILE_H 3 4 #include <rl_userdata.h> 5 6 #include <stdint.h> 7 #include <stddef.h> 8 9 /* 10 A tile is a rectangular area of 100% opaque pixels pixels. A tileset is a 11 collection of tiles that share the same dimensions. 12 */ 13 14 typedef struct 15 { 16 rl_userdata_t ud; 17 18 int width; /* the width of each tile */ 19 int height; /* the height of each tile */ 20 int size; /* width * height */ 21 int num_tiles; /* the number of tiles in this tileset */ 22 23 const uint16_t data[ 0 ]; /* the tiles' pixels */ 24 } 25 rl_tileset_t; 26 27 /* Creates a tileset given the data produced by rltileset. */ 28 rl_tileset_t* rl_tileset_create( const void* data, size_t size ); 29 /* Destroys a tileset. */ 30 #define rl_tileset_destroy( tileset) do { rl_free( tileset ); } while ( 0 ) 31 32 /* Blits a tile from a tileset onto the background. */ 33 void rl_tileset_blit_nobg( const rl_tileset_t* tileset, int index, int x, int y ); 34 /* Blits a tile from a tileset onto the background, saving overwritten pixels in bg. */ 35 uint16_t* rl_tileset_blit( const rl_tileset_t* tileset, int index, int x, int y, uint16_t* bg ); 36 /* Erases a tile from a tileset from the background, restoring overwritten pixels from bg. */ 37 void rl_tileset_unblit( const rl_tileset_t* tileset, int x, int y, const uint16_t* bg ); 38 39 /* Blits a tile onto the background. */ 40 void rl_tile_blit_nobg( int width, int height, const uint16_t* pixels, int x, int y ); 41 /* Blits a tile onto the background, saving overwritten pixels in bg. */ 42 uint16_t* rl_tile_blit( int width, int height, const uint16_t* pixels, int x, int y, uint16_t* bg ); 43 /* Erases a tile from the background, restoring overwritten pixels from bg. */ 44 void rl_tile_unblit( int width, int height, int x, int y, const uint16_t* bg ); 45 46 #endif /* RL_TILE_H */ 47