#include "animation.h" #include "stdlib.h" Animation * AnimationInit(){ Animation *animation = (Animation *) malloc(sizeof(Animation)); animation->head = 0; animation->tail = 0; return animation; } AnimationFrame * AnimationFrameCreate(Texture2D *texture){ AnimationFrame *frame = (AnimationFrame *) malloc(sizeof(AnimationFrame)); frame->texture = texture; frame->next = 0; frame->prev = 0; return frame; } void AnimationInsertFront(Animation *animation, Texture2D *texture){ AnimationFrame *new = AnimationFrameCreate(texture); if(animation->head == 0){ animation->head = new; animation->tail = new; animation->head->prev = animation->tail; animation->tail->next = animation->head->prev; } else if(animation->head == animation->tail){ animation->head = new; animation->head->next = animation->tail; animation->head->prev = animation->tail; animation->tail->prev = animation->head; animation->tail->next = animation->head; } else{ animation->head->prev = new; new->next = animation->head; new->prev = animation->tail; animation->tail->next = new; animation->head = new; } } void AnimationInsertBack(Animation *animation, Texture2D *texture){ AnimationFrame *new = AnimationFrameCreate(texture); if(animation->head == 0){ animation->head = new; animation->tail = new; animation->head->prev = animation->tail; animation->tail->next = animation->head->prev; } else if(animation->head == animation->tail){ animation->tail = new; animation->head->next = animation->tail; animation->head->prev = animation->tail; animation->tail->prev = animation->head; animation->tail->next = animation->head; } else{ animation->tail->next = new; new->prev = animation->tail; new->next = animation->head; animation->head->prev = new; animation->tail = new; } }