mirror of
https://gitlab.com/dosowisko.net/libsuperderpy.git
synced 2024-12-12 12:08:00 +01:00
character: Pass current frame number to animation stream callback
Without that there's no way to restart an already running animation.
This commit is contained in:
parent
5476be3631
commit
5f4f5bafaf
2 changed files with 5 additions and 5 deletions
|
@ -60,7 +60,7 @@ SYMBOL_EXPORT void SelectSpritesheet(struct Game* game, struct Character* charac
|
|||
free(character->frame);
|
||||
}
|
||||
character->frame = calloc(1, sizeof(struct SpritesheetFrame));
|
||||
*(character->frame) = tmp->stream(game, 0.0, tmp->stream_data);
|
||||
*(character->frame) = tmp->stream(game, 0.0, character->pos, tmp->stream_data);
|
||||
character->frame->_priv.image = al_create_sub_bitmap(character->frame->bitmap, character->frame->sx * tmp->scale, character->frame->sy * tmp->scale, (character->frame->sw > 0) ? (character->frame->sw * tmp->scale) : al_get_bitmap_width(character->frame->bitmap), (character->frame->sh > 0) ? (character->frame->sh * tmp->scale) : al_get_bitmap_height(character->frame->bitmap));
|
||||
|
||||
tmp->width = al_get_bitmap_width(character->frame->bitmap);
|
||||
|
@ -228,7 +228,7 @@ SYMBOL_EXPORT void PreloadStreamedSpritesheet(struct Game* game, struct Characte
|
|||
spritesheet->frames = calloc(size, sizeof(struct SpritesheetFrame));
|
||||
while (true) {
|
||||
PrintConsole(game, " - frame %d", i);
|
||||
spritesheet->frames[i] = spritesheet->stream(game, delta, spritesheet->stream_data);
|
||||
spritesheet->frames[i] = spritesheet->stream(game, delta, i, spritesheet->stream_data);
|
||||
|
||||
if (!spritesheet->frames[i].owned) {
|
||||
spritesheet->frames[i].bitmap = al_clone_bitmap(spritesheet->frames[i].bitmap);
|
||||
|
@ -696,7 +696,7 @@ SYMBOL_EXPORT void AnimateCharacter(struct Game* game, struct Character* charact
|
|||
al_destroy_bitmap(character->frame->_priv.image);
|
||||
free(character->frame);
|
||||
character->frame = calloc(1, sizeof(struct SpritesheetFrame));
|
||||
*(character->frame) = character->spritesheet->stream(game, duration, character->spritesheet->stream_data);
|
||||
*(character->frame) = character->spritesheet->stream(game, duration, pos, character->spritesheet->stream_data);
|
||||
character->frame->_priv.image = al_create_sub_bitmap(character->frame->bitmap, character->frame->sx * character->spritesheet->scale, character->frame->sy * character->spritesheet->scale, (character->frame->sw > 0) ? (character->frame->sw * character->spritesheet->scale) : al_get_bitmap_width(character->frame->bitmap), (character->frame->sh > 0) ? (character->frame->sh * character->spritesheet->scale) : al_get_bitmap_height(character->frame->bitmap));
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -49,8 +49,8 @@ struct SpritesheetFrame {
|
|||
} _priv;
|
||||
};
|
||||
|
||||
typedef struct SpritesheetFrame SpritesheetStream(struct Game*, double, void*);
|
||||
#define SPRITESHEET_STREAM(x) struct SpritesheetFrame x(struct Game* game, double delta, void* data)
|
||||
typedef struct SpritesheetFrame SpritesheetStream(struct Game*, double, int, void*);
|
||||
#define SPRITESHEET_STREAM(x) struct SpritesheetFrame x(struct Game* game, double delta, int frame, void* data)
|
||||
|
||||
typedef void SpritesheetStreamDestructor(struct Game*, void*);
|
||||
#define SPRITESHEET_STREAM_DESCTRUCTOR(x) void x(struct Game* game, void* data)
|
||||
|
|
Loading…
Reference in a new issue