2025-09-24 00:39:44 -05:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "pxl8_types.h"
|
|
|
|
|
#include "pxl8_gfx.h"
|
|
|
|
|
|
2025-09-27 11:03:36 -05:00
|
|
|
typedef struct pxl8_tile_animation pxl8_tile_animation;
|
|
|
|
|
typedef struct pxl8_tile_properties pxl8_tile_properties;
|
|
|
|
|
typedef struct pxl8_autotile_rule pxl8_autotile_rule;
|
|
|
|
|
|
2025-09-24 00:39:44 -05:00
|
|
|
typedef struct pxl8_tilesheet {
|
|
|
|
|
u8* data;
|
|
|
|
|
bool* tile_valid;
|
|
|
|
|
u32 width;
|
|
|
|
|
u32 height;
|
|
|
|
|
u32 tile_size;
|
|
|
|
|
u32 tiles_per_row;
|
|
|
|
|
u32 total_tiles;
|
|
|
|
|
pxl8_color_mode color_mode;
|
2025-09-27 11:03:36 -05:00
|
|
|
u32 ref_count;
|
|
|
|
|
|
|
|
|
|
pxl8_tile_animation* animations;
|
|
|
|
|
u32 animation_count;
|
|
|
|
|
|
|
|
|
|
pxl8_tile_properties* properties;
|
|
|
|
|
|
|
|
|
|
pxl8_autotile_rule** autotile_rules;
|
|
|
|
|
u32* autotile_rule_counts;
|
2025-09-24 00:39:44 -05:00
|
|
|
} pxl8_tilesheet;
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
|
2025-09-28 13:10:29 -05:00
|
|
|
pxl8_result pxl8_tilesheet_add_animation(
|
|
|
|
|
pxl8_tilesheet* tilesheet,
|
|
|
|
|
u16 base_tile_id,
|
|
|
|
|
const u16* frames,
|
|
|
|
|
u16 frame_count,
|
|
|
|
|
f32 frame_duration
|
|
|
|
|
);
|
|
|
|
|
pxl8_result pxl8_tilesheet_add_autotile_rule(
|
|
|
|
|
pxl8_tilesheet* tilesheet,
|
|
|
|
|
u16 base_tile_id,
|
|
|
|
|
u8 neighbor_mask,
|
|
|
|
|
u16 result_tile_id
|
|
|
|
|
);
|
|
|
|
|
u16 pxl8_tilesheet_apply_autotile(const pxl8_tilesheet* tilesheet, u16 base_tile_id, u8 neighbors);
|
2025-09-24 00:39:44 -05:00
|
|
|
void pxl8_tilesheet_free(pxl8_tilesheet* tilesheet);
|
2025-09-28 13:10:29 -05:00
|
|
|
u16 pxl8_tilesheet_get_animated_frame(const pxl8_tilesheet* tilesheet, u16 tile_id);
|
|
|
|
|
const pxl8_tile_properties* pxl8_tilesheet_get_tile_property(
|
|
|
|
|
const pxl8_tilesheet* tilesheet,
|
|
|
|
|
u16 tile_id
|
|
|
|
|
);
|
2025-09-24 00:39:44 -05:00
|
|
|
bool pxl8_tilesheet_is_tile_valid(const pxl8_tilesheet* tilesheet, u16 tile_id);
|
2025-09-28 13:10:29 -05:00
|
|
|
pxl8_result pxl8_tilesheet_load(pxl8_tilesheet* tilesheet, const char* filepath, pxl8_gfx_ctx* gfx);
|
2025-09-27 11:03:36 -05:00
|
|
|
void pxl8_tilesheet_ref(pxl8_tilesheet* tilesheet);
|
2025-09-28 13:10:29 -05:00
|
|
|
void pxl8_tilesheet_render_tile(
|
|
|
|
|
const pxl8_tilesheet* tilesheet,
|
|
|
|
|
pxl8_gfx_ctx* gfx,
|
|
|
|
|
u16 tile_id,
|
|
|
|
|
i32 x,
|
|
|
|
|
i32 y,
|
|
|
|
|
u8 flags
|
|
|
|
|
);
|
|
|
|
|
void pxl8_tilesheet_set_tile_property(
|
|
|
|
|
pxl8_tilesheet* tilesheet,
|
|
|
|
|
u16 tile_id,
|
|
|
|
|
const pxl8_tile_properties* props
|
|
|
|
|
);
|
2025-09-27 11:03:36 -05:00
|
|
|
void pxl8_tilesheet_unref(pxl8_tilesheet* tilesheet);
|
|
|
|
|
void pxl8_tilesheet_update_animations(pxl8_tilesheet* tilesheet, f32 delta_time);
|
|
|
|
|
|
2025-09-24 00:39:44 -05:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
2025-09-27 11:03:36 -05:00
|
|
|
#endif
|