Automatic drawable objects.
This module allows creating automatic objects that draw theirselves into the screen and vanish once complete. They could be considered as lightweight alternatives to actions, however in contrast to them, drawables do have a position.
Maximum number of drawable in a unique drawable_stack.
#define DRAWABLE_STACK_MAX 128
Abstract drawable object.
Optional drawable data.
Position on screen.
Update the drawable
self with the
ticks since last frame. The callback
should return true if it is considered complete.
bool (*update)(struct drawable *self, unsigned int ticks)
Draw the drawable
void (*draw)(struct drawable *self)
Called with the drawable
self when it was completed.
This callback is mostly provided to allow the user doing something else once an drawable is complete. Predefined drawable should not use this callback by themselves.
void (*end)(struct drawable *self)
Destroy internal resources for the drawable
void (*finish)(struct drawable *self)
Stack of drawable objects.
This stack of drawable object can be used to store drawable objects within a specific transition (state, battle, menu, etc).
You can add, clear, update and draw them.
Non-owning array of drawables to manage.
Invoke and return the
dw update callback with the given event
ticks since last frame if it is not NULL.
bool drawable_update(struct drawable *dw, unsigned int ticks)
dw draw callback if it is not NULL.
void drawable_draw(struct drawable *dw)
dw end callback if it is not NULL.
void drawable_end(struct drawable *dw)
dw finish callback if it is not NULL.
void drawable_finish(struct drawable *dw)
Initalize the drawable stack
It is unnecessary if the object was zero'ed.
void drawable_stack_init(struct drawable_stack *st)
Add the drawable
dw to the stack pointed by
st. Returns true if there was
enough room to insert.
bool drawable_stack_add(struct drawable_stack *st, struct drawable *dw)
Update all drawables with
ticks since last frame in the stack
bool drawable_stack_update(struct drawable_stack *st, unsigned int ticks)
Draw all drawables in the stack
void drawable_stack_draw(const struct drawable_stack *st)
Tells if there is any pending drawable in the stack
st. Returns true if there
are no drawables or if they have all completed.
bool drawable_stack_completed(const struct drawable_stack *st)
Terminate all drawables and clear the stack
void drawable_stack_finish(struct drawable_stack *st)