From 48cef82988d6209987ae27fe29b72d7d5e402b3c Mon Sep 17 00:00:00 2001 From: 3gg <3gg@shellblade.net> Date: Wed, 19 Jul 2023 08:35:00 -0700 Subject: Add sprites. --- gfx-iso/include/isogfx/isogfx.h | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) (limited to 'gfx-iso/include/isogfx/isogfx.h') diff --git a/gfx-iso/include/isogfx/isogfx.h b/gfx-iso/include/isogfx/isogfx.h index 6b7ce8e..e96606c 100644 --- a/gfx-iso/include/isogfx/isogfx.h +++ b/gfx-iso/include/isogfx/isogfx.h @@ -8,6 +8,12 @@ typedef struct IsoGfx IsoGfx; +/// Sprite sheet handle. +typedef uint16_t SpriteSheet; + +/// Sprite handle. +typedef uint16_t Sprite; + /// Tile handle. typedef uint16_t Tile; @@ -48,8 +54,10 @@ typedef struct WorldDesc { } WorldDesc; typedef struct IsoGfxDesc { - int screen_width; /// Screen width in pixels. - int screen_height; /// Screen height in pixels. + int screen_width; /// Screen width in pixels. + int screen_height; /// Screen height in pixels. + int max_num_sprites; /// 0 for an implementation-defined default. + int sprite_sheet_pool_size_bytes; /// 0 for an implementation-defined default. } IsoGfxDesc; /// Create a new isometric graphics engine. @@ -79,6 +87,29 @@ void isogfx_set_tile(IsoGfx*, int x, int y, Tile); /// Set the tiles in positions in the range (x0,y0) - (x1,y1). void isogfx_set_tiles(IsoGfx*, int x0, int y0, int x1, int y1, Tile); +/// Load a sprite sheet (.SS) file. +bool isogfx_load_sprite_sheet(IsoGfx*, const char* filepath, SpriteSheet*); + +/// Create an animated sprite. +Sprite isogfx_make_sprite(IsoGfx*, SpriteSheet); + +/// Destroy the sprite. +void isogfx_del_sprite(IsoGfx*, Sprite); + +/// Destroy all the sprites. +void isogfx_del_sprites(IsoGfx*); + +/// Set the sprite's position. +void isogfx_set_sprite_position(IsoGfx*, Sprite, int x, int y); + +/// Set the sprite's current animation. +void isogfx_set_sprite_animation(IsoGfx*, Sprite, int animation); + +/// Update the renderer. +/// +/// Currently this updates the sprite animations. +void isogfx_update(IsoGfx*, double t); + /// Render the world. void isogfx_render(IsoGfx*); -- cgit v1.2.3