This function is used to add an animation to the animator.
void dg_animator_add(dg_dg_animation_t * animator, char * key, dg_animation_t *animation);
dg_animator_add(player, "walk", walk);
void dg_animator_add(dg_animation_t * animator, char * key, dg_animation_t *animation)
{
dg_animation_t **new_anim_list = 0;
char **new_key_list = 0;
new_anim_list = malloc(sizeof(dg_animation_t *) * (animator->length + 1));
new_key_list = malloc(sizeof(char *) * (animator->length + 1));
if (animator->length != 0) {
for (int i = 0; i < animator->length; i++) {
new_anim_list[i] = animator->animations[i];
new_key_list[i] = animator->keys[i];
}
free(animator->animations);
free(animator->keys);
}
new_anim_list[animator->length] = animation;
new_key_list[animator->length] = key;
animator->animations = new_anim_list;
animator->keys = new_key_list;
animator->length++;
}