You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.4 KiB

#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(list->head == 0){
list->head = new;
list->tail = new;
}
else if(list->head == list->tail){
list->head = new;
list->head->next = list->tail;
list->tail->prev = list->head;
}
else{
list->head->prev = new;
new->next = list->head;
list->head = new;
}
}
void AnimationInsertBack(Animation *animation, Texture2D *texture){
AnimationFrame *new = AnimationFrameCreate(texture);
if(list->head == 0){
list->head = new;
list->tail = new;
}
else if(list->head == list->tail){
list->tail = new;
list->head->next = list->tail;
list->tail->prev = list->head;
}
else{
list->tail->next = new;
new->prev = list->tail;
list->tail = new;
}
}